@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;600;800;900&display=swap');

:root {
    --bg-light: #f4f8fb;
    --white-glass: rgba(255, 255, 255, 0.7);
    --white-glass-heavy: rgba(255, 255, 255, 0.95);
    --blue-primary: #2563eb;
    --blue-light: #60a5fa;
    --blue-glow: rgba(37, 99, 235, 0.2);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-glass: rgba(255, 255, 255, 0.5);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    --kpi-green: #10b981;
    --kpi-blue: #3b82f6;
    --kpi-purple: #8b5cf6;
    --kpi-orange: #f59e0b;
    --kpi-teal: #14b8a6;
    --kpi-dark: #475569;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
}

body {
    background: transparent;
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
}

/* =========================================
   دکمه شناور (FAB)
   ========================================= */
.fab-menu-btn {
    position: fixed;
    top: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--white-glass-heavy);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    color: var(--blue-primary);
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-glass);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-menu-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 40px var(--blue-glow);
    color: var(--blue-light);
}

/* =========================================
   منوی شیشه ای تمام صفحه
   ========================================= */
.overlay-menu {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(244, 248, 251, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-menu.open {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    width: 90%;
    max-width: 1000px;
    transform: scale(0.9) translateY(20px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.overlay-menu.open .overlay-content {
    transform: scale(1) translateY(0);
}

.close-btn {
    position: absolute;
    top: 30px;
    left: 30px;
    background: var(--white-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.close-btn:hover { background: var(--white-glass-heavy); color: #ef4444; transform: rotate(90deg); }

.menu-header { text-align: center; margin-bottom: 50px; }
.menu-header h2 { font-size: 36px; font-weight: 900; color: var(--blue-primary); margin-bottom: 10px; letter-spacing: -1px; }
.menu-header p { color: var(--text-muted); font-size: 16px; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.menu-card {
    background: var(--white-glass);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-glass);
    padding: 35px 20px;
    border-radius: 24px;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-glass);
    cursor: pointer;
}

.menu-card i {
    font-size: 40px;
    color: var(--blue-primary);
    transition: all 0.4s;
}

.menu-card span {
    font-size: 18px;
    font-weight: 700;
}

.menu-card:hover {
    background: var(--blue-primary);
    color: white;
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px var(--blue-glow);
}

.menu-card:hover i {
    color: white;
    transform: scale(1.1);
}

/* =========================================
   محتوای اصلی
   ========================================= */
.main-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 60px 40px;
    padding-top: 100px;
    position: relative;
    z-index: 10;
}

.page-header { margin-bottom: 40px; }
.page-header h1 { font-size: 34px; font-weight: 900; color: var(--text-main); margin-bottom: 8px; }
.page-header p { color: var(--text-muted); font-size: 16px; }

/* =========================================
   کارت‌های KPI (داشبورد جدید)
   ========================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.kpi-card {
    background: var(--white-glass-heavy);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    padding: 24px;
    border-radius: 20px;
    box-shadow: var(--shadow-glass);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 0;
}

.kpi-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.kpi-info {
    min-width: 0;
    flex: 1;
}

.kpi-info h3 {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 26px;
    font-weight: 900;
    color: var(--text-main);
    overflow-wrap: anywhere;
}

.kpi-value span {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.kpi-green .kpi-icon { background: var(--kpi-green); box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3); }
.kpi-blue .kpi-icon { background: var(--kpi-blue); box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3); }
.kpi-purple .kpi-icon { background: var(--kpi-purple); box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3); }
.kpi-orange .kpi-icon { background: var(--kpi-orange); box-shadow: 0 8px 20px rgba(245, 158, 11, 0.3); }
.kpi-teal .kpi-icon { background: var(--kpi-teal); box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3); }
.kpi-dark .kpi-icon { background: var(--kpi-dark); box-shadow: 0 8px 20px rgba(71, 85, 105, 0.3); }

/* =========================================
   جداول
   ========================================= */
.table-container {
    background: var(--white-glass-heavy);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    box-shadow: var(--shadow-glass);
    margin-bottom: 40px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

th, td {
    padding: 18px 12px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: var(--text-main);
    white-space: nowrap;
}

th {
    background: rgba(37, 99, 235, 0.05);
    color: var(--blue-primary);
    font-weight: 800;
    font-size: 15px;
}

tr:last-child td { border-bottom: none; }
tr { transition: background 0.3s; }
tr:hover td { background: rgba(37, 99, 235, 0.03); }

/* =========================================
   فرم‌ها و دکمه‌ها
   ========================================= */
.btn {
    padding: 16px 32px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
    background: var(--blue-primary);
    box-shadow: 0 8px 20px var(--blue-glow);
}

.btn:hover {
    background: var(--blue-light);
    transform: translateY(-2px);
    box-shadow: 0 12px 25px var(--blue-glow);
}

.btn-primary { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.btn-lg { padding: 18px 40px; font-size: 17px; border-radius: 18px; }
.btn-sm {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 10px;
    box-shadow: none;
    gap: 4px;
}
.btn-outline {
    background: transparent; border: 2px solid var(--blue-primary);
    color: var(--blue-primary); box-shadow: none;
}
.btn-outline:hover { background: var(--blue-primary); color: white; }
.btn-danger { background: #ef4444; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: linear-gradient(135deg, #10b981, #34d399); }
.btn-block { width: 100%; }

/* =========================================
   استایل دکمه‌های عملیات در جدول
   ========================================= */
.action-buttons {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 8px;
    min-width: 34px;
    height: 32px;
    box-shadow: none;
    margin: 0;
    flex-shrink: 0;
}

/* =========================================
   فرم‌ها
   ========================================= */
.form-group { margin-bottom: 25px; display: flex; flex-direction: column; gap: 0.5rem; }
label { display: block; margin-bottom: 4px; font-weight: 700; color: var(--text-main); font-size: 15px; }

select, input[type="number"], input[type="text"], input[type="date"], input[type="password"], textarea {
    width: 100%;
    padding: 15px 18px;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 16px;
    font-size: 16px;
    color: var(--text-main);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
    font-family: inherit;
}
select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--blue-light);
    box-shadow: 0 0 0 4px var(--blue-glow);
}

/* پیام‌ها */
.messages { padding: 20px; border-radius: 16px; margin-bottom: 30px; font-weight: 600; }
.success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.section-title { margin-bottom: 25px; color: var(--text-main); font-size: 24px; font-weight: 900; display: flex; align-items: center; gap: 10px; }
.section-title i { color: var(--blue-primary); }
.text-danger { color: #ef4444; font-weight: 800; }
.text-success { color: #10b981; font-weight: 800; }

/* =========================================
   استایل‌های صفحات (انبار، خرید، تامین‌کننده، مشتریان)
   ========================================= */
.page-container { max-width: 1200px; margin: 0 auto; padding: 1rem; width: 100%; }

.page-header-flex {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1rem; margin-bottom: 2rem;
}
.page-header-flex h1 { font-size: 1.8rem; font-weight: 900; color: var(--text-main); }
.header-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.search-bar {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.85rem 1.25rem; border-radius: 16px; margin-bottom: 1.5rem;
    background: var(--white-glass-heavy);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-glass);
}
.search-bar i { color: var(--text-muted); }
.search-bar input {
    flex: 1; min-width: 0; border: none; background: transparent;
    outline: none; font-family: inherit; font-size: 1rem; padding: 0.4rem;
    box-shadow: none;
}

.glass {
    background: var(--white-glass-heavy);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    box-shadow: var(--shadow-glass);
}

.glass-table-wrapper {
    border-radius: 24px;
    background: var(--white-glass-heavy);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-glass);
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.glass-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 650px;
}

.glass-table th, .glass-table td {
    padding: 1.1rem 0.75rem;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    white-space: nowrap;
}

.glass-table th { background: rgba(37, 99, 235, 0.05); font-weight: 800; color: var(--blue-primary); }
.glass-table tr:hover td { background: rgba(37, 99, 235, 0.03); }

.badge { padding: 0.4rem 0.8rem; border-radius: 10px; font-size: 0.85rem; font-weight: 700; display: inline-block; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state i { font-size: 3.5rem; color: var(--blue-light); margin-bottom: 1.25rem; opacity: 0.75; }
.empty-state p { margin-bottom: 1.5rem; color: var(--text-muted); font-size: 1.05rem; }

.form-container { padding: 2.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group .form-control {
    width: 100%; padding: 1rem 1.2rem; border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08); background: rgba(255,255,255,0.92);
    font-family: inherit; font-size: 1rem; outline: none; transition: all 0.3s;
}
.form-group .form-control:focus { border-color: var(--blue-primary); box-shadow: 0 0 0 4px var(--blue-glow); }
.form-help { color: var(--text-muted); font-size: 0.8rem; }
.field-error { color: #ef4444; font-size: 0.85rem; margin-top: 0.3rem; }
.form-actions { display: flex; gap: 1rem; margin-top: 2rem; justify-content: flex-end; flex-wrap: wrap; }

.text-muted { color: var(--text-muted); font-size: 0.9rem; display: block; margin-top: 0.2rem; }

/* =========================================
   کارت نمودار (Chart.js)
   ========================================= */
.chart-card {
    padding: 30px;
    margin-bottom: 40px;
    background: var(--white-glass-heavy);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    box-shadow: var(--shadow-glass);
}
.chart-card canvas {
    max-height: 300px;
    max-width: 100%;
}

/* =========================================
   بهینه‌سازی کامل نسخه موبایل (تا عرض 768px)
   ========================================= */
@media (max-width: 768px) {
    .main-container {
        padding-left: 12px;
        padding-right: 12px;
        padding-top: 18px;
    }

    .page-container {
        padding: 0.25rem;
    }

    .page-header {
        margin-bottom: 20px;
    }

    .page-header h1,
    .page-header-flex h1 {
        font-size: 1.45rem;
        line-height: 1.4;
    }

    .page-header p {
        font-size: 0.9rem;
    }

    .page-header-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
        gap: 0.5rem;
    }

    .header-actions .btn {
        width: 100%;
        padding: 11px 14px;
        font-size: 0.88rem;
        border-radius: 13px;
    }

    .section-title {
        font-size: 1.15rem;
        margin-bottom: 14px;
    }

    /* کارت‌های KPI در موبایل */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 22px;
    }

    .kpi-card {
        padding: 16px;
        border-radius: 18px;
        gap: 14px;
    }

    .kpi-card:hover {
        transform: none;
    }

    .kpi-icon {
        width: 48px;
        height: 48px;
        border-radius: 14px;
        font-size: 20px;
    }

    .kpi-info h3 {
        font-size: 0.82rem;
        margin-bottom: 4px;
    }

    .kpi-value {
        font-size: 1.3rem;
    }

    /* فرم‌ها و دکمه‌ها در موبایل */
    .form-container {
        padding: 1.15rem;
        border-radius: 18px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-group {
        margin-bottom: 14px;
    }

    label {
        font-size: 0.9rem;
    }

    select,
    input[type="number"],
    input[type="text"],
    input[type="date"],
    input[type="password"],
    textarea,
    .form-group .form-control {
        padding: 12px 14px;
        font-size: 16px; /* جلوگیری از زوم خودکار iOS */
        border-radius: 13px;
    }

    .btn {
        padding: 13px 18px;
        font-size: 0.95rem;
        border-radius: 14px;
    }

    .btn-lg {
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 15px;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 0.65rem;
        margin-top: 1.25rem;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* جدول‌ها و کارت نمودار در موبایل */
    .table-container,
    .glass-table-wrapper {
        border-radius: 18px;
        margin-bottom: 24px;
    }

    table,
    .glass-table {
        min-width: 560px;
    }

    th, td,
    .glass-table th, .glass-table td {
        padding: 12px 8px;
        font-size: 0.82rem;
    }

    th {
        font-size: 0.84rem;
    }

    .badge {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .chart-card {
        padding: 16px;
        border-radius: 18px;
        margin-bottom: 24px;
    }

    .chart-card canvas {
        max-height: 220px;
    }

    .close-btn {
        top: 16px;
        left: 16px;
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
}