/* ═══════════════════════════════════════════════════════════
   ACCOUNTING MODULE — Tree, Tabs, Modals, JE Lines
   ═══════════════════════════════════════════════════════════ */

/* ─── Tab Bar ──────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px;
    overflow-x: auto;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: inherit;
}

.tab-btn .material-symbols-outlined { font-size: 18px; }

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124,141,255,0.3);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeInUp 0.3s ease; }

/* ─── Tree Legend ──────────────────────────────────────── */
.tree-legend {
    display: flex;
    gap: 18px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.type-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.type-dot.type-assets, .type-1 > .tree-node-header .tree-code { color: #3b82f6; }
.type-dot.type-assets { background: #3b82f6; }
.type-dot.type-liabilities, .type-2 > .tree-node-header .tree-code { color: #f59e0b; }
.type-dot.type-liabilities { background: #f59e0b; }
.type-dot.type-expenses, .type-3 > .tree-node-header .tree-code { color: #ef4444; }
.type-dot.type-expenses { background: #ef4444; }
.type-dot.type-revenues, .type-4 > .tree-node-header .tree-code { color: #22c55e; }
.type-dot.type-revenues { background: #22c55e; }

/* ─── Account Tree ─────────────────────────────────────── */
.account-tree {
    user-select: none;
}

.tree-node {
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
}

.tree-node.type-1 { border-left-color: rgba(59,130,246,0.2); }
.tree-node.type-2 { border-left-color: rgba(245,158,11,0.2); }
.tree-node.type-3 { border-left-color: rgba(239,68,68,0.2); }
.tree-node.type-4 { border-left-color: rgba(34,197,94,0.2); }

.tree-node[data-depth="0"] {
    border-left-width: 3px;
    margin-bottom: 4px;
}

.tree-node-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 8px;
    min-height: 42px;
}

.tree-node-header:hover {
    background: var(--bg-hover);
}

.tree-node-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.tree-toggle {
    font-size: 18px !important;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.tree-children.expanded > .tree-node > .tree-node-header > .tree-node-left > .tree-toggle {
    transform: rotate(0);
}

.tree-leaf-icon {
    font-size: 8px !important;
    color: var(--text-muted);
    opacity: 0.5;
    flex-shrink: 0;
}

.tree-code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    flex-shrink: 0;
}

.tree-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.tree-badge.master {
    background: rgba(124,141,255,0.12);
    color: var(--accent-primary);
}

.tree-badge.detail {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.tree-node-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.tree-balance {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

.tree-balance.positive { color: var(--success); }
.tree-balance.negative { color: var(--danger); }

.tree-type-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 55px;
    text-align: center;
}

.tree-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.tree-node-header:hover .tree-actions {
    opacity: 1;
}

.tree-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.tree-action-btn .material-symbols-outlined { font-size: 16px; }

.tree-action-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.tree-action-btn.danger:hover {
    color: var(--danger);
    background: rgba(239,68,68,0.1);
}

.tree-action-btn.add:hover {
    color: var(--success);
    background: rgba(34,197,94,0.1);
}

.tree-lock {
    color: var(--text-muted);
    opacity: 0.3;
}

.tree-lock .material-symbols-outlined { font-size: 14px; }

/* Tree Children */
.tree-children {
    display: none;
    padding-left: 4px;
}

.tree-children.expanded {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Modal ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease;
    box-shadow: 0 24px 48px rgba(0,0,0,0.3);
}

.modal-lg { max-width: 840px; }

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
}

.modal-header h3 .material-symbols-outlined {
    color: var(--accent-primary);
    font-size: 22px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--danger);
    color: #fff;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ─── Form Elements ────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: span 2; }

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.req { color: var(--danger); }

.form-input {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124,141,255,0.12);
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-sm .material-symbols-outlined { font-size: 16px; }
.btn .material-symbols-outlined { font-size: 18px; }

.btn-primary {
    background: var(--accent-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(124,141,255,0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-actions-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ─── JE Lines Section ─────────────────────────────────── */
.je-lines-section {
    margin-top: 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.je-lines-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.je-lines-header h4 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.je-lines-header h4 .material-symbols-outlined {
    font-size: 18px;
    color: var(--accent-primary);
}

.je-lines-table .form-input {
    padding: 6px 8px;
    font-size: 0.8rem;
    min-width: 70px;
}

.je-lines-table select.form-input {
    min-width: 160px;
}

.je-totals-row {
    background: var(--bg-tertiary);
    border-top: 2px solid var(--border-color);
}

.je-lines-expand .inner-table {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin: 8px;
}

.je-lines-expand .inner-table th {
    background: rgba(124,141,255,0.06);
}

/* ─── Table Actions ────────────────────────────────────── */
.table-actions {
    display: flex;
    gap: 2px;
}

/* ─── Toast Notifications ──────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast .material-symbols-outlined { font-size: 20px; }

.toast-success { background: linear-gradient(135deg, #059669, #047857); }
.toast-error { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.toast-info { background: linear-gradient(135deg, #2563eb, #1d4ed8); }

/* ─── Loading Spinner ──────────────────────────────────── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ─── Settings Grid (sidebar + panel layout) ──────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    min-height: 60vh;
}
.settings-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: fit-content;
    position: sticky;
    top: 80px;
}
.settings-menu-header {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}
.settings-menu-header .material-symbols-outlined { font-size: 22px; color: var(--accent-primary); }
.settings-menu-header h3 { font-size: 0.95rem; font-weight: 700; }
.settings-menu-list { list-style: none; padding: 6px; margin: 0; }
.settings-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: var(--radius-md);
    cursor: pointer; transition: all var(--transition-fast);
    color: var(--text-secondary); font-size: 0.85rem; font-weight: 500;
}
.settings-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.settings-menu-item.active { background: rgba(124,141,255,0.1); color: var(--accent-primary); font-weight: 600; }
.settings-menu-item .material-symbols-outlined { font-size: 20px; width: 24px; text-align: center; }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeInUp 0.3s ease; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.panel-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-title .material-symbols-outlined { font-size: 22px; color: var(--accent-primary); }

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .tree-node-right { display: none; }
    .tree-node-header:hover .tree-node-right { display: flex; flex-wrap: wrap; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: span 1; }
    .modal { width: 96%; }
    .header-actions-row { flex-wrap: wrap; }
}

