/* ================================================
   نظام ليالي الشام - التنسيقات الرئيسية
   ================================================ */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Outfit:wght@300;400;500;600;700&display=swap');

/* === CSS Variables === */
:root {
    --primary: #b8912e;
    --primary-light: #d4a843;
    --primary-dark: #9a7824;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-solid: #ffffff;
    --bg-input: #f7f8fa;
    --border: #e2e8f0;
    --border-hover: #b8912e;
    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1), 0 12px 32px rgba(0,0,0,0.06);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --header-height: 64px;
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Outfit', sans-serif;
}

/* === Reset === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ar);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font-ar); }

/* === Numbers Font === */
.num, .price, .total, .count,
input[type="number"], input[type="tel"] {
    font-family: var(--font-en), var(--font-ar);
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ================================================
   Login Screen
   ================================================ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 45px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 35px;
}

.login-logo img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px rgba(184, 145, 46, 0.15);
}

.login-logo h1 {
    color: var(--primary);
    font-size: 30px;
    font-weight: 900;
    margin-top: 15px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 5px;
}

/* ================================================
   Layout - App Shell
   ================================================ */
.app-shell {
    display: none;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.app-shell.active { display: flex; }

/* === Sidebar === */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0,0,0,0.04);
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}

.sidebar-header h2 {
    color: var(--primary);
    font-size: 18px;
    margin-top: 8px;
}

.sidebar-header span {
    color: var(--text-secondary);
    font-size: 11px;
}

.sidebar-nav {
    flex: 1;
    padding: 15px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 4px;
    border: none;
    background: none;
    width: 100%;
    font-size: 14px;
    text-align: right;
}

.nav-item:hover {
    background: #f7f8fa;
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(184, 145, 46, 0.08);
    color: var(--primary);
    font-weight: 700;
    border: 1px solid rgba(184, 145, 46, 0.15);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item .badge {
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    margin-right: auto;
    font-family: var(--font-en);
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 10px;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
    background: #f7f8fa;
}

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

.user-info small { color: var(--text-muted); font-size: 11px; display: block; }

/* === Main Content === */
.main-content {
    margin-right: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === Header === */
.app-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    padding: 8px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    background: #f7f8fa;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.header-btn:hover {
    background: rgba(184, 145, 46, 0.08);
    color: var(--primary);
    border-color: var(--border-hover);
}

.header-btn .dot {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: none;
}

.header-btn .dot.show { display: block; }

.online-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.online-status.offline {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: rgba(231, 76, 60, 0.2);
}

.online-status .dot-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease infinite;
}

/* === Page Content === */
.page-content {
    flex: 1;
    padding: 25px;
}

.page-view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page-view.active { display: block; }

/* ================================================
   Components
   ================================================ */

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* === Stat Cards === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    border-radius: 0 0 0 4px;
}

.stat-card:nth-child(2)::before { background: var(--success); }
.stat-card:nth-child(3)::before { background: var(--info); }
.stat-card:nth-child(4)::before { background: var(--warning); }

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--border-hover);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: rgba(184, 145, 46, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 14px;
}

.stat-card:nth-child(2) .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card:nth-child(3) .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-card:nth-child(4) .stat-icon { background: var(--warning-bg); color: var(--warning); }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    font-family: var(--font-en), var(--font-ar);
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius);
    font-family: var(--font-ar);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
    cursor: pointer;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
    color: #ffffff;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(212, 168, 67, 0.35);
}

.btn-secondary {
    background: #f7f8fa;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover { background: rgba(184, 145, 46, 0.08); color: var(--primary); border-color: var(--border-hover); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; transform: translateY(-2px); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px 12px;
}
.btn-ghost:hover { color: var(--primary); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-icon { width: 38px; height: 38px; padding: 0; }
.btn-block { width: 100%; }

/* === Forms === */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-ar);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a89070' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 35px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* === Tables === */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table th {
    background: #f7f8fa;
    color: var(--text-secondary);
    font-weight: 700;
    padding: 12px 16px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

table td {
    padding: 11px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: #f7f8fa;
}

/* === Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: rgba(184, 145, 46, 0.08); color: var(--primary); }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.modal-close:hover { color: var(--danger); }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* === Toast / Notifications === */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideInLeft 0.4s ease;
    border-right: 4px solid var(--primary);
}

.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.warning { border-right-color: var(--warning); }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 60px;
    height: 60px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.empty-state h4 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* === Loading === */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 3px;
}

/* === Tabs === */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #f1f5f9;
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-ar);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.tab-btn.active {
    background: rgba(184, 145, 46, 0.1);
    color: var(--primary);
    font-weight: 700;
}

/* === Search === */
.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-ar);
    font-size: 14px;
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* === Filters === */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* ================================================
   Animations
   ================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 12px rgba(184, 145, 46, 0.1); }
    50% { box-shadow: 0 0 24px rgba(184, 145, 46, 0.2); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

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

/* ================================================
   Chart Container
   ================================================ */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

/* ================================================
   Responsive Design
   ================================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .menu-toggle { display: flex; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    html { font-size: 13px; }
    .page-content { padding: 15px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .card { padding: 16px; }
    .modal { max-width: 95%; }
    .app-header { padding: 0 15px; }
    .filters-bar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .login-box { padding: 30px 20px; }
    .stat-card .stat-value { font-size: 22px; }
    .toast { min-width: auto; }
}

/* === Sidebar Overlay === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

@media (max-width: 992px) {
    .sidebar.open ~ .sidebar-overlay { display: block; }
}

/* ================================================
   Utilities
   ================================================ */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hidden { display: none !important; }

/* === Font Awesome Icons Sizing === */
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.type-btn i { margin-left: 4px; }
.btn i { font-size: 14px; }
.settings-section h3 i { color: var(--primary); }
.card-header h3 i { font-size: 16px; }
.login-logo h1 i { margin-left: 6px; }
