/* =========================================================
   Financial Dashboard — Shared Theme
   Persian (RTL) fintech admin. Loaded by every template.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
    /* Neutrals */
    --bg: #eef1f7;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --ink: #0f1b2d;
    --muted: #64748b;
    --border: #e4e9f2;

    /* Brand + semantic */
    --primary: #3b46c4;
    --primary-strong: #2b34a0;
    --primary-soft: #eef0ff;
    --success: #0f9d6e;
    --success-soft: #e7f7f1;
    --danger: #e0413f;
    --danger-soft: #fdecec;
    --info: #2f6bff;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 3px rgba(15, 27, 45, .04);
    --shadow: 0 6px 24px rgba(15, 27, 45, .08);
    --ring: 0 0 0 3px rgba(59, 70, 196, .18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Vazirmatn', Tahoma, system-ui, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-strong); }

/* ---------------- Top App Bar ---------------- */
.header {
    background: linear-gradient(90deg, #171f3d 0%, #232c57 100%);
    color: #fff;
    padding: 0 clamp(16px, 4vw, 34px);
    min-height: 66px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header h1 {
    font-size: 19px;
    font-weight: 700;
    margin: 14px 0;
    letter-spacing: -.2px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.header h1::before {
    content: "";
    width: 10px; height: 22px;
    border-radius: 4px;
    background: linear-gradient(180deg, #6f79f0, #3b46c4);
}

.header > div { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

.header a {
    color: #c9d0ea;
    font-size: 13.5px;
    font-weight: 500;
    padding: 8px 13px;
    border-radius: 999px;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.header a:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* ---------------- Layout ---------------- */
.container {
    max-width: 1180px;
    margin: 26px auto;
    padding: 0 clamp(14px, 4vw, 24px);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* ---------------- Cards ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 22px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 300px;
}
.card-table { flex: 2 1 560px; min-width: 320px; overflow-x: auto; }

.card h2, .container h2 {
    margin: 0 0 18px;
    color: var(--ink);
    font-size: 17px;
    font-weight: 700;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 9px;
}
.card h2::before, .container h2::before {
    content: "";
    width: 6px; height: 18px;
    border-radius: 3px;
    background: var(--primary);
}

/* ---------------- Summary boxes ---------------- */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    width: 100%;
    margin-bottom: 4px;
}
.summary-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.summary-box::after {
    content: "";
    position: absolute;
    inset-inline-start: 0; top: 0; bottom: 0;
    width: 5px;
    background: var(--primary);
}
.summary-box:nth-child(2)::after { background: var(--success); }
.summary-box:nth-child(3)::after { background: var(--danger); }
.summary-box h3 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.summary-box p {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.5px;
    font-variant-numeric: tabular-nums;
}

/* ---------------- Forms ---------------- */
label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: #47536b;
    margin: 14px 0 6px;
}
input, select, textarea {
    width: 100%;
    padding: 11px 13px;
    font-family: inherit;
    font-size: 14.5px;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: #9aa6bd; }
textarea { resize: vertical; }
input[type="file"] { padding: 9px; background: #fff; cursor: pointer; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .06s, box-shadow .15s, background .15s;
    box-shadow: 0 2px 6px rgba(59, 70, 196, .25);
    text-decoration: none;
}
.btn:hover { background: var(--primary-strong); color: #fff; box-shadow: 0 5px 14px rgba(59, 70, 196, .3); }
.btn:active { transform: translateY(1px); }
.btn-blue { background: var(--info); box-shadow: 0 2px 6px rgba(47, 107, 255, .25); }
.btn-blue:hover { background: #1e54e6; }
.btn-green { background: var(--success); box-shadow: 0 2px 6px rgba(15, 157, 110, .25); }
.btn-green:hover { background: #0c855d; }
.btn-red { background: var(--danger); box-shadow: 0 2px 6px rgba(224, 65, 63, .25); }
.btn-red:hover { background: #c5332f; }

form .btn { margin-top: 18px; }

/* ---------------- Tables ---------------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    overflow: hidden;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
th, td {
    padding: 13px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th {
    background: var(--surface-2);
    color: #47536b;
    font-weight: 700;
    font-size: 13px;
    position: sticky;
    top: 0;
}
tbody tr:last-child td, tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: var(--primary-soft); }
td a { font-weight: 600; }

.pill {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
}
.pill-green { background: var(--success-soft); color: var(--success); }
.pill-red { background: var(--danger-soft); color: var(--danger); }

/* ---------------- Filters bar ---------------- */
.filters {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-sm);
}
.filters form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filters label { margin: 0 0 6px; }
.filters .btn { margin-top: 0; }
.filters input { width: auto; min-width: 150px; }

/* ---------------- Autocomplete ---------------- */
.search-wrapper { position: relative; }
.autocomplete-items {
    position: absolute;
    z-index: 60;
    inset-inline: 0;
    top: calc(100% + 4px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    overflow: hidden;
    max-height: 240px;
    overflow-y: auto;
}
.autocomplete-items div {
    padding: 11px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.autocomplete-items div:last-child { border-bottom: none; }
.autocomplete-items div:hover { background: var(--primary-soft); color: var(--primary-strong); }

/* ---------------- Persian datepicker polish ---------------- */
.datepicker-plot-area { border-radius: var(--radius-sm) !important; box-shadow: var(--shadow) !important; border: 1px solid var(--border) !important; font-family: 'Vazirmatn', Tahoma, sans-serif !important; }

/* ---------------- Utilities ---------------- */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.muted { color: var(--muted); }

@media (max-width: 640px) {
    .header { min-height: 0; padding-block: 10px; }
    .header h1 { font-size: 16px; margin: 6px 0; }
    .summary-box p { font-size: 20px; }
    th, td { padding: 10px 8px; font-size: 13px; }
}
