/* ============================================================
   Invoice App - Main Stylesheet
   Theme: Dark Blue (#1a3a6b) + Green (#4caf50) - RTL Persian
   ============================================================ */

:root {
    --primary: #1a3a6b;
    --primary-light: #2454a0;
    --accent: #4caf50;
    --accent-dark: #388e3c;
    --sidebar-width: 240px;
    --topbar-height: 52px;
    --text-dark: #222;
    --text-muted: #666;
    --bg-light: #f5f7fa;
    --border: #e0e0e0;
}

/* ─── Base ──────────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
    font-family: 'Vazirmatn', Tahoma, 'Arial', sans-serif;
    font-size: 14px;
    color: var(--text-dark);
    background: var(--bg-light);
    margin: 0;
    direction: rtl;
}

/* ─── Layout ────────────────────────────────────────────── */
#wrapper { display: flex; min-height: 100vh; }

#sidebar-wrapper {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}

#page-content-wrapper {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Sidebar collapsed */
#wrapper.sidebar-collapsed #sidebar-wrapper { transform: translateX(100%); }
#wrapper.sidebar-collapsed #page-content-wrapper { margin-right: 0; }

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    color: #fff;
}

.brand-logo {
    width: 42px; height: 42px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.brand-name { font-size: 13px; font-weight: 700; color: #fff; line-height: 1.3; }
.brand-sub { font-size: 10px; color: rgba(255,255,255,.6); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section {
    font-size: 10px;
    color: rgba(255,255,255,.45);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 14px 18px 4px;
    font-weight: 600;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    border-radius: 0;
    transition: background .15s, color .15s;
    font-size: 13px;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.sidebar-nav .nav-link.active { border-right: 3px solid var(--accent); }

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: rgba(255,255,255,.7);
    font-size: 12px;
}

/* ─── Topbar ────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

/* ─── Content ───────────────────────────────────────────── */
.main-content { flex: 1; padding: 24px; }

/* ─── Cards ─────────────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.card-header { background: #fff; font-weight: 600; padding: 14px 16px; border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0 !important; }

/* ─── Stat Cards ────────────────────────────────────────── */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.stat-blue { background: linear-gradient(135deg, #1a3a6b, #2454a0); }
.stat-green { background: linear-gradient(135deg, #388e3c, #66bb6a); }
.stat-orange { background: linear-gradient(135deg, #e65100, #ff8f00); }
.stat-red { background: linear-gradient(135deg, #c62828, #ef5350); }

.stat-icon { font-size: 32px; opacity: .8; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; opacity: .85; margin-top: 2px; }

/* ─── Tables ────────────────────────────────────────────── */
.table th { font-weight: 600; font-size: 13px; }
.table td { font-size: 13px; vertical-align: middle; }

/* ─── Login Page ────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a3a6b 0%, #2454a0 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo {
    width: 60px; height: 60px;
    background: var(--primary);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px; font-weight: 700; color: #fff;
    margin-bottom: 12px;
}

/* ─── Invoice Paper ─────────────────────────────────────── */
.invoice-paper {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    overflow: hidden;
    max-width: 900px;
    margin: 0 auto;
}

/* Invoice Header */
.inv-header {
    background: var(--primary);
    color: #fff;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.inv-company-name { font-size: 24px; font-weight: 700; }
.inv-company-slogan { font-size: 12px; opacity: .8; margin-top: 2px; }
.inv-meta { margin-top: 12px; font-size: 12px; line-height: 2; }
.inv-meta span { color: rgba(255,255,255,.7); }

.inv-badge-hex {
    width: 100px; height: 100px;
    background: rgba(255,255,255,.15);
    border: 3px solid rgba(255,255,255,.5);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    text-align: center;
}

.inv-badge-inner { color: #fff; }
.inv-type-label { font-size: 10px; opacity: .9; }
.inv-number { font-size: 13px; font-weight: 700; margin-top: 2px; }

/* Parties */
.inv-parties {
    display: flex;
    gap: 24px;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
}

.inv-party { flex: 1; }
.inv-party-title {
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 4px;
    margin-bottom: 10px;
}

.inv-party-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12.5px;
}
.inv-party-row label { color: var(--text-muted); white-space: nowrap; }

/* Items Table */
.inv-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.inv-items-table thead tr {
    background: var(--accent);
    color: #fff;
}

.inv-items-table th {
    padding: 10px 10px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--accent-dark);
}

.inv-items-table td {
    padding: 8px 10px;
    border: 1px solid #e8e8e8;
    font-size: 12.5px;
    vertical-align: top;
}

.inv-items-table tbody tr:nth-child(even) { background: #f9fef9; }

/* Footer Section */
.inv-footer-section {
    display: flex;
    gap: 24px;
    padding: 20px 28px;
    border-top: 1px solid var(--border);
}

.inv-notes { flex: 1; font-size: 12px; line-height: 1.8; color: var(--text-dark); }
.inv-notes-title { font-weight: 700; color: var(--primary); margin-bottom: 8px; }

.inv-totals {
    width: 260px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.inv-total-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 12.5px;
    border-bottom: 1px solid #f0f0f0;
}

.inv-grand-total {
    background: var(--primary);
    color: #fff;
    border-radius: 6px;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 14px;
    margin-top: 8px;
    border: none;
}

.inv-remaining {
    color: var(--accent-dark);
    font-weight: 600;
}

.inv-doc-footer {
    background: var(--primary);
    color: rgba(255,255,255,.8);
    display: flex;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 11px;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

/* ─── Print ─────────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    #sidebar-wrapper { display: none !important; }
    #page-content-wrapper { margin-right: 0 !important; }
    .topbar { display: none !important; }
    .main-content { padding: 0 !important; }
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar-wrapper { transform: translateX(100%); }
    #page-content-wrapper { margin-right: 0; }
    #wrapper.sidebar-open #sidebar-wrapper { transform: translateX(0); }
}

/* ─── Jalali Date Picker ────────────────────────────────── */
.jal-date-wrap { position: relative; }

.jal-date-wrap .form-control {
    background-image: linear-gradient(45deg, transparent 50%, var(--primary) 50%),
                      linear-gradient(135deg, var(--primary) 50%, transparent 50%);
    background-position: calc(.5rem) calc(50%), calc(.5rem + 4px) calc(50%);
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    direction: ltr;
    text-align: right;
    font-family: 'Vazirmatn', Tahoma, monospace, sans-serif;
    cursor: pointer;
}

.jal-calendar {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1050;
    width: 290px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: 10px;
    direction: rtl;
    user-select: none;
}

.jal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.jal-title {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
}
.jal-nav {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    line-height: 1;
    font-size: 18px;
    color: var(--primary);
    cursor: pointer;
}
.jal-nav:hover { background: var(--bg-light); }

.jal-weekdays, .jal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}
.jal-weekdays span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    padding: 4px 0;
}
.jal-day, .jal-empty {
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.jal-day {
    cursor: pointer;
    color: var(--text-dark);
}
.jal-day:hover { background: #e8f0fe; }
.jal-day.jal-today {
    outline: 1px solid var(--accent);
    color: var(--accent-dark);
    font-weight: 700;
}
.jal-day.jal-selected {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}
.jal-day.jal-selected:hover { background: var(--primary-light); }

.jal-foot {
    margin-top: 8px;
    text-align: center;
}
.jal-today-btn {
    border: 1px solid var(--accent);
    background: #fff;
    color: var(--accent-dark);
    border-radius: 6px;
    padding: 4px 16px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}
.jal-today-btn:hover { background: #e8f5e9; }
