/* ===============================
   HK HAMZA - Custom Styles
   =============================== */

:root {
    /* Base Variables (Theme 1: Light Gray/Red - Default HKHAMZA) */
    --bg-main: #f1f5f9;
    --bg-secondary: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary-color: #dc2626; /* Red */
    --primary-hover: #b91c1c;
    --border-color: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --hover-bg: rgba(0, 0, 0, 0.05);
    --input-bg: rgba(0, 0, 0, 0.03);
    
    --sidebar-width: 280px;
    --topbar-height: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme 2: Ocean */
[data-theme="ocean"] {
    --bg-main: #020617;
    --bg-secondary: #0f172a;
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(14, 165, 233, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    --hover-bg: rgba(255, 255, 255, 0.05);
    --input-bg: rgba(0, 0, 0, 0.2);
}

/* Theme 3: Sunset */
[data-theme="sunset"] {
    --bg-main: #170f11;
    --bg-secondary: #2e1065;
    --primary-color: #d946ef;
    --primary-hover: #c026d3;
    --glass-bg: rgba(46, 16, 101, 0.6);
    --glass-border: rgba(217, 70, 239, 0.1);
    --text-main: #f8fafc;
    --text-muted: #a78bfa;
    --border-color: rgba(255, 255, 255, 0.08);
    --hover-bg: rgba(255, 255, 255, 0.05);
    --input-bg: rgba(0, 0, 0, 0.3);
}

/* RTL Support */
[dir="rtl"] {
    font-family: 'Cairo', sans-serif;
}
[dir="rtl"] .sidebar { left: auto; right: 0; border-right: none; border-left: 1px solid var(--border-color); }
[dir="rtl"] .main-content { margin-left: 0; margin-right: var(--sidebar-width); }
[dir="rtl"] .input-group i { left: auto; right: 15px; }
[dir="rtl"] .input-group input, [dir="rtl"] .input-group select { padding-left: 15px; padding-right: 45px; }

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Buttons */
button { font-family: inherit; cursor: pointer; border: none; outline: none; transition: var(--transition); border-radius: 8px; font-weight: 500; }
.btn-primary { background: var(--primary-color); color: white; padding: 12px 24px; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }
.btn-secondary { background: var(--hover-bg); color: var(--text-main); padding: 12px 24px; border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--input-bg); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: #ef4444; padding: 12px 24px; display: flex; align-items: center; gap: 8px; justify-content: center; width: 100%; }
.btn-danger:hover { background: #ef4444; color: white; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 0.9rem; font-weight: 600; }
.form-control { width: 100%; padding: 12px 15px; background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 8px; transition: var(--transition); }
.form-control:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }
.form-control option { background: var(--bg-secondary); color: var(--text-main); }

/* Views */
.view { display: none; opacity: 0; transition: opacity 0.4s ease; }
.view.active { display: block; opacity: 1; }

/* Login Screen */
#login-view { height: 100vh; align-items: center; justify-content: center; background: radial-gradient(circle at center, var(--bg-secondary), var(--bg-main)); }
#login-view.active { display: flex; }
.login-card { width: 100%; max-width: 420px; padding: 30px; text-align: center; }
.login-logo { font-size: 2.5rem; font-weight: 700; margin-bottom: 10px; letter-spacing: -1px; }
.login-logo .hk { color: var(--text-main); }
.login-logo .hamza { color: var(--primary-color); }
.login-header p { color: var(--text-muted); margin-bottom: 30px; }
.input-group { position: relative; margin-bottom: 20px; text-align: left; }
.input-group i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-group input, .input-group select { width: 100%; padding: 14px 15px 14px 45px; background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 10px; font-size: 1rem; }
.input-group input:focus, .input-group select:focus { border-color: var(--primary-color); outline: none; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; margin-top: 10px; }

/* Sidebar */
.sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-width); height: 100vh; display: flex; flex-direction: column; z-index: 100; border-radius: 0; border-right: 1px solid var(--border-color); }
.sidebar-header { padding: 30px 20px; text-align: center; }
.brand-logo { font-size: 2rem; font-weight: 700; letter-spacing: -1px; }
.brand-logo .hk { color: var(--text-main); }
.brand-logo .hamza { color: var(--primary-color); }
.current-branch-badge { display: inline-block; background: rgba(220, 38, 38, 0.15); color: var(--primary-color); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; margin-top: 10px; font-weight: 600; border: 1px solid rgba(220, 38, 38, 0.3); }
.nav-links { list-style: none; padding: 0 15px; flex: 1; overflow-y: auto; }
.nav-links li { padding: 14px 20px; margin-bottom: 5px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 15px; color: var(--text-muted); transition: var(--transition); font-weight: 600; }
.nav-links li:hover { background: var(--hover-bg); color: var(--text-main); }
.nav-links li.active { background: var(--primary-color); color: white; box-shadow: 0 4px 15px rgba(220, 38, 38, 0.2); }
.nav-links li i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); }

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

/* Topbar */
.topbar { height: var(--topbar-height); padding: 0 20px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 90; border-radius: 0; border-bottom: 1px solid var(--border-color); }
.topbar-search { position: relative; width: 300px; }
.topbar-search i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.topbar-search input { width: 100%; padding: 10px 15px 10px 40px; background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 20px; transition: var(--transition); }
.topbar-search input:focus { width: 350px; border-color: var(--primary-color); outline: none; }
[dir="rtl"] .topbar-search i { left: auto; right: 15px; }
[dir="rtl"] .topbar-search input { padding: 10px 40px 10px 15px; }

.topbar-actions { display: flex; align-items: center; gap: 20px; }
.lang-switcher { display: flex; background: var(--input-bg); border-radius: 20px; padding: 4px; border: 1px solid var(--border-color); }
.lang-btn { background: transparent; color: var(--text-muted); padding: 6px 12px; border-radius: 16px; font-size: 0.85rem; font-weight: 600; }
.lang-btn.active { background: var(--primary-color); color: white; }
.icon-btn { background: var(--hover-bg); color: var(--text-main); width: 40px; height: 40px; border-radius: 50%; position: relative; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--input-bg); }
.badge { position: absolute; top: -5px; right: -5px; background: var(--primary-color); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; font-weight: bold; border: 2px solid var(--glass-bg); }
.user-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 10px; border-radius: 20px; transition: var(--transition); }
.user-profile:hover { background: var(--hover-bg); }
.user-profile img { width: 36px; height: 36px; border-radius: 50%; }
.user-profile span { font-weight: 500; }

/* Content Wrapper */
.content-wrapper { padding: 20px 30px; flex: 1; }
.content-section { display: none; animation: fadeIn 0.4s ease; }
.content-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.page-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 20px; letter-spacing: -0.5px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.header-actions { display: flex; gap: 10px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card { padding: 20px; display: flex; align-items: center; gap: 15px; transition: var(--transition); cursor: pointer; }
.stat-card:hover { transform: translateY(-5px); box-shadow: 0 12px 40px rgba(0,0,0,0.4); }
.stat-icon { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.stat-info h3 { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; margin-bottom: 5px; }
.stat-info h2 { font-size: 1.8rem; font-weight: 700; }

/* Charts */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.chart-card { padding: 20px; }
.chart-card h3 { margin-bottom: 15px; font-weight: 600; }
.chart-card canvas { width: 100% !important; height: 260px !important; }

/* Tables */
.table-container { padding: 20px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
[dir="rtl"] .data-table { text-align: right; }
.data-table th { padding: 15px; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table td { padding: 15px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: var(--hover-bg); }

/* Badges */
.status-badge { padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; display: inline-block; }
.status-success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.status-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.status-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Action Buttons */
.action-btn { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; margin-right: 5px; transition: var(--transition); }
.action-edit { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.action-edit:hover { background: #6366f1; color: white; }
.action-delete { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.action-delete:hover { background: #ef4444; color: white; }
.action-view { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.action-view:hover { background: #10b981; color: white; }

/* Vehicles Grid */
.vehicules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.vehicule-card { overflow: hidden; display: flex; flex-direction: column; transition: var(--transition); cursor: pointer; padding: 0; }
.vehicule-card:hover { transform: translateY(-5px); box-shadow: 0 15px 40px rgba(0,0,0,0.4); }
.vehicule-img { width: 100%; height: 200px; object-fit: cover; border-bottom: 1px solid var(--border-color); }
.vehicule-info { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.vehicule-info h3 { font-size: 1.1rem; font-weight: 600; }
.vehicule-price { font-size: 1.4rem; font-weight: 700; color: var(--primary-color); }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: var(--transition); }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 16px; width: 100%; max-width: 500px; padding: 30px; transform: translateY(20px); transition: var(--transition); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); max-height: 90vh; overflow-y: auto;}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.modal-header h3 { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.modal-close { background: transparent; color: var(--text-muted); font-size: 1.2rem; }
.modal-close:hover { color: var(--primary-color); }
.modal-actions { display: flex; justify-content: flex-end; gap: 15px; margin-top: 30px; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.settings-card { padding: 24px; }
.settings-card h3 { margin-bottom: 20px; font-weight: 600; }
.theme-options { display: flex; flex-direction: column; gap: 15px; }
.theme-btn { display: flex; align-items: center; gap: 15px; background: var(--input-bg); padding: 15px; color: var(--text-main); border: 1px solid var(--border-color); width: 100%; text-align: left; border-radius: 8px; }
[dir="rtl"] .theme-btn { text-align: right; }
.theme-btn:hover { background: var(--hover-bg); border-color: var(--text-muted); }
.theme-btn.active { border-color: var(--primary-color); background: rgba(220, 38, 38, 0.05); }
.theme-btn span:first-child { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-color); display: inline-block; }

/* Toast */
.toast { position: fixed; bottom: 30px; right: 30px; color: white; padding: 15px 25px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); z-index: 2000; animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards; font-weight: 500; }
[dir="rtl"] .toast { right: auto; left: 30px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Map */
.custom-map-icon i { filter: drop-shadow(0 0 6px rgba(0,0,0,0.5)); }

/* Beneficiary Item (Wholesale Orders) */
.beneficiary-item { background: var(--input-bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 15px; position: relative; }
.remove-beneficiary { position: absolute; top: 10px; right: 10px; background: rgba(239, 68, 68, 0.1); color: #ef4444; width: 25px; height: 25px; border-radius: 4px; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; }
[dir="rtl"] .remove-beneficiary { right: auto; left: 10px; }
.remove-beneficiary:hover { background: #ef4444; color: white; }

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .main-content { margin-left: 0 !important; margin-right: 0 !important; }
    .topbar { padding: 0 20px; }
    .content-wrapper { padding: 20px; }
}
