/* ==========================================================================
   HESABDI PREMIUM ACCOUNTING UI SYSTEM
   Designed specifically for WebView & Modern ERP Dashboards
   Architecture: Mobile-First, Flexbox/Grid, Glassmorphism
   ========================================================================== */

@import url('https://v1.fontapi.ir/css/Vazirmatn');

:root {
    /* Color Palette - Financial Professional */
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --secondary: #0F172A;
    --secondary-light: #1E293B;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --border: #E2E8F0;
    --text: #1E293B;
    --text-muted: #64748B;
    --text-light: #94A3B8;

    /* Shadows & Effects */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
    --radius: 14px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layout Constants */
    --topbar-height: 64px;
}

/* Dark Mode Override */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F172A;
        --surface: #1E293B;
        --border: #334155;
        --text: #F8FAFC;
        --text-muted: #94A3B8;
        --secondary: #F8FAFC;
    }
}

/* ==========================================================================
   Base Elements
   ========================================================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 500px; /* WebView Optimised for Mobile App Feel */
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 80px; /* Space for bottom interaction */
}

/* Scrollbar Styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--text-light); border-radius: 10px; }

/* ==========================================================================
   Topbar / Navigation
   ========================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--topbar-height);
    background: var(--secondary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-lg);
}

.topbar-title {
    font-weight: 900;
    font-size: 18px;
    letter-spacing: -0.5px;
}

.topbar a {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    opacity: 0.8;
    transition: var(--transition);
}

.topbar a:hover { opacity: 1; }

/* ==========================================================================
   Cards & Stats
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
    transition: var(--transition);
}

.card-header {
    padding: 16px;
    background: rgba(0,0,0,0.02);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-weight: 800;
    font-size: 16px;
    color: var(--primary);
}

.online {
    font-size: 11px;
    color: var(--success);
    font-weight: bold;
}

.card-body { padding: 16px; }

/* Dashboard Summary Stats */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    border-right: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 15px;
    font-weight: 900;
    white-space: nowrap;
}

/* Site-specific Mini Stats */
.mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

.mini-stat {
    padding: 10px;
    background: var(--bg);
    border-radius: 10px;
}

/* ==========================================================================
   Tables (WebView Adaptive)
   ========================================================================== */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: var(--surface);
}

th {
    background: var(--bg);
    padding: 12px 10px;
    text-align: right;
    font-weight: 800;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) { background-color: rgba(0,0,0,0.01); }

/* Financial Data Alignment */
.num {
    font-family: 'Vazirmatn', sans-serif;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.red-text { color: var(--danger); }
.green-text { color: var(--success); }
.blue-text { color: var(--primary); }

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.date-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.field { margin-bottom: 12px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--text-muted);
}

input[type="text"],
input[type="tel"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.btn:active { transform: scale(0.96); }

.btn.green {
    background: var(--success);
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}

.btn.red { background: var(--danger); }
.btn.gray { background: var(--text-muted); }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: flex-end; /* Bottom sheet style for mobile */
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    padding: 24px;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal h3 {
    margin-top: 0;
    font-weight: 900;
    color: var(--secondary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
}

.modal .actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    margin-top: 20px;
}

/* ==========================================================================
   Utilities & Alerts
   ========================================================================== */
.flash {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    animation: fadeInDown 0.4s ease;
}

.error-box {
    background: var(--danger);
    color: white;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    margin-bottom: 15px;
}

.alloc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 11px;
    color: var(--text-muted);
}

.alloc-list li {
    padding: 2px 0;
    border-bottom: 1px dashed var(--border);
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ==========================================================================
   Login Box (Specific)
   ========================================================================== */
.login-box {
    background: var(--surface);
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 400px;
    margin: 100px auto;
}

/* ==========================================================================
   Print Optimization
   ========================================================================== */
@media print {
    .topbar, .btn, .toolbar, .modal-backdrop { display: none !important; }
    body { background: white; }
    .card { border: 1px solid #eee; box-shadow: none; }
}

/* ==========================================================================
   Mobile Table Magic (Stack rows if needed)
   ========================================================================== */
@media screen and (max-width: 480px) {
    th:nth-child(2), td:nth-child(2), /* Hide order count if tight */
    th:nth-child(8), td:nth-child(8) { display: none; }
}