/* --- 1. GLOBAL THEME VARIABLES --- */
:root {
    --primary-color: #059669;       /* Emerald - Credit Union Green */
    --primary-dark: #047857;        /* Darker Emerald for hover */
    --nav-color: #064E3B;           /* Deep Green Navy */
    --bg-color: #F0FDF4;            /* Faint Green-Tinted Background */
    --text-color: #1F2937;          /* Dark Slate Text */
    --muted-color: #6B7280;         /* Grey Text */
    --success-color: #16A34A;       /* Green */
    --danger-color: #DC2626;        /* Red */
    --card-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* --- 2. BASE STYLES --- */
body {
    background:
        radial-gradient(circle at 15% 10%, rgba(124,58,237,0.14), transparent 40%),
        radial-gradient(circle at 85% 25%, rgba(5,150,105,0.16), transparent 45%),
        radial-gradient(circle at 50% 90%, rgba(37,99,235,0.12), transparent 50%),
        #F3F5FA;
    background-attachment: fixed;
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* --- STICKY FOOTER MAGIC --- */
    display: flex;             /* Turn body into a flex container */
    flex-direction: column;    /* Stack children vertically */
    min-height: 100vh;         /* Force body to be at least as tall as the screen */
}

h1, h2, h3, h4, h5, h6 {
    color: var(--nav-color);
    font-weight: 600;
}

/* --- 3. NAVIGATION --- */
.app-navbar {
    padding: 0;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 4px 24px rgba(31,41,55,0.06);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5em;
    color: var(--nav-color) !important;
    padding: 10px 0;
}

/* Square icon mark - sized here so the bar height stays put if the file
   ever changes aspect. */
.navbar-brand img { display: block; width: 44px; height: 44px; }

/* Slim, uppercase, letter-spaced menu type - reads as one connected menu
   (divider between each item) rather than a row of buttons. */
.nav-link {
    color: #374151 !important;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    font-weight: 400;
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 22px 22px !important;
    margin: 0;
    border-radius: 0;
    position: relative;
    transition: color 0.2s ease;
}

.nav-item:not(:last-child) .nav-link {
    border-right: 1px solid rgba(31,41,55,0.1);
}

.nav-alert-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--danger-color);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: normal;
    text-transform: none;
    vertical-align: super;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.nav-link.active {
    color: var(--primary-color) !important;
    font-weight: 600;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: 22px;
    right: 22px;
    bottom: 6px;
    height: 2px;
    background: var(--primary-color);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.2s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
}

/* Icon-only Settings/Logout buttons */
.nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #6b7280;
    font-size: 1.05rem;
    margin-left: 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-icon-btn:hover {
    background-color: rgba(0,0,0,0.05);
    color: var(--nav-color);
}

.nav-icon-btn.active {
    color: var(--primary-color);
    background-color: color-mix(in srgb, var(--primary-color) 12%, transparent);
}

.nav-icon-btn-label {
    font-size: 0.9rem;
    font-weight: 500;
}

@media (max-width: 991.98px) {
    .nav-icon-btn {
        width: auto;
        height: auto;
        border-radius: 8px;
        justify-content: flex-start;
        padding: 8px 14px;
    }
}

/* --- 4. CARDS & CONTAINERS --- */
.card, .report-card, .report-stat-card, .metric-card {
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 20px;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(31,41,55,0.08);
    margin-bottom: 24px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-weight: bold;
    color: var(--nav-color);
    padding: 15px 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 20px 20px 0 0 !important;
}

/* Flat icon stat row - reused on reports.php and dashboard.php */
.report-stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 100%;
}
.report-stat-icon {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2em; flex-shrink: 0; color: #fff;
}
.report-stat-icon.stat-business { background: var(--success-color); }
.report-stat-icon.stat-personal { background: #2563eb; }
.report-stat-icon.stat-net { background: var(--nav-color); }
.report-stat-icon.stat-ignored { background: #9ca3af; }
.report-stat-label { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.5px; color: #9ca3af; font-weight: 700; margin-bottom: 2px; }
.report-stat-value { font-size: 1.4em; font-weight: 700; color: var(--nav-color); }

/* --- 5. BUTTONS --- */
.btn {
    border-radius: 8px;
    font-weight: 600;
    padding: 9px 20px;
    letter-spacing: 0.2px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-lg {
    border-radius: 10px;
    padding: 12px 26px;
}

.btn-sm {
    border-radius: 6px;
    padding: 5px 12px;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--primary-color) 40%, transparent);
}

.btn-outline-secondary {
    border-color: #d1d5db;
    color: #4b5563;
    font-weight: 600;
}

.btn-outline-secondary:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: var(--nav-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.btn-outline-primary {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 6%, white);
}

.btn-outline-primary:hover, .btn-outline-primary:active, .btn-outline-primary:focus {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--primary-color) 35%, transparent);
}

/* Pill-shaped action buttons (Connect Bank / Refresh / Sync) */
.btn-pill {
    border-radius: 999px !important;
    padding: 9px 20px;
}

.btn-pill:hover {
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #eef0f2;
    border-color: #eef0f2;
    color: #4b5563;
}

.btn-secondary:hover, .btn-secondary:active, .btn-secondary:focus {
    background-color: #e2e5e9 !important;
    border-color: #e2e5e9 !important;
    color: var(--nav-color) !important;
}

/* --- 6. DASHBOARD WIDGETS --- */
.dash-widget {
    display: flex;
    align-items: center;
    padding: 24px;
}

.widget-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-right: 20px;
    flex-shrink: 0;
}

/* Widget Variants */
.widget-icon.income { background-color: rgba(39, 174, 96, 0.1); color: var(--success-color); }
.widget-icon.expense { background-color: rgba(231, 76, 60, 0.1); color: var(--danger-color); }
.widget-icon.balance { background-color: rgba(26, 188, 156, 0.1); color: var(--primary-color); }

.widget-content .label {
    font-size: 0.85rem;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 4px;
}

.widget-content .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--nav-color);
    line-height: 1;
}

/* --- 7. TRANSACTION TABLES & DATA --- */
.filter-bar {
    background: #fff;
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.table-hover tbody tr:hover {
    background-color: rgba(26, 188, 156, 0.05); /* Light teal hover */
}

.transaction-amount {
    font-weight: 600;
    font-family: 'Consolas', monospace;
}

.transaction-name {
    cursor: pointer;
    border-bottom: 1px dashed #ccc;
    font-weight: 600;
}
.transaction-name:hover {
    color: var(--primary-color); /* Updated to match theme */
    border-bottom-color: var(--primary-color);
}

/* Badges & Pills */
.cat-badge {
    font-size: 0.75em;
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    color: #777;
    text-transform: uppercase;
}

.tag-chip {
    color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.tag-chip-name {
    font-weight: 600;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.tag-chip i {
    color: #fff;
    opacity: 0.85;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.tag-chip i:hover {
    opacity: 1;
}

.tag-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    margin-right: 4px;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    font-weight: 600;
}

.add-tag-btn { cursor: pointer; color: #bdc3c7; font-size: 0.9em; }
.add-tag-btn:hover { color: var(--nav-color); }

/* --- 8. UTILITIES --- */
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }

.color-option {
    width: 25px; height: 25px;
    border-radius: 50%;
    display: inline-block;
    cursor: pointer;
    border: 2px solid transparent;
    margin-right: 5px;
}
.color-option.selected {
    border-color: #333;
    transform: scale(1.1);
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
}

/* --- 9. FOOTER --- */
.main-footer {
    margin-top: auto; /* This pushes the footer to the bottom of the flex container */
    background-color: var(--nav-color);
    padding: 48px 0 20px;
    color: rgba(255,255,255,0.65);
    font-size: 0.9em;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.footer-brand img {
    border-radius: 6px;
}

.footer-brand span {
    font-weight: 700;
    font-size: 1.1em;
    color: #fff;
}

.footer-blurb {
    max-width: 340px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.footer-trust {
    font-size: 0.85em;
    color: rgba(255,255,255,0.5);
}

.footer-trust i {
    color: var(--success-color);
    margin-right: 4px;
}

.footer-heading {
    color: #fff;
    font-weight: 700;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links li {
    margin-bottom: 10px;
}

.main-footer a {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    transition: color 0.2s;
}

.main-footer a:hover {
    color: #fff;
    text-decoration: underline;
}

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 0.85em;
    color: rgba(255,255,255,0.45);
}

/* --- 10. PRINT STYLES --- */
@media print {
    body { background-color: #fff !important; }
    .navbar, .filter-bar, footer, .no-print, .btn { display: none !important; }
    .container { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }

    /* Ensure colors print correctly - a light tint + colored text rather
       than the screen's solid fill, to keep printed reports ink-light. */
    .r-header-business { background-color: #ecfdf5 !important; color: #047857 !important; -webkit-print-color-adjust: exact; }
    .r-header-personal { background-color: #ebf5fb !important; color: #2563eb !important; -webkit-print-color-adjust: exact; }
}

/* --- 11. DASHBOARD LISTS (Recent Activity) --- */
.transaction-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.transaction-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f9f9f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item .text-muted {
    font-size: 0.85em;
    display: block;
    margin-top: 2px;
}

.amount {
    font-weight: 600;
    font-family: 'Consolas', monospace;
    text-align: right;
}

.total-row {
    background: #f9f9f9;
    padding: 15px 20px;
    font-weight: bold;
    text-align: right;
    border-top: 1px solid #eee;
    font-size: 1.1em;
}

.month-title, .page-heading {
    color: var(--muted-color);
    margin-bottom: 15px;
    font-weight: 400;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.page-heading-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

.page-heading-row .page-heading {
    margin-bottom: 0;
}

.page-heading-info {
    color: #9ca3af;
    cursor: help;
    font-size: 0.85em;
}

/* --- 12. DISMISSABLE TUTORIAL CARDS (reused on transactions.php / analyze.php) --- */
.tutorial-card {
    position: relative;
    background: color-mix(in srgb, var(--primary-color) 8%, rgba(255,255,255,0.6));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid color-mix(in srgb, var(--primary-color) 20%, white);
    border-radius: 20px;
    padding: 20px 24px;
}

.tutorial-close {
    position: absolute;
    top: 16px;
    right: 16px;
}

.tutorial-heading {
    font-weight: 700;
    color: var(--nav-color);
    margin-bottom: 4px;
}

.tutorial-heading i {
    color: var(--primary-color);
    margin-right: 6px;
}

.tutorial-lead {
    color: #5b6b66;
    margin-bottom: 16px;
    max-width: 720px;
}

.tutorial-example {
    background: #fff;
    border-radius: 10px;
    padding: 14px;
    height: 100%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.tutorial-example-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary-color) 14%, white);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    margin-bottom: 8px;
}

.tutorial-example-raw {
    font-family: 'Consolas', monospace;
    font-size: 0.78em;
    color: #8a8f98;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tutorial-example-arrow {
    color: #c0c5cc;
    font-size: 0.75em;
    margin: 4px 0;
}

.tutorial-example-clean {
    font-weight: 700;
    color: var(--nav-color);
    margin-bottom: 6px;
}

.tutorial-example-desc {
    font-size: 0.85em;
    color: #6b7280;
}

/* --- 13. ADMIN SECTION NAV (admin/ads.php, admin/banks.php, admin/users.php) --- */
.admin-menu {
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 4px 24px rgba(31,41,55,0.06);
    padding: 14px 0;
    margin-bottom: 32px;
}

.admin-menu-brand {
    font-weight: 700;
    color: var(--nav-color);
    letter-spacing: 0.3px;
}

.admin-menu-links {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.admin-menu-link {
    padding: 8px 14px;
    border-radius: 8px;
    color: #4b5563;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.admin-menu-link:hover {
    background-color: rgba(0,0,0,0.04);
    color: var(--nav-color);
}

.admin-menu-link.active {
    color: var(--primary-color);
    font-weight: 600;
    background-color: color-mix(in srgb, var(--primary-color) 12%, transparent);
}

/* --- 14. APP ALERTS (flat, replaces bootstrap's loud .alert-warning/.alert-danger) --- */
.app-alert {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    border-radius: 16px;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: 0 4px 16px rgba(31,41,55,0.05);
}

.app-alert-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.05em;
}

.app-alert-warning .app-alert-icon { background: color-mix(in srgb, #D97706 15%, white); color: #D97706; }
.app-alert-danger .app-alert-icon { background: color-mix(in srgb, var(--danger-color) 12%, white); color: var(--danger-color); }
.app-alert-info .app-alert-icon { background: color-mix(in srgb, var(--primary-color) 15%, white); color: var(--primary-color); }

.app-alert-text {
    flex: 1;
    color: #4b5563;
    font-size: 0.92em;
    line-height: 1.5;
}

.app-alert-text strong {
    color: var(--nav-color);
}

/* --- 14. ICON LINKS: never underline (icons are self-evidently clickable) --- */
.nav-icon-btn,
.account-badge,
.tutorial-close,
.add-tag-btn,
a:has(> i:only-child),
a:has(> i:first-child:last-child) {
    text-decoration: none !important;
}
