/* -------------------------------------------------------------------------- */
/* KUBERA 2.0 — DESIGN SYSTEM & GLASSMORPHIC STYLES                           */
/* -------------------------------------------------------------------------- */

:root {
    /* Colors */
    --bg-dark: #0A0A0A;
    --bg-sidebar: #111111;
    --bg-surface: #1A1A1A;
    --bg-surface-elevated: #222222;
    --glass-bg: #1A1A1A;
    --glass-border: #2C2C2C;

    --text-primary: #FFFFFF;
    --text-secondary: #888888;
    --text-muted: #888888;

    /* Accents */
    --gold-primary: #C9A84C;
    --gold-light: #FFB04A;
    --gold-glow: rgba(201, 168, 76, 0.15);

    --emerald-primary: #4CAF50;
    --emerald-glow: rgba(76, 175, 80, 0.15);

    --ruby-primary: #E05252;
    --ruby-glow: rgba(224, 82, 82, 0.15);

    --blue-primary: #5BA4FF;
    --blue-glow: rgba(91, 164, 255, 0.15);

    --purple-primary: #8B5CF6;
    --purple-glow: rgba(139, 92, 246, 0.15);

    /* Fonts & Radii */
    --font-family: system-ui, -apple-system, sans-serif;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 12px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout Shell */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Left Sidebar Navigation Bar */
.sidebar-nav {
    width: 220px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main Content Area */
.main-content {
    margin-left: 220px;
    flex: 1;
    min-width: 0; /* Fix flex child expanding past viewport */
    padding: 2rem;
    max-width: 1400px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed State */
.sidebar-nav.collapsed {
    width: 76px;
}

.main-content.collapsed {
    margin-left: 76px;
}

.sidebar-nav.collapsed .brand-text,
.sidebar-nav.collapsed .brand-tag,
.sidebar-nav.collapsed .nav-text,
.sidebar-nav.collapsed .user-info {
    display: none;
}

.sidebar-nav.collapsed .sidebar-header {
    padding: 1.25rem 0.5rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
}

.sidebar-nav.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.sidebar-nav.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
    justify-content: center;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: var(--transition);
    margin-left: auto;
}

.sidebar-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.18);
}

.sidebar-nav.collapsed .sidebar-toggle-btn {
    margin-left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
}

.brand-logo {
    font-size: 1.75rem;
    background: var(--gold-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #FFFFFF;
}

.brand-tag {
    font-size: 0.7rem;
    background: var(--gold-glow);
    color: var(--gold-primary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    margin-left: 4px;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.925rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: #FFFFFF;
    background: rgba(91, 164, 255, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.15rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold-primary);
    color: #000;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.logout-btn:hover {
    color: var(--ruby-primary);
    background: var(--ruby-glow);
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header Component */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Cards & Layout Grids */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.card-hero {
    background: var(--bg-surface-elevated);
    border: 1px solid rgba(234, 179, 8, 0.3);
    box-shadow: 0 10px 25px -5px var(--gold-glow);
}

.card-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.card-value-gold {
    display: inline-block;
    color: #FFFFFF;
}

.card-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Progress Bars */
.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.75rem;
}

.progress-bar-fill {
    height: 100%;
    background: var(--blue-primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}

/* Tables */
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    overflow-y: auto;
    max-height: 65vh;
    margin-bottom: 1.75rem;
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--accent-gold) var(--bg-deep);
}

.table-container::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg-deep);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--accent-gold);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--accent-emerald);
}

.table-container table {
    min-width: 980px;
}

.table-header-box {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 1.05rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

.amount-positive {
    color: var(--emerald-primary);
    font-weight: 600;
}

.amount-negative {
    color: var(--ruby-primary);
    font-weight: 600;
}

/* Action Button Visibility */
.action-write-btn {
    display: inline-flex !important;
}

/* Floating Action Button (FAB) */
.fab-btn {
    position: fixed;
    bottom: 2rem;
    right: 2.25rem;
    z-index: 500;
    background: var(--gold-primary);
    color: #FFFFFF;
    border: none;
    border-radius: 50px;
    padding: 0.85rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(234, 179, 8, 0.4);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.fab-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 15px 30px rgba(234, 179, 8, 0.6);
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: var(--gold-primary);
    color: #FFFFFF;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px var(--gold-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: var(--ruby-primary);
    color: #FFFFFF;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.775rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 2px var(--blue-glow);
}

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

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

/* Login Fullscreen */
.login-screen {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

/* Tree View */
.tree-node {
    margin-left: 1.25rem;
    border-left: 1px solid var(--glass-border);
    padding-left: 0.85rem;
    margin-top: 0.5rem;
}

/* Ledger Inline Editing */
.dirty-row {
    background: rgba(234, 179, 8, 0.05); /* very light gold tint */
}
.inline-edit {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    padding: 0.15rem 0.25rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.inline-edit:hover, .inline-edit:focus {
    background: var(--bg-surface-elevated);
    border-color: var(--glass-border);
    outline: none;
}
