/* ==========================================================================
   Contabilidad General Express - Estilos de Plan de Cuentas (Accounts CSS)
   Aesthetic: Continuous Paper Document Editor (Word/Notion/Outline style)
   ========================================================================== */

/* Company Home View (Imagen 5) */
.company-home-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
}

.company-home-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.company-home-topbar .topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-back-link {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.btn-back-link:hover {
    background-color: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.company-home-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.company-home-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--success-light);
    color: var(--success);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
}

.company-modules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 1100px) {
    .company-modules-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .company-modules-grid {
        grid-template-columns: 1fr;
    }
}

.module-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    text-decoration: none;
    color: inherit;
}

.module-card.active-module {
    cursor: pointer;
}

.module-card.action-module {
    border-left: 5px solid #2563eb; /* Azul Real - Acciones de Gestión */
}

.module-card.action-module:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
    border-color: #2563eb;
}

.module-card.report-module {
    border-left: 5px solid #f59e0b; /* Dorado / Ámbar - Informes */
}

.module-card.report-module:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
}

.font-blue {
    background-color: #eff6ff !important;
    color: #2563eb !important;
}

.font-yellow {
    background-color: #fffbeb !important;
    color: #d97706 !important;
}

.module-card.disabled-module {
    opacity: 0.65;
    cursor: not-allowed;
    background-color: #fafafa;
}

.module-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.module-info h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.module-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.module-badge {
    position: absolute;
    top: 12px;
    right: 14px;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.725rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.module-arrow {
    margin-left: auto;
    font-size: 1.2rem;
    color: var(--text-light);
}

/* Modales de Selección de Plan de Cuentas (Paso 2 y 3) */
.chart-choice-card {
    max-width: 640px;
}

.choice-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.choice-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 10px;
}

.choice-card {
    background-color: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.choice-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.choice-card .yellow-accent {
    background-color: #fef3c7;
    color: #d97706;
}

.choice-card:hover .yellow-accent {
    background-color: #fde68a;
}

.choice-card .blue-accent {
    background-color: var(--primary-light);
    color: var(--primary);
}

.choice-card:hover .blue-accent {
    background-color: #e0e7ff;
}

.choice-card .purple-accent {
    background-color: #f3e8ff;
    color: #7c3aed;
}

.choice-card:hover .purple-accent {
    background-color: #e9d5ff;
}

.choice-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 16px;
}

.choice-card h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.choice-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.justify-center {
    justify-content: center !important;
}

/* Modal Selección de Modelo (Imagen 2 y 3) */
.model-selection-card {
    max-width: 900px;
}

.model-selection-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    max-height: 480px;
    overflow-y: auto;
    padding: 4px;
}

.model-card {
    background-color: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.model-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.model-card.active {
    border-color: #f59e0b; /* Borde Activo Amarillo/Dorado */
    background-color: #fffbeb;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.model-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.model-card-header h4 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.model-card-badge {
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.model-card.active .model-card-badge {
    background-color: #fef3c7;
    color: #b45309;
}

.model-tree-preview {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.8rem;
    font-family: monospace;
    max-height: 140px;
    overflow-y: auto;
    color: var(--text-muted);
}

.model-tree-item {
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.model-tree-code {
    font-weight: 700;
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75rem;
}

.model-tree-item.level-1 { font-weight: 700; color: var(--text-main); }
.model-tree-item.level-2 { padding-left: 12px; }
.model-tree-item.level-3 { padding-left: 24px; }
.model-tree-item.level-4 { padding-left: 36px; }

.model-tree-more {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.75rem;
    margin-top: 6px;
    font-style: italic;
}

/* Modal Vista Previa Completa */
.model-preview-card {
    max-width: 920px !important;
    width: 94% !important;
    max-height: 90vh !important;
}

.preview-tree-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.preview-tree-table th {
    background-color: #f1f5f9;
    color: #475569;
    font-weight: 600;
    text-align: left;
    padding: 10px 16px;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 2;
}

.preview-tree-table td {
    padding: 8px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.preview-tree-table tr:hover {
    background-color: #f8fafc;
}

.preview-row-level-1 {
    background-color: #eff6ff !important;
    font-weight: 700;
    color: #1e3a8a;
}

.preview-row-level-1 td {
    border-top: 1px solid #dbeafe;
    border-bottom: 1px solid #dbeafe;
    padding-top: 10px;
    padding-bottom: 10px;
}

.preview-row-level-2 {
    font-weight: 600;
    color: #1e293b;
    background-color: #fafafa;
}

.preview-row-level-3 {
    font-weight: 500;
    color: #334155;
}

.preview-row-level-4, .preview-row-level-5 {
    color: #475569;
}

.account-code-badge {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #334155;
    display: inline-block;
}

.preview-row-level-1 .account-code-badge {
    background: #2563eb;
    color: #ffffff;
}

.preview-row-level-2 .account-code-badge {
    background: #cbd5e1;
    color: #0f172a;
}

.indent-level-1 { padding-left: 0px; }
.indent-level-2 { padding-left: 18px; }
.indent-level-3 { padding-left: 36px; }
.indent-level-4 { padding-left: 54px; }
.indent-level-5 { padding-left: 72px; }

.level-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    display: inline-block;
}

.level-badge-1 { background: #dbeafe; color: #1e40af; }
.level-badge-2 { background: #e0e7ff; color: #3730a3; }
.level-badge-3 { background: #f3e8ff; color: #6b21a8; }
.level-badge-4 { background: #f1f5f9; color: #475569; }
.level-badge-5 { background: #dcfce7; color: #166534; }

/* ==========================================================================
   Continuous Text-Editor Style Canvas (Word/Notion/Outline)
   ========================================================================== */

.accountschart-editor-wrapper {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
}

.editor-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.editor-topbar .topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.editor-topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.autosave-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.825rem;
    color: var(--text-muted);
    background-color: var(--bg-surface);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.autosave-status i {
    font-size: 0.95rem;
}

/* Keyboard Shortcuts Toolbar */
.keyboard-shortcuts-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-bottom: 24px;
    font-size: 0.825rem;
    color: #92400e;
    flex-wrap: wrap;
}

.shortcuts-title {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
}

.shortcut-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

kbd {
    background-color: #ffffff;
    border: 1px solid #f59e0b;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    color: #78350f;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: monospace;
    font-weight: 700;
}

/* Document Paper Container */
.editor-paper-container {
    display: flex;
    justify-content: center;
}

.editor-paper-sheet {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    width: 100%;
    min-height: 760px;
    padding: 40px 48px;
}

.editor-paper-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 20px;
    margin-bottom: 28px;
    border-bottom: 2px solid #f3f4f6;
}

.editor-paper-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
}

.paper-meta-badge {
    background-color: #f3f4f6;
    color: #4b5563;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

/* Continuous Rows List */
.editor-rows-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Individual Account Row */
.editor-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
    position: relative;
}

.editor-row:hover {
    background-color: #f9fafb;
}

.editor-row.focused {
    background-color: #fffbeb; /* Destacado amarillo suave al enfocar */
}

/* Levels Indentation */
.editor-row.level-0 { margin-left: 0px; }
.editor-row.level-1 { margin-left: 28px; }
.editor-row.level-2 { margin-left: 56px; }
.editor-row.level-3 { margin-left: 84px; }
.editor-row.level-4 { margin-left: 112px; }

/* Icons */
.row-handle {
    color: #d1d5db;
    font-size: 0.85rem;
    cursor: grab;
    opacity: 0.3;
    transition: opacity var(--transition-fast);
}

.editor-row:hover .row-handle {
    opacity: 1;
}

.row-icon {
    font-size: 1rem;
    color: var(--primary);
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-icon.is-parent {
    color: #d97706; /* Color Cálido para Agrupadores */
}

.row-icon.is-locked {
    color: #ef4444; /* Candado rojo si está bloqueado */
}

/* Code Badge Non-Editable */
.code-badge {
    background-color: #f3f4f6;
    color: #374151;
    font-family: monospace;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    user-select: none;
    flex-shrink: 0;
    min-width: 72px;
    text-align: center;
}

.editor-row.level-0 .code-badge {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

/* Borderless Clean Input Field */
.account-input-clean {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--text-main);
    padding: 6px 8px;
    border-radius: 4px;
    transition: all var(--transition-fast);
    outline: none;
    font-family: inherit;
}

.editor-row.level-0 .account-input-clean {
    font-weight: 700;
    font-size: 1.05rem;
    color: #111827;
}

.editor-row.is-mayor-account .account-input-clean {
    font-weight: 700;
    color: #0f172a;
}

.editor-row.is-mayor-account .code-badge {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
    font-weight: 700;
}

.editor-row.is-detail-account .account-input-clean {
    font-weight: 400;
    color: #334155;
}

.account-input-clean:focus {
    background-color: #ffffff;
    box-shadow: inset 0 -2px 0 #f59e0b; /* Línea de enfoque amarillo debajo */
}

.account-input-clean:disabled {
    color: #9ca3af;
    cursor: not-allowed;
}

/* Rango de Acciones Flotantes al Pasar Cursor */
.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.editor-row:hover .row-actions {
    opacity: 1;
}

.btn-row-action {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-row-action:hover {
    background-color: #e5e7eb;
    color: var(--text-main);
}

.btn-row-action.delete-action:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

/* Account Group Badges & Selectors */
.group-select-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-full);
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.group-select-pill select {
    background: transparent;
    border: none;
    outline: none;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    cursor: pointer;
    padding: 0;
}

.group-select-pill.badge-unassigned {
    background-color: #fff1f2;
    color: #e11d48;
    border-color: #fecdd3;
    font-weight: 700;
}

.group-inherited-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #f3f4f6;
    color: #6b7280;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    font-weight: 500;
    user-select: none;
}

/* 🖨️ REGLAS DE IMPRESIÓN DEL PLAN DE CUENTAS (@media print) */
@media print {
    @page {
        size: auto;
        margin: 10mm 12mm 10mm 12mm;
    }

    /* Ocultar elementos de UI no imprimibles */
    .app-header,
    .editor-topbar,
    .keyboard-shortcuts-bar,
    .btn-back-link,
    .topbar-actions,
    .row-handle,
    .row-icon,
    .row-actions,
    .btn-row-action,
    .btn,
    .modal-overlay,
    .app-footer,
    .group-select-pill,
    .group-inherited-badge {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    }

    .accountschart-editor-wrapper {
        padding: 0 !important;
        background: #ffffff !important;
    }

    .editor-paper-container {
        padding: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    .editor-paper-sheet {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        background: transparent !important;
    }

    /* ENCABEZADO OFICIAL IMPRESO HOMOLOGADO */
    .report-header-box {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        border-bottom: 2px solid #000000 !important;
        padding-bottom: 6px !important;
        margin-bottom: 12px !important;
        width: 100% !important;
    }

    .header-company-meta h2 {
        font-size: 15pt !important;
        font-weight: 700 !important;
        color: #000000 !important;
        margin: 0 !important;
    }

    .header-company-meta p {
        font-size: 9.5pt !important;
        font-weight: 600 !important;
        color: #333333 !important;
        margin: 2px 0 0 0 !important;
    }

    .header-title-box h3 {
        font-size: 14pt !important;
        font-weight: 700 !important;
        color: #000000 !important;
        text-align: right !important;
        margin: 0 !important;
    }

    .header-title-box p {
        font-size: 9.5pt !important;
        color: #333333 !important;
        text-align: right !important;
        margin: 2px 0 0 0 !important;
    }

    /* INDENTACIÓN MÁS COMPACTA PARA IMPRESIÓN */
    .editor-row.level-0 { margin-left: 0px !important; }
    .editor-row.level-1 { margin-left: 14px !important; }
    .editor-row.level-2 { margin-left: 28px !important; }
    .editor-row.level-3 { margin-left: 42px !important; }
    .editor-row.level-4 { margin-left: 56px !important; }

    /* FILAS ULTRASANAS Y COMPACTAS SIN RECUADROS */
    .editor-row {
        background: transparent !important;
        border: none !important;
        border-bottom: 1px dotted #e2e8f0 !important;
        padding: 1px 0 !important;
        margin: 0 !important;
        gap: 8px !important;
        box-shadow: none !important;
        min-height: auto !important;
        page-break-inside: avoid;
    }

    /* ELIMINAR RECUADRO DEL CÓDIGO Y ALINEAR A LA IZQUIERDA */
    .code-badge {
        border: none !important;
        background: transparent !important;
        color: #000000 !important;
        font-weight: 700 !important;
        font-size: 9.5pt !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        text-align: left !important;
        min-width: unset !important;
        width: auto !important;
        flex-shrink: 0 !important;
    }

    /* CAMPO DE NOMBRE DE CUENTA EN TEXTO PLANO */
    .account-input-clean {
        border: none !important;
        background: transparent !important;
        color: #000000 !important;
        font-size: 9.5pt !important;
        line-height: 1.2 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }

    .editor-row.is-mayor-account .code-badge,
    .editor-row.is-mayor-account .account-input-clean {
        font-weight: 700 !important;
        color: #000000 !important;
    }
}

