@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
}

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
}

/* ---------- Login ---------- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
    top: -200px; left: -200px;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    bottom: -150px; right: -150px;
}
.login-box {
    background: #fff;
    padding: 45px 35px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 2;
}
.login-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ffffff, #ffffff);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: #fff;
    font-size: 36px;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}
.login-box h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 6px;
    color: var(--text);
}
.login-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 14px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; margin-bottom: 8px;
    font-size: 14px; color: var(--text-muted); font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 16px;
    transition: all 0.2s;
    background: #fafafa;
    direction: ltr;
    text-align: center;
    letter-spacing: 2px;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    width: 100%;
    box-shadow: 0 8px 20px rgba(99,102,241,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 25px rgba(99,102,241,0.45); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 14px;
    display: flex; align-items: center; gap: 8px;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.code-inputs {
    display: flex; gap: 10px; justify-content: center; direction: ltr;
    margin-bottom: 20px;
}
.code-inputs input {
    width: 50px; height: 60px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fafafa;
    font-family: inherit;
}
.code-inputs input:focus {
    outline: none; border-color: var(--primary);
    background: #fff; box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
}

.timer { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 15px; }
.timer a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ---------- App Header ---------- */
.app-header {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    padding: 20px;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 8px 30px rgba(99,102,241,0.25);
}
.app-header-inner {
    max-width: 1000px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
}
.app-header h1 { font-size: 20px; }
.app-header .user-info { font-size: 13px; opacity: 0.9; }

.container {
    max-width: 1000px; margin: 0 auto;
    padding: 20px;
}

.search-box {
    position: relative; margin: 20px 0;
}
.search-box input {
    width: 100%;
    padding: 14px 50px 14px 20px;
    border: none;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    font-family: inherit;
    font-size: 15px;
}
.search-box input:focus { outline: 2px solid var(--primary); }
.search-box i {
    position: absolute; right: 20px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin: 25px 0 15px;
    display: flex; align-items: center; gap: 8px;
}
.section-title::before {
    content: ''; width: 4px; height: 20px;
    background: var(--primary); border-radius: 2px;
}

/* ---------- Categories Grid ---------- */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}
.category-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}
.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(99,102,241,0.18);
}
.category-icon {
    width: 60px; height: 60px;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
    font-size: 26px;
    color: #fff;
}
.category-name { font-size: 14px; font-weight: 600; }
.category-count { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.badge-type {
    position: absolute; top: 8px; left: 8px;
    font-size: 10px; padding: 2px 8px;
    border-radius: 8px;
    background: #f1f5f9; color: var(--text-muted);
}

/* ---------- Products ---------- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.product-card {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.25s;
}
.product-card:hover { transform: translateY(-3px); }
.product-image {
    height: 140px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; font-size: 40px;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 12px; }
.product-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; min-height: 42px; }
.product-price { display: flex; align-items: center; justify-content: space-between; }
.price-main { color: var(--primary); font-weight: 700; font-size: 15px; }
.price-old {
    color: var(--text-muted); text-decoration: line-through; font-size: 12px;
}
.discount-badge {
    background: var(--danger); color: #fff;
    font-size: 11px; padding: 2px 6px; border-radius: 6px;
}
.out-of-stock {
    color: var(--danger); font-size: 12px; font-weight: 600;
}

.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 60px; margin-bottom: 20px; opacity: 0.4; }

/* ---------- Admin ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px; background: #1e293b; color: #cbd5e1;
    padding: 20px 0;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 0 20px 20px;
    font-size: 20px; font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #334155;
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px;
}
.sidebar-menu { list-style: none; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 14px;
}
.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: #334155;
    color: #fff;
    border-right: 3px solid var(--primary);
}
.sidebar-menu i { width: 20px; text-align: center; }

.admin-content { flex: 1; padding: 25px; background: var(--bg); }
.admin-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.admin-header h2 { font-size: 22px; }

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 15px;
}
.stat-icon {
    width: 55px; height: 55px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 22px;
}
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 13px; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.table-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}
.table-card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.table-card-header h3 { font-size: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 12px 15px;
    text-align: right;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
}
table tr:hover td { background: #f8fafc; }

.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    padding: 25px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none; border: none;
    font-size: 22px; cursor: pointer;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar-brand span,
    .sidebar-menu a span { display: none; }
    .sidebar-menu a { justify-content: center; padding: 15px; }
    .form-row { grid-template-columns: 1fr; }
    .categories-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

a.product-card {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
}
a.product-card:hover .product-name {
    color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════
   IMPORTANT: جلوگیری از شکستن position:fixed
   ═══════════════════════════════════════════════════════════ */
html, body {
    overflow-x: hidden;
}

body {
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    -webkit-perspective: none !important;
}

/* اگر جایی transform داشتیم، fixed رو نمی‌شکنه */
body > * {
    transform: none;
}