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

:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --primary: #2656d9;
    --primary-dark: #1d43ad;
    --secondary: #0f172a;
    --success: #12805c;
    --danger: #e11d48;
    --warning: #a16207;
    --border: #e5e7eb;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Tajawal', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

.login-body {
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 20%, #dfe9ff 0, transparent 34%), linear-gradient(135deg, #0f172a, #1e3a8a);
    padding: 24px;
}
.login-card {
    width: min(440px, 100%);
    background: rgba(255,255,255,.98);
    border-radius: 28px;
    box-shadow: 0 30px 70px rgba(0,0,0,.25);
    padding: 34px;
}
.brand-mark {
    display: inline-flex;
    padding: 10px 16px;
    border-radius: 999px;
    background: #e8efff;
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 8px; font-size: 30px; }
.login-card p { color: var(--muted); margin: 0 0 22px; line-height: 1.8; }
.login-hint { margin-top: 18px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--border); border-radius: 14px; padding: 12px; line-height: 1.8; }

.dashboard-shell { display: grid; grid-template-columns: 286px 1fr; min-height: 100vh; }
.sidebar {
    background: #0f172a;
    color: #fff;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 24px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 16px; }
.logo-box { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(135deg, #3b82f6, #7c3aed); font-weight: 800; }
.sidebar-brand strong { display: block; font-size: 18px; }
.sidebar-brand span { display: block; color: #aab3c5; font-size: 13px; margin-top: 3px; }
.side-nav { display: grid; gap: 8px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-radius: 14px; color: #cbd5e1; transition: .2s; }
.side-nav a:hover, .side-nav a.active { background: rgba(59, 130, 246, .16); color: #fff; }
.nav-icon { min-width: 42px; height: 28px; display: inline-grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.08); font-size: 11px; color: #93c5fd; }

.main-area { min-width: 0; }
.topbar {
    min-height: 92px;
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    padding: 22px 32px;
    background: rgba(255,255,255,.82);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; font-size: 28px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.menu-toggle { display: none; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 13px; cursor: pointer; }
.content-area { padding: 28px 32px 48px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.panel h2 { margin: 0 0 18px; font-size: 21px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-head span { color: var(--muted); background: #f8fafc; border-radius: 999px; padding: 8px 12px; }
.welcome-panel { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.welcome-panel p { color: var(--muted); line-height: 1.9; max-width: 850px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: linear-gradient(135deg, #fff, #f8fbff); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.stat-card span { color: var(--muted); display: block; margin-bottom: 12px; }
.stat-card strong { font-size: 34px; color: var(--primary); }

.form-stack, .admin-form { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label span { display: block; font-weight: 700; margin-bottom: 8px; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: .2s;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, textarea:focus, select:focus { border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(59,130,246,.12); }
.check-row { display: flex; align-items: center; gap: 10px; padding-top: 30px; }
.check-row input { width: auto; }
.check-row span { margin: 0; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Modern Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    border-radius: 14px;
    padding: 12px 22px;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f1f5f9;
    color: #475569;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    user-select: none;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.btn:active { transform: translateY(0); }

.btn-primary { 
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); 
    color: #fff; 
    box-shadow: 0 4px 12px rgba(38, 86, 217, 0.25);
}
.btn-primary:hover { 
    background: linear-gradient(135deg, var(--primary-dark), #163891); 
    box-shadow: 0 8px 20px rgba(38, 86, 217, 0.35);
}

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

.btn-outline { 
    background: #fff; 
    color: var(--text); 
    border: 1px solid var(--border); 
}
.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger { 
    background: #fff1f2; 
    color: var(--danger); 
    border: 1px solid #fecdd3;
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

.btn-sm { 
    padding: 8px 14px; 
    border-radius: 10px; 
    font-size: 13px; 
}
.btn-full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.alert { padding: 14px 16px; border-radius: 15px; margin-bottom: 18px; border: 1px solid transparent; line-height: 1.7; }
.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: var(--warning); border-color: #fde68a; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th, .data-table td { padding: 14px 12px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
.data-table th { color: #475569; font-size: 14px; background: #f8fafc; }
.data-table tr:hover td { background: #fbfdff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center !important; color: var(--muted); padding: 30px !important; }
.thumb { width: 72px; height: 56px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: #f8fafc; }
.brand-thumb { object-fit: contain; background: #fff; }
.preview-img { width: 170px; max-height: 140px; object-fit: contain; border: 1px solid var(--border); border-radius: 16px; padding: 8px; background: #fff; }
.badge { display: inline-flex; border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.info-table { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.info-table div { border: 1px solid var(--border); border-radius: 16px; padding: 15px; background: #fcfdff; }
.info-table strong { display: block; margin-bottom: 6px; }
.info-table span { color: var(--muted); line-height: 1.7; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .form-grid, .form-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .dashboard-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; right: -310px; top: 0; width: 286px; z-index: 50; transition: .25s; }
    .sidebar.open { right: 0; }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 18px; align-items: flex-start; }
    .topbar-user { flex-direction: column; align-items: flex-end; }
    .content-area { padding: 18px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .welcome-panel { flex-direction: column; align-items: stretch; }
    .info-table { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .stats-grid, .form-grid, .form-grid.two-col { grid-template-columns: 1fr; }
    .topbar h1 { font-size: 22px; }
    .panel { padding: 18px; }
}

/* Dynamic CRUD UI */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}
.page-header h1 { margin: 0 0 8px; font-size: 28px; }
.page-header p { margin: 0; color: var(--muted); line-height: 1.8; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.card h2 { margin: 0 0 18px; font-size: 21px; }
.card-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.card-header h2 { margin: 0; }
.card-header small { color: var(--muted); line-height: 1.7; }
.form-card form { display: grid; gap: 18px; }
.form-grid.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.align-end { align-items: end; }
.form-group label { display: block; font-weight: 700; margin-bottom: 8px; }
.switch-row { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; padding: 14px 0; }
.switch-row input { width: auto; transform: scale(1.15); }
.form-image-preview {
    width: 170px;
    max-width: 100%;
    height: 128px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    background: #fff;
    margin-top: 12px;
    display: block;
}
.table-responsive { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-table th, .admin-table td { padding: 14px 12px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
.admin-table th { color: #475569; font-size: 14px; background: #f8fafc; }
.admin-table tr:hover td { background: #fbfdff; }
.admin-table small { display: block; color: var(--muted); margin-top: 4px; direction: ltr; }
.table-thumb { width: 72px; height: 56px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); background: #fff; }
.table-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty-state { text-align: center; color: var(--muted); padding: 26px; background: #f8fafc; border-radius: 16px; margin-top: 14px; }

@media (max-width: 860px) {
    .page-header, .card-header { flex-direction: column; }
}
@media (max-width: 640px) {
    .form-grid.two-cols { grid-template-columns: 1fr; }
    .card { padding: 18px; }
}

/* Visual Button Picker & Live Preview */
.live-preview-container {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    text-align: center;
}

.preview-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.visual-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.color-circle {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.color-circle:hover {
    transform: scale(1.1);
}

.color-circle.active {
    border-color: #333;
    transform: scale(1.1);
}

.custom-color-input {
    width: 45px;
    height: 45px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
}

.style-option {
    padding: 10px 20px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    background: white;
    font-size: 13px;
}

.style-option:hover {
    background: #f1f3f5;
}

.style-option.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(38, 86, 217, 0.05);
}

.btn-preview {
    display: inline-block;
    padding: 12px 30px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    max-width: 100%;
    text-align: center;
}

/* للموبايل - أقل من 768px */
@media (max-width: 767px) {
    .btn-preview {
        padding: 8px 16px;      /* تقليل الـ padding */
        font-size: 15px;        /* تقليل حجم الخط */
        max-width: 90%;         /* تقليل العرض */
    }
}

/* للأجهزة الصغيرة جداً - أقل من 480px */
@media (max-width: 479px) {
    .btn-preview {
        padding: 6px 12px;
        font-size: 15px;
        max-width: 100%;
    }
}

/* Styles */
.btn-preview.solid { border: none; }
.btn-preview.outline { background-color: transparent !important; border-width: 2px; border-style: solid; }
.btn-preview.rounded { border-radius: 50px !important; }
.btn-preview.shadow { box-shadow: 0 10px 20px rgba(0,0,0,0.15); }
.btn-preview.glass { backdrop-filter: blur(5px); background-color: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3); }
.btn-preview.gradient { background-image: linear-gradient(to right, var(--btn-color-start, #4e73df), var(--btn-color-end, #224abe)); color: white; border: none; }
.btn-preview.thick-border { border-width: 4px; border-style: solid; }

/* Predefined Colors */
.btn-preview.color-primary { --btn-color: #4e73df; }
.btn-preview.color-secondary { --btn-color: #858796; }
.btn-preview.color-success { --btn-color: #1cc88a; }
.btn-preview.color-danger { --btn-color: #e74a3b; }
.btn-preview.color-warning { --btn-color: #f6c23e; }
.btn-preview.color-info { --btn-color: #36b9cc; }
.btn-preview.color-dark { --btn-color: #5a5c69; }

/* Apply Color */
.btn-preview.solid { background-color: var(--btn-color); color: white; }
.btn-preview.outline { color: var(--btn-color); border-color: var(--btn-color); }
.btn-preview.thick-border { border-color: var(--btn-color); }
