/* 
    Gescontabilize Signature Generator - Premium Styles
    Aesthetic: Modern Professional / Glassmorphism
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #202A5B;
    --primary-light: #2D3A7D;
    --bg-main: #F4F7FA;
    --text-main: #2D3748;
    --text-muted: #718096;
    --white: #ffffff;
    --accent: #3B82F6;
    --danger: #EF4444;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.4);
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
}

.hidden-visual {
    display: none !important;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    background: var(--primary);
    color: var(--white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.logo-gescon {
    height: 32px;
}

main {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
    overflow-y: auto;
    height: calc(100vh - 64px);
}

.user-view main {
    height: 100vh;
}

.user-view .editor-panel {
    padding-top: 3rem;
}

/* Editor Panel */
.editor-panel {
    width: 380px;
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid #e2e8f0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.editor-section h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #edf2f7;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(32, 42, 91, 0.1);
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.5rem;
    cursor: pointer;
    color: var(--text-main);
}

/* Sheets Integration */
.sheet-section {
    background: rgba(59, 130, 246, 0.03);
    border: 1px solid rgba(59, 130, 246, 0.1);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.sheet-section h2 {
    color: var(--accent);
    border-bottom-color: rgba(59, 130, 246, 0.1);
}

.sheet-url-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.sheet-status {
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 1.2rem;
    margin-bottom: 0.5rem;
}

.sheet-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Dynamic Units List */
.units-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.unit-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.unit-item.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(32, 42, 91, 0.05);
}

.unit-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.02);
    user-select: none;
}

.unit-header:hover {
    background: rgba(0, 0, 0, 0.04);
}

.unit-content {
    padding: 0 1rem;
    max-height: 0;
    opacity: 0;
    transition: all 0.3s ease-out;
    pointer-events: none;
}

.unit-item.expanded .unit-content {
    padding: 1rem;
    max-height: 1000px;
    opacity: 1;
    pointer-events: auto;
}

.expand-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0 0.5rem;
}

.drag-handle:active {
    cursor: grabbing;
}

.unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.unit-header span {
    font-weight: 600;
    font-size: 0.85rem;
}

.btn-remove-unit {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-remove-unit:hover {
    opacity: 1;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: rgba(32, 42, 91, 0.05);
}

.btn-block {
    width: 100%;
}

.btn-success {
    background: #5cb85c !important;
    border-color: #4cae4c !important;
    color: var(--white) !important;
}

.actions-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: auto;
    padding-top: 2rem;
}

/* Painel de Preview */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 3rem 1.5rem;
    background-color: #f8fafc;
    overflow-y: auto;
    min-width: 0;
    /* Permite que o flex child encolha abaixo do conteúdo */
}

.preview-container {
    background: var(--white);
    padding: 2.5rem;
    border-radius: 1.25rem;
    box-shadow: var(--card-shadow);
    width: 100%;
    max-width: 780px;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--glass-border);
}

.preview-container h3 {
    position: absolute;
    top: 1rem;
    left: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#signature-canvas {
    width: 100%;
    height: 500px;
    border: none;
    background: transparent;
}

/* Social Inputs Section */
#social-inputs-container {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 2px solid #edf2f7;
}

#social-inputs-container h2 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Salvar como Padrão */
.btn-save-default {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.btn-save-default:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.5);
}

.btn-save-default:active {
    transform: translateY(0);
}

.btn-clear-default {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
    backdrop-filter: blur(4px);
}

.btn-clear-default:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.6);
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

.preview-actions .btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 180px;
}

/* Toast Notification */
#toast-msg {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    transform: translateX(120%);
    background: #1e293b;
    color: #fff;
    padding: 0.85rem 1.75rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    opacity: 0;
    pointer-events: none;
}

#toast-msg.toast-visible {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Design */
@media (max-width: 1280px) {
    .editor-panel {
        width: 320px;
    }
}

@media (max-width: 1024px) {
    body {
        overflow-y: auto;
        height: auto;
    }

    main {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .editor-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        height: auto;
    }

    .preview-panel {
        padding: 2rem 1rem;
        min-height: auto;
    }

    header {
        flex-direction: column;
        padding: 1.5rem;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .preview-container {
        padding: 1.5rem;
        border-radius: 0.75rem;
    }

    #signature-canvas {
        height: 500px;
        transform: scale(0.85);
        transform-origin: top left;
        width: 117.6%;
        /* Compensa o scale 0.85 (1 / 0.85) */
    }

    .preview-actions {
        flex-direction: column;
        margin-top: 1rem;
    }

    .preview-actions .btn {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    #signature-canvas {
        height: 400px;
        transform: scale(0.65);
        width: 153.8%;
        /* Compensa o scale 0.65 */
    }
}