@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100;300;400;500;700;900&display=swap');

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --sidebar-width: 280px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    direction: rtl;
    background: #f1f5f9;
    color: #334155;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.5s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    color: #fff;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.login-header p { color: #64748b; }

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.login-footer a {
    color: #64748b;
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.login-footer a:hover { color: var(--primary); }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
}

.sidebar-brand h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.sidebar-brand p {
    font-size: 0.8rem;
    color: #64748b;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.5rem;
    color: #64748b;
    text-decoration: none;
    transition: var(--transition);
    border-right: 3px solid transparent;
    margin: 0.25rem 0;
    white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
    background: #f8fafc;
    color: var(--primary);
    border-right-color: var(--primary);
}

.nav-item i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.nav-item span {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: #fff;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-details h4 {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-details p {
    font-size: 0.75rem;
    color: #64748b;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background: #fee2e2;
    color: #ef4444;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.logout-btn:hover { background: #fecaca; }

/* Main Content */
.main-content {
    margin-right: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
    transition: var(--transition);
    max-width: calc(100vw - var(--sidebar-width));
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.top-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, transparent 0%, rgba(99, 102, 241, 0.05) 100%);
    border-radius: 0 0 0 100px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.stat-icon.blue { background: #dbeafe; color: #3b82f6; }
.stat-icon.green { background: #d1fae5; color: #10b981; }
.stat-icon.purple { background: #ede9fe; color: #8b5cf6; }
.stat-icon.orange { background: #fef3c7; color: #f59e0b; }
.stat-icon.red { background: #fee2e2; color: #ef4444; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #64748b;
}

.stat-change {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.stat-change.up { color: #10b981; }
.stat-change.down { color: #ef4444; }

/* Chart Container */
.chart-container {
    background: #fff;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

/* Data Table */
.data-table-container {
    background: #fff;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    overflow-x: auto;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

.table-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: right;
    font-weight: 600;
    font-size: 0.875rem;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    color: #334155;
}

.data-table tr:hover td { background: #f8fafc; }

/* Status Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: transparent;
    border: 2px solid #e2e8f0;
    color: #64748b;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-block { width: 100%; }

/* Form Styles */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: #334155;
}

.form-label .required { color: #ef4444; margin-right: 0.25rem; }

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i:first-child {
    position: absolute;
    right: 1rem;
    color: #94a3b8;
    z-index: 10;
}

.input-group .form-input { padding-right: 2.75rem; }

.toggle-password {
    position: absolute;
    left: 1rem;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    z-index: 10;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    color: #334155;
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder { color: #94a3b8; }

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    padding-left: 2.5rem;
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

/* Filters */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-input {
    padding: 0.625rem 1rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.filter-input:focus { border-color: var(--primary); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.page-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.page-btn:hover,
.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 1rem;
}

.admin-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.admin-modal-content {
    background: #fff;
    border-radius: 24px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

.admin-modal-overlay.active .admin-modal-content { transform: scale(1); }

.admin-modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-radius: 24px 24px 0 0;
}

.admin-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
}

.admin-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f1f5f9;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1rem;
}

.admin-modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.admin-modal-body { padding: 2rem; }

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Image Upload */
.image-upload {
    border: 2px dashed #e2e8f0;
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
}

.image-upload:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.image-upload i {
    font-size: 2rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.image-upload p { color: #64748b; font-size: 0.875rem; }

/* Gallery Grid Admin */
.gallery-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-admin-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
}

.gallery-admin-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.gallery-admin-item:hover img { transform: scale(1.1); }

.gallery-admin-actions {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: var(--transition);
}

.gallery-admin-item:hover .gallery-admin-actions { opacity: 1; }

.gallery-admin-actions button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    color: #fff;
}

.gallery-admin-actions .edit-btn { background: #3b82f6; }
.gallery-admin-actions .delete-btn { background: #ef4444; }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(100%); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-right: 0; max-width: 100vw; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .mobile-menu-btn { display: flex; }
}

/* Mobile Menu Toggle */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    border: none;
    background: #fff;
    color: #1e293b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.mobile-menu-btn:active { transform: scale(0.94); }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
}

.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .main-content { padding-top: 4.5rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .table-header { flex-direction: column; align-items: stretch; }
    .table-actions { justify-content: stretch; }
    .filter-bar { flex-direction: column; }
    .filter-input { width: 100%; }
    .sidebar { width: 260px; }
    .top-bar { padding-top: 3rem; }
    .page-title { font-size: 1.2rem; }
    .admin-modal-content { max-width: 100% !important; }

    /* Collapse two/three-column inline grids used across admin pages */
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: repeat(2, 1fr)"],
    [style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Print */
@media print {
    .sidebar, .top-bar, .btn, .table-actions { display: none !important; }
    .main-content { margin: 0; padding: 0; }
}

/* Scrollbar for tables */
.data-table-container::-webkit-scrollbar {
    height: 6px;
}

.data-table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.data-table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}