/* ========== فونت فارسی ========== */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700&display=swap');

/* ========== متغیرهای تم ========== */
:root {
    --bg: #f0f4f8;
    --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --accent: #2e7d32; /* این مقدار با PHP جایگزین می‌شود */
    --accent-rgb: 46, 125, 50; /* این هم جایگزین می‌شود */
    --accent-hover: #1b5e20;
    --accent-light: #4caf50;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --chart-grid: #e2e8f0;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: rgba(30, 41, 59, 0.75);
    --surface-solid: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: #334155;
    --accent: #4caf50;
    --accent-hover: #66bb6a;
    --accent-light: #81c784;
    --danger: #ef5350;
    --success: #66bb6a;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.5);
    --chart-grid: #475569;
}

/* ========== پایه ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--bg);
    background-image: 
        radial-gradient(circle at 20% 20%, var(--accent-light) 0%, transparent 25%),
        radial-gradient(circle at 80% 80%, var(--accent) 0%, transparent 30%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    padding: 20px;
    direction: rtl;
    text-align: right;
    transition: background-color var(--transition), color var(--transition);
    animation: fadeInPage 0.8s ease-out;
}

@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== کانتینر ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ========== کارت‌ها ========== */
.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    animation: slideUp 0.6s ease-out both;
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

/* ========== نوار ناوبری ========== */
.navbar {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 20px;
    z-index: 100;
    animation: slideUp 0.5s ease-out;
    direction: rtl;
}
.navbar > div:first-child {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}
.navbar > div:last-child {
    text-align: left;
}
.navbar a {
    color: var(--text-secondary);
    text-decoration: none;
    margin: 0 10px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all var(--transition);
    position: relative;
}
.navbar a:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    transform: translateY(-2px);
}
.navbar a::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 50%;
    transform: translateX(50%);
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width var(--transition);
}
.navbar a:hover::after {
    width: 70%;
}

/* لوگو */
.navbar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    overflow: hidden;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    background: var(--accent);
    border: 2px solid var(--accent);
}
.navbar-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 15px;
}

/* ========== لینک‌ها ========== */
a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-hover);
}

/* ========== دکمه‌ها ========== */
button, .btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 500;
    transition: all var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    display: inline-block;
    text-align: center;
    line-height: 1.5;
}
button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    filter: brightness(1.05);
    color: #ffffff;
}
button:active, .btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}
button:active::after {
    width: 300px;
    height: 300px;
}

/* دکمه‌های با رنگ متفاوت (در صورت استفاده از کلاس‌های خاص) */
.btn-blue { background: linear-gradient(135deg, #3498db, #2980b9); }
.btn-red { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.btn-green { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn-gray { background: linear-gradient(135deg, #95a5a6, #7f8c8d); }

/* ========== فرم‌ها ========== */
input, select, textarea {
    background-color: var(--surface-solid);
    color: var(--text);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    margin: 8px 0;
    width: 100%;
    max-width: 100%;
    font-family: 'Vazirmatn', sans-serif;
    text-align: right;
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}
textarea {
    min-height: 100px;
    resize: vertical;
}

/* ========== جدول‌ها ========== */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 15px 0;
    border-radius: 12px;
    overflow: hidden;
}
th {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--text);
    font-weight: 700;
    padding: 14px 16px;
    text-align: right;
    border-bottom: 2px solid var(--border);
}
td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
tr:last-child td {
    border-bottom: none;
}
tbody tr:hover td {
    background: rgba(var(--accent-rgb), 0.05);
}

/* ========== هشدارها ========== */
.alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    animation: slideUp 0.4s ease-out;
    font-weight: 500;
}
.alert-error {
    background: #fee2e2;
    color: var(--danger);
    border-right: 4px solid var(--danger);
    border-left: none;
}
.alert-success {
    background: #dcfce7;
    color: var(--success);
    border-right: 4px solid var(--success);
    border-left: none;
}

/* ========== نمودار ========== */
.chart-container {
    max-width: 100%;
    margin: 20px auto;
    padding: 20px;
    background: var(--surface-solid);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: transform var(--transition);
}
.chart-container:hover {
    transform: scale(1.01);
}

/* ========== اسکرول‌بار ========== */
::-webkit-scrollbar {
    width: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

/* ========== پرینت ========== */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    .no-print {
        display: none !important;
    }
    .print-only {
        display: block !important;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    .navbar {
        display: none !important;
    }
    table {
        border-collapse: collapse;
        width: 100%;
    }
    th, td {
        border: 1px solid #000 !important;
        padding: 8px;
    }
}

/* ========== ریسپانسیو ========== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 0;
    }
    .navbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 15px;
        position: static;
    }
    .navbar > div:first-child {
        flex-direction: column;
        align-items: flex-start;
    }
    .navbar a {
        display: inline-block;
        margin: 5px;
        font-size: 14px;
        padding: 6px 10px;
    }
    .navbar > div:last-child {
        align-self: flex-start;
    }
    .card {
        padding: 18px;
        margin-bottom: 15px;
    }
    table, thead, tbody, th, td, tr {
        display: block;
    }
    thead {
        display: none;
    }
    tr {
        margin-bottom: 15px;
        border: 1px solid var(--border);
        border-radius: 10px;
        overflow: hidden;
    }
    td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        border-bottom: 1px solid var(--border);
    }
    td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--text-secondary);
        margin-left: 10px;
    }
    td:last-child {
        border-bottom: none;
    }
    input, select, textarea, button {
        font-size: 16px;
    }
    .chart-container {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 10px;
    }
    .navbar a {
        margin: 3px;
        font-size: 13px;
        padding: 5px 8px;
    }
    .card {
        padding: 15px;
    }
    button, .btn {
        padding: 10px 20px;
        width: 100%;
    }
    .card h2, .card h3 {
        font-size: 1.3rem;
    }
}