:root {
    --primary-bg: #f8fafc;
    --panel-bg: #ffffff;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --primary-blue: #2563eb;
    --primary-blue-hover: #1d4ed8;
    --error-red: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-dark);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Panel de Edición (Izquierda) */
.editor-panel {
    width: 380px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.editor-header h2 {
    font-size: 1.5rem;
    color: #0f172a;
    margin-bottom: 4px;
}

.editor-header p {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 24px;
}

.editor-section {
    margin-bottom: 30px;
}

.editor-section h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: #334155;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #475569;
}

.input-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group input[type="date"] {
    color: #475569;
}

.editor-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 40px;
    padding-bottom: 30px;
}

button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

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

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

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--error-red);
    border-color: var(--error-red);
}

.btn-secondary:hover {
    background-color: #fef2f2;
}

/* Panel de Vista Previa (Derecha) */
.preview-panel {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    background-color: #cbd5e1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    gap: 40px;
}

.dc3-document {
    background-color: white;
    width: 21.59cm; /* Letter size width */
    min-height: 27.94cm; /* Letter size height */
    padding: 0.8cm 1.5cm; /* Reducido para evitar overflow en html2pdf */
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    font-family: Arial, Helvetica, sans-serif;
    color: black;
    position: relative;
}

/* Front Page Layout */
.dc3-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.company-logo {
    max-width: 180px;
    height: auto;
    max-height: 85px;
    background-color: white;
}

.folio-container {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

.dc3-title-section {
    text-align: center;
    margin-bottom: 20px;
}

.dc3-title-section h1 {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 5px 0;
}

.dc3-title-section h2 {
    font-size: 14px;
    font-weight: bold;
    margin: 0;
}

.dc3-section {
    border: 1px solid black;
    margin-bottom: 15px;
}

.section-title {
    background-color: black;
    color: white;
    font-weight: bold;
    text-align: center;
    padding: 5px;
    font-size: 12px;
}

.field-box {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.field-label {
    font-size: 10px;
    padding: 3px 5px;
    line-height: 1.1;
}

.field-value {
    font-size: 12px;
    padding: 3px 5px 6px 5px;
    min-height: 20px;
    font-family: 'Courier New', Courier, monospace; /* Monospace for inputs looks like typewritten */
    text-transform: uppercase;
}

.flex-row {
    display: flex;
    width: 100%;
}

.half-width {
    width: 50%;
}

.right-border {
    border-right: 1px solid black;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.flex-date { width: 35px; }

.text-center { text-align: center; }
.mt-15 { margin-top: 15px; }

/* Char boxes for CURP and RFC */
.char-boxes-container {
    display: flex;
    padding: 0 5px 5px 5px;
    gap: 2px;
}

.char-box {
    width: 15px;
    height: 20px;
    border: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    text-transform: uppercase;
}

/* Signatures */
.signatures-section {
    padding: 10px;
    border: 1px solid black;
}

.signatures-text {
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 25px; /* Reducido para ahorrar espacio */
}

.signatures-row {
    display: flex;
    justify-content: space-between;
    padding: 0 10px 10px 10px;
}

.sig-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30%;
}

.sig-title {
    font-size: 11px;
    text-align: center;
    margin-bottom: 30px; /* Reducido para ahorrar espacio */
    min-height: 26px;
}

.sig-line {
    width: 100%;
    border-top: 1px solid black;
    margin-bottom: 5px;
}

.sig-name {
    font-size: 10px;
    text-align: center;
    text-transform: uppercase;
}

/* Instructions */
.dc3-instructions {
    margin-top: 10px;
    font-size: 9px;
    line-height: 1.2;
}

.instruction-line {
    margin-bottom: 2px;
}

.dc3-footer {
    font-size: 10px;
    text-align: right;
    position: absolute;
    bottom: 1.5cm;
    right: 1.5cm;
    margin-top: 0;
}

/* Back Page Styles */
.catalog-title {
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
}

.catalog-columns {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.catalog-col {
    width: 48%;
    font-size: 8px;
}

.cat-header {
    display: flex;
    font-weight: bold;
    margin-bottom: 5px;
}

.cat-clave {
    width: 60px;
}

.cat-denom {
    flex: 1;
}

.cat-row {
    display: flex;
    margin-bottom: 2px;
}

/* Print Rules */
@media print {
    body {
        background-color: white;
    }
    .hide-on-print {
        display: none !important;
    }
    .preview-panel {
        padding: 0;
        background-color: white;
        height: auto;
        overflow: visible;
        display: block;
    }
    .dc3-document {
        box-shadow: none;
        padding: 0;
        width: 100%;
        min-height: 100vh;
        margin: 0;
        page-break-after: always;
    }
    .page-break {
        page-break-before: always;
    }
}

/* Auth Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #1e293b;
    padding: 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: #f8fafc;
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-switch a {
    color: #3b82f6;
    text-decoration: none;
    font-size: 0.9rem;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* User Bar & DB Controls */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #334155;
    margin-bottom: 20px;
}

.user-email {
    font-size: 0.85rem;
    color: #94a3b8;
}

.btn-text {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-text:hover {
    color: #f87171;
}

.section-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header-flex h3 {
    margin-bottom: 0;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.db-loader {
    background: rgba(15, 23, 42, 0.3);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #334155;
}

/* Mobile Responsive Styles */
.mobile-toggle-btn {
    display: none;
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }

    .editor-panel {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 80px; /* Space for FAB */
    }

    .preview-panel {
        width: 100%;
        height: auto;
        display: none; /* Hidden by default on mobile */
        padding-bottom: 80px; /* Space for FAB */
        overflow-x: auto;
        padding-left: 10px;
        padding-right: 10px;
    }

    .preview-panel.show-mobile {
        display: flex;
    }

    .editor-panel.hide-mobile {
        display: none;
    }
    
    .dc3-document {
        margin: 0 auto;
    }

    /* Floating Action Button */
    .mobile-toggle-btn {
        display: flex;
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background-color: var(--primary-blue);
        color: white;
        border: none;
        padding: 12px 24px;
        border-radius: 30px;
        font-weight: 600;
        box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
        z-index: 9999;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 1rem;
        cursor: pointer;
    }
}
