/* ============================================================
   1099 Expense Tracker — estilos.css
   mygastosapp.com
   ============================================================ */
:root {
    --primary:         #1e40af;
    --primary-dark:    #1e3a8a;
    --primary-light:   #dbeafe;
    --accent:          #3b82f6;
    --sidebar-bg:      #0f172a;
    --sidebar-text:    #94a3b8;
    --sidebar-hover:   #1e293b;
    --sidebar-active:  #1e40af;
    --success:         #16a34a;
    --success-light:   #dcfce7;
    --danger:          #dc2626;
    --danger-light:    #fee2e2;
    --warning:         #d97706;
    --warning-light:   #fef3c7;
    --bg:              #f1f5f9;
    --card-bg:         #ffffff;
    --border:          rgba(0,0,0,0.07);
    --border-strong:   rgba(0,0,0,0.14);
    --text-primary:    #0f172a;
    --text-secondary:  #64748b;
    --text-muted:      #94a3b8;
    --radius:          10px;
    --sidebar-width:   248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ── LAYOUT ────────────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
}
.sidebar-logo {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.app-name {
    font-size: 14.5px;
    font-weight: 600;
    color: #f1f5f9;
}
.app-sub {
    font-size: 11px;
    color: #475569;
    margin-top: 2px;
}
.sidebar-section {
    padding: 14px 10px 4px;
}
.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #334155;
    padding: 0 8px;
    margin-bottom: 3px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: all 0.12s;
    margin-bottom: 1px;
}
.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover { background: var(--sidebar-hover); color: #cbd5e1; }
.nav-link:hover svg { opacity: 1; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-link.active svg { opacity: 1; }
.sidebar-footer {
    margin-top: auto;
    padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px;
    border-radius: 7px;
    margin-bottom: 4px;
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: #fff; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: #e2e8f0; }
.user-role { font-size: 11px; color: #475569; }
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}

/* ── MAIN CONTENT ──────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 13px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    gap: 12px;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-content { padding: 22px 26px; flex: 1; }
.btn-icon {
    width: 36px; height: 36px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
}
.d-md-none { display: none; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-body { padding: 18px 20px; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }

/* ── METRICS ───────────────────────────────────────────────── */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.metric-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.metric-label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-secondary); margin-bottom: 8px;
}
.metric-value {
    font-size: 24px; font-weight: 700;
    letter-spacing: -0.02em; line-height: 1;
    margin-bottom: 5px;
}
.metric-value.income  { color: var(--success); }
.metric-value.expense { color: var(--danger); }
.metric-value.warning { color: var(--warning); }
.metric-sub { font-size: 11.5px; color: var(--text-muted); }
.metric-icon {
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
}
.metric-icon.blue   { background: var(--primary-light); color: var(--primary); }
.metric-icon.green  { background: var(--success-light); color: var(--success); }
.metric-icon.red    { background: var(--danger-light);  color: var(--danger); }
.metric-icon.amber  { background: var(--warning-light); color: var(--warning); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 15px;
    border-radius: 7px;
    font-size: 13.5px; font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.13s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-primary   { background: var(--primary);  color: #fff;  border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-secondary { background: var(--card-bg);  color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── QUICK ACTIONS ──────────────────────────────────────────── */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

/* ── TABLES ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left; padding: 9px 14px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 500;
}
.badge-income    { background: var(--success-light);  color: #15803d; }
.badge-expense   { background: var(--danger-light);   color: #b91c1c; }
.badge-tax       { background: var(--warning-light);  color: #92400e; }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* ── FORMS ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px; font-weight: 500;
    color: var(--text-primary); margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid #d1d5db; border-radius: 7px;
    font-size: 14px; color: var(--text-primary);
    background: #fff;
    transition: border-color 0.14s, box-shadow 0.14s;
    outline: none;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.13);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── ALERTS ────────────────────────────────────────────────── */
.alert { padding: 11px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error   { background: var(--danger-light);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #166534; border: 1px solid #86efac; }
.alert-info    { background: var(--primary-light); color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: var(--warning-light); color: #78350f; border: 1px solid #fcd34d; }

/* ── LOGIN ──────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, #0f172a 0%, #1e3a8a 100%);
    padding: 24px;
}
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 38px 36px;
    width: 100%; max-width: 370px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
    width: 54px; height: 54px;
    background: var(--primary);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; color: #fff;
    margin: 0 auto 12px;
}
.login-logo h1 { font-size: 19px; font-weight: 700; }
.login-logo p  { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

/* ── GRIDS ──────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── UPLOAD ZONE ────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 36px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: #f8fafc;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--primary-light);
}
.upload-zone input[type=file] { display: none; }
.upload-zone-icon { font-size: 40px; margin-bottom: 10px; }
.upload-zone p { color: var(--text-secondary); font-size: 14px; }
.upload-zone small { color: var(--text-muted); font-size: 12px; }

/* ── RECEIPT PREVIEW ────────────────────────────────────────── */
.receipt-preview {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.receipt-preview img { width: 100%; display: block; }

/* ── PAGINATION ─────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.page-link {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 7px;
    border: 1px solid var(--border);
    font-size: 13px; text-decoration: none; color: var(--text-primary);
    background: var(--card-bg); transition: all 0.12s;
}
.page-link:hover   { background: var(--bg); }
.page-link.active  { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* ── UTILITIES ──────────────────────────────────────────────── */
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--danger)  !important; }
.text-warning   { color: var(--warning) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-right     { text-align: right; }
.text-center    { text-align: center; }
.fw-600         { font-weight: 600; }
.fw-500         { font-weight: 500; }
.fs-12          { font-size: 12px; }
.fs-13          { font-size: 13px; }
.mt-3           { margin-top: 12px; }
.mt-4           { margin-top: 16px; }
.mt-5           { margin-top: 20px; }
.mb-3           { margin-bottom: 12px; }
.mb-4           { margin-bottom: 16px; }
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-2          { gap: 8px; }
.gap-3          { gap: 12px; }
.w-100          { width: 100%; }
hr.divider      { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.empty-state    { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar.open ~ .sidebar-overlay { display: block; }
    .main-content { margin-left: 0; }
    .d-md-none { display: flex; }
    .topbar { padding: 11px 16px; }
    .page-content { padding: 16px; }
}
@media (max-width: 640px) {
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .form-row   { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
    .metrics-grid { grid-template-columns: 1fr; }
}

/* ── SELECT2 OVERRIDES ──────────────────────────────────────── */
.select2-container--classic .select2-selection--single {
    height: 38px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 7px !important;
    display: flex; align-items: center;
}
.select2-container--classic .select2-selection--single .select2-selection__rendered {
    line-height: 38px !important;
    padding-left: 12px !important;
    color: var(--text-primary) !important;
}
.select2-container--classic .select2-selection--single .select2-selection__arrow {
    height: 36px !important;
    border-radius: 0 7px 7px 0 !important;
}
.select2-container--classic.select2-container--focus .select2-selection--single {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.13) !important;
}
