/* =============================================
   D'Eats Yola - Financial Transaction Manager
   Mobile-First, Minimalist CSS
   ============================================= */

/* ===== CSS Variables ===== */
:root {
    --primary: #e67e22;
    --primary-dark: #d35400;
    --primary-light: #fdebd0;
    --success: #27ae60;
    --success-light: #d5f5e3;
    --danger: #e74c3c;
    --danger-light: #fadbd8;
    --warning: #f39c12;
    --warning-light: #fef9e7;
    --info: #3498db;
    --info-light: #d6eaf8;

    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-muted: #bdc3c7;
    --border: #ecf0f1;
    --border-dark: #dfe6e9;

    --sidebar-width: 240px;
    --header-height: 56px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== LOGIN SCREEN ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e67e22 0%, #d35400 50%, #e74c3c 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; color: var(--text); margin-bottom: 4px; }
.login-subtitle { color: var(--text-light); margin-bottom: 28px; font-size: 13px; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: white;
    transition: border-color var(--transition);
    font-family: inherit;
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { resize: vertical; min-height: 60px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-sm {
    padding: 6px 10px;
    font-size: 13px;
    border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text);
}

.input-sm:focus { outline: none; border-color: var(--primary); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border-dark);
}

.btn:hover { border-color: var(--primary); color: var(--primary); }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: white; }

.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #219a52; }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #c0392b; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-full { width: 100%; padding: 12px; font-size: 15px; }

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.btn-icon:hover { background: var(--primary-dark); }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== ERROR & ALERTS ===== */
.error-msg {
    background: var(--danger-light);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
}

.hidden { display: none !important; }

/* ===== APP LAYOUT ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== MOBILE HEADER ===== */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.mobile-title { font-size: 16px; color: var(--primary); font-weight: 700; }

.menu-toggle {
    width: 32px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
}
.menu-toggle span {
    display: block;
    width: 100%;
    height: 2.5px;
    background: var(--text);
    border-radius: 2px;
    transition: var(--transition);
}

.header-actions { display: flex; gap: 8px; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    left: -260px;
    top: 0;
    z-index: 200;
    overflow-y: auto;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open { left: 0; }

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sidebar.open ~ .sidebar-overlay {
    opacity: 1;
    pointer-events: all;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 36px; }
.sidebar-header h2 { font-size: 18px; color: var(--primary); margin-top: 4px; }
.sidebar-version { font-size: 11px; color: var(--text-muted); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-light); text-transform: capitalize; }

.nav-menu {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-icon { font-size: 16px; width: 24px; text-align: center; flex-shrink: 0; }

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 16px;
}

.nav-logout:hover { color: var(--danger) !important; background: var(--danger-light) !important; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 72px 16px 20px;
    min-height: 100vh;
    width: 100%;
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h2 { font-size: 20px; color: var(--text); }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--border);
}

.stat-income { border-left-color: var(--success); }
.stat-expense { border-left-color: var(--danger); }
.stat-profit { border-left-color: var(--primary); }
.stat-cash { border-left-color: var(--info); }

.stat-icon { font-size: 28px; flex-shrink: 0; }
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== TODAY BAR ===== */
.today-bar {
    background: white;
    border-radius: var(--radius);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    font-size: 13px;
}

.today-label { font-weight: 600; color: var(--text); }
.today-divider { color: var(--text-muted); }

/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 14px; }

.settings-card { padding: 20px; }

/* ===== CHARTS ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.chart-card h3 { font-size: 14px; margin-bottom: 12px; color: var(--text); }
.chart-card canvas { max-height: 300px; }

/* ===== TABLES ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:hover { background: #fafbfc; }

.table .empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-debit { background: var(--danger-light); color: var(--danger); }
.badge-credit { background: var(--success-light); color: var(--success); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: #eee; color: #999; }
.badge-void { background: #eee; color: #999; text-decoration: line-through; }
.badge-admin { background: var(--primary-light); color: var(--primary); }
.badge-manager { background: var(--info-light); color: var(--info); }
.badge-staff { background: var(--warning-light); color: var(--warning); }

.badge-asset { background: var(--info-light); color: var(--info); }
.badge-liability { background: var(--danger-light); color: var(--danger); }
.badge-equity { background: #e8daef; color: #8e44ad; }
.badge-revenue { background: var(--success-light); color: var(--success); }
.badge-expense { background: var(--warning-light); color: var(--warning); }

.amount-debit { color: var(--danger); font-weight: 600; }
.amount-credit { color: var(--success); font-weight: 600; }

/* ===== FILTERS BAR ===== */
.filters-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--border-dark);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--text);
}

.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: var(--text-light); padding: 0 8px; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    margin-top: 40px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; }

.modal-close {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 20px; }
.modal-body .form-group:last-child { margin-bottom: 0; }
.modal-body .btn-primary { margin-top: 8px; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 320px;
    word-wrap: break-word;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* ===== ACCOUNT BALANCES REPORT ===== */
.balance-group { margin-bottom: 16px; }
.balance-group-header {
    padding: 8px 16px;
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
    text-transform: capitalize;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}
.balance-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.balance-item-name { color: var(--text); }
.balance-item-amount { font-weight: 600; font-family: 'Courier New', monospace; }
.balance-total {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 14px;
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* ===== RESPONSIVE: Tablet ===== */
@media (min-width: 768px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .charts-grid { grid-template-columns: 1fr 1fr; }
    .charts-grid .full-width { grid-column: 1 / -1; }
    .stat-value { font-size: 22px; }
    .main-content { padding: 72px 24px 24px; }
}

/* ===== RESPONSIVE: Desktop ===== */
@media (min-width: 1024px) {
    .mobile-header { display: none; }
    
    .sidebar {
        left: 0;
        position: fixed;
        box-shadow: none;
    }
    
    .sidebar-overlay { display: none !important; }
    
    .main-content {
        margin-left: var(--sidebar-width);
        padding: 24px 32px;
    }

    .modal {
        margin-top: 80px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .mobile-header, .sidebar, .sidebar-overlay, .toast-container,
    .modal-overlay, .filters-bar, .page-actions, .btn, button { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .page { display: block !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ===== LOADING SPINNER ===== */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Action buttons in tables */
.action-btns { display: flex; gap: 4px; }
.action-btns .btn { padding: 4px 8px; font-size: 11px; }
