/* =====================================================================
   theme.css — SINGLE source of truth for the whole app.
   Corporate colors live here as CSS variables. Change them once and the
   entire system updates.
   ===================================================================== */

:root {
    /* ---- Corporate brand colors ---- */
    --brand-green: #4DB049;   /* Color 1 — PRIMARY  */
    --brand-blue:  #4ABED5;   /* Color 2 — ACCENT   */

    /* Derived brand tokens */
    --primary:       var(--brand-green);
    --primary-dark:  #3f9a3c;   /* darker green (hover/active)  */
    --primary-tint:  #e9f6e9;   /* pale green (backgrounds)     */
    --accent:        var(--brand-blue);
    --accent-dark:   #35a7bd;
    --accent-tint:   #e6f7fb;

    /* Brand gradient (green -> blue) */
    --brand-gradient: linear-gradient(135deg, var(--brand-green), var(--brand-blue));

    /* Neutrals */
    --bg:        #f0f4f8;
    --surface:   #ffffff;
    --border:    #e2e8f0;
    --text:      #1e293b;
    --text-soft: #64748b;

    /* Sidebar */
    --sidebar-bg:    #0f2f2b;   /* deep teal-green to tie into brand */
    --sidebar-text:  #cbe8d9;

    /* Status colors */
    --success: #16a34a;
    --danger:  #dc2626;
    --warning: #f59e0b;
    --info:    var(--accent);

    --radius: 12px;
    --shadow: 0 4px 20px rgba(15, 47, 43, 0.08);
    --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* Amharic script font */
body.lang-am,
body.lang-am input,
body.lang-am select,
body.lang-am textarea,
body.lang-am button {
    font-family: 'Noto Sans Ethiopic', 'Inter', 'Segoe UI', sans-serif;
}

a { color: var(--accent-dark); text-decoration: none; }

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

.content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    transition: margin-left .25s;
}
.app.collapsed .content { margin-left: 72px; }

/* ===================== Sidebar ===================== */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 100;
    transition: width .25s;
}
.app.collapsed .sidebar { width: 72px; }

.sidebar-brand {
    padding: 22px 20px;
    background: var(--brand-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .logo {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,.2);
    display: grid; place-items: center;
    font-weight: 800; font-size: 18px;
    flex-shrink: 0;
}
.sidebar-brand .brand-text h1 { margin: 0; font-size: 18px; }
.sidebar-brand .brand-text p  { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.app.collapsed .sidebar-brand .brand-text { display: none; }

.sidebar-menu { list-style: none; margin: 12px 0; padding: 0; }
.sidebar-menu li a {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 20px;
    color: var(--sidebar-text);
    white-space: nowrap;
    border-left: 3px solid transparent;
    transition: background .2s, border-color .2s;
}
.sidebar-menu li a i { width: 22px; text-align: center; font-size: 16px; }
.sidebar-menu li a:hover { background: rgba(74,190,213,.15); }
.sidebar-menu li a.active {
    background: rgba(77,176,73,.18);
    border-left-color: var(--primary);
    color: #fff;
}
.app.collapsed .sidebar-menu li a span { display: none; }

/* ===================== Topbar ===================== */
.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 50;
}
.menu-toggle {
    background: none; border: none; cursor: pointer;
    font-size: 20px; color: var(--text-soft);
}
.topbar-title { font-weight: 600; font-size: 18px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }

.lang-switch {
    display: inline-flex; border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
}
.lang-switch a {
    padding: 6px 12px; font-size: 13px; font-weight: 600;
    color: var(--text-soft); background: #fff;
}
.lang-switch a.active { background: var(--brand-gradient); color: #fff; }

.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.user-chip i { font-size: 22px; color: var(--primary); }

/* ===================== Main ===================== */
.main { padding: 28px 24px; }
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 22px; }

/* ===================== Cards ===================== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 22px;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 18px; margin-bottom: 24px;
}
.stat {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex; align-items: center; gap: 16px;
    border-left: 4px solid var(--primary);
}
.stat .icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--primary-tint); color: var(--primary);
    font-size: 20px; flex-shrink: 0;
}
.stat.accent { border-left-color: var(--accent); }
.stat.accent .icon { background: var(--accent-tint); color: var(--accent-dark); }
.stat.warn { border-left-color: var(--warning); }
.stat.warn .icon { background: #fef3c7; color: #b45309; }
.stat .value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat .label { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

/* ===================== Tables ===================== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; }
table.data thead th {
    background: #f8fafc; color: var(--text-soft);
    font-weight: 600; border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:hover { background: #f8fafc; }

/* ===================== Badges ===================== */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
}
.badge-green  { background: var(--primary-tint); color: var(--primary-dark); }
.badge-blue   { background: var(--accent-tint);  color: var(--accent-dark); }
.badge-gray   { background: #f1f5f9; color: var(--text-soft); }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-amber  { background: #fef3c7; color: #b45309; }

/* ===================== Buttons ===================== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px; border: none; border-radius: 9px;
    font-weight: 600; font-size: 14px; cursor: pointer;
    text-decoration: none; transition: filter .2s, background .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-light   { background: #f1f5f9; color: var(--text); }
.btn-light:hover { background: #e2e8f0; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ===================== Forms ===================== */
.form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.form-group { display: flex; flex-direction: column; margin-bottom: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-weight: 600; font-size: 13px; margin-bottom: 7px; color: #374151; }
.form-group input,
.form-group select,
.form-group textarea {
    padding: 11px 12px; border: 1px solid #d1d5db;
    border-radius: 8px; font-size: 14px; outline: none;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(77,176,73,.15);
}
.form-group input[readonly] { background: #f3f4f6; }
.form-actions { margin-top: 20px; display: flex; gap: 12px; }

/* ===================== Ethiopian date picker ===================== */
.ethdp { position: relative; }
.ethdp-input {
    width: 100%; padding: 11px 12px; border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 14px; background: #fff; cursor: pointer; font-family: inherit;
}
.ethdp-input:focus { border-color: var(--primary); outline: none; }
.ethdp-pop {
    position: absolute; z-index: 200; top: calc(100% + 6px); left: 0;
    width: 280px; background: #fff; border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 30px rgba(15,47,43,.18); padding: 12px;
}
.ethdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ethdp-my { font-weight: 700; color: var(--primary-dark); }
.ethdp-nav {
    border: none; background: var(--primary-tint); color: var(--primary-dark);
    width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.ethdp-nav:hover { background: var(--primary); color: #fff; }
.ethdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.ethdp-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-soft); padding: 4px 0; }
.ethdp-day {
    border: none; background: #f8fafc; border-radius: 7px; padding: 7px 0; cursor: pointer;
    font-size: 13px; color: var(--text); font-family: inherit;
}
.ethdp-day:hover { background: var(--accent-tint); color: var(--accent-dark); }
.ethdp-day.sel { background: var(--primary); color: #fff; font-weight: 700; }
.ethdp-foot { display: flex; justify-content: space-between; margin-top: 10px; }
.ethdp-foot button { border: none; background: none; color: var(--accent-dark); font-weight: 600; cursor: pointer; font-size: 13px; }

/* ===================== Flash ===================== */
.flash {
    padding: 13px 18px; border-radius: 9px; margin-bottom: 18px;
    font-weight: 500; border: 1px solid transparent;
}
.flash-success { background: var(--primary-tint); color: var(--primary-dark); border-color: #bfe6bd; }
.flash-error   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.flash-info    { background: var(--accent-tint); color: var(--accent-dark); border-color: #bde9f2; }

/* ===================== Auth (login) ===================== */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center;
    background: var(--brand-gradient); padding: 20px;
}
.auth-card {
    background: #fff; width: 100%; max-width: 400px;
    border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 38px 34px;
}
.auth-logo {
    width: 64px; height: 64px; margin: 0 auto 16px;
    border-radius: 16px; background: var(--brand-gradient);
    display: grid; place-items: center; color: #fff;
    font-size: 26px; font-weight: 800;
}
.auth-logo.has-img { width: 84px; height: 84px; background: #fff; padding: 4px; }
.auth-logo.has-img img { width: 100%; height: 100%; object-fit: contain; }
.auth-card h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { text-align: center; color: var(--text-soft); margin: 0 0 24px; font-size: 14px; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 13px; }
.auth-lang { text-align: center; margin-top: 18px; }
.auth-lang a { margin: 0 6px; font-weight: 600; color: var(--text-soft); }
.auth-lang a.active { color: var(--primary-dark); }

/* ===================== Responsive ===================== */
@media (max-width: 860px) {
    .content { margin-left: 0; }
    .sidebar { left: -100%; }
    .app.mobile-open .sidebar { left: 0; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ===================== Brand logo in sidebar ===================== */
.sidebar-brand .logo.brand-img { background: #fff; padding: 3px; }
.sidebar-brand .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ===================== Print / PDF ===================== */
@page { size: A4; margin: 14mm; }

/* Print-only ECCSA letterhead — hidden on screen, shown when printing. */
.print-letterhead { display: none; }

@media print {
    html, body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    /* Hide the app chrome so only the document content prints. */
    .sidebar, .topbar, .menu-toggle, .no-print, .flash { display: none !important; }
    .app { display: block !important; }
    .content { margin-left: 0 !important; }
    .main { padding: 0 !important; }

    /* Clean cards for paper; keep each card from splitting across pages. */
    .card { box-shadow: none !important; border: 1px solid #dfe6ee !important;
            break-inside: avoid; page-break-inside: avoid; margin-bottom: 14px; }
    a { color: inherit !important; text-decoration: none !important; }

    .print-letterhead {
        display: flex !important; align-items: center; gap: 16px;
        border-bottom: 3px solid var(--primary); padding-bottom: 14px; margin-bottom: 20px;
    }
    .print-letterhead img { width: 72px; height: 72px; object-fit: contain; }
    .print-letterhead h1 { margin: 0; font-size: 18px; color: var(--primary-dark); line-height: 1.2; }
    .print-letterhead p { margin: 4px 0 0; font-size: 12px; color: #555; }
}
