/* ============================================================
   Winshy Admin Panel — Design System
   Matches the mobile app's visual identity
   ============================================================ */

/* ── CSS Variables ── */
:root {
    /* Primary (Mobile app: #FAA41A) */
    --primary: #FAA41A;
    --primary-dark: #E8930F;
    --primary-light: #FFF3DC;
    --primary-gradient: linear-gradient(135deg, #FAA41A 0%, #FC6300 100%);

    /* Service Colors */
    --roadside: #FC6300;
    --furniture: #155DFC;
    --goods: #0FAB49;
    --cranes: #9810FA;

    /* Neutrals */
    --dark: #050811;
    --dark-secondary: #0A0E19;
    --surface: #F9FAFB;
    --card: #FFFFFF;
    --input-bg: #F5F5F5;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --text-on-primary: #FFFFFF;

    /* Status */
    --success: #10B981;
    --success-bg: #D1FAE5;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    --error: #DC2626;
    --error-bg: #FEE2E2;
    --info: #2563EB;
    --info-bg: #E0EDFF;

    /* Borders */
    --border: #E5E7EB;
    --border-light: #F3F4F6;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-bg: var(--dark);
    --topbar-height: 64px;

    /* Radius */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

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

html { font-size: 16px; }

body {
    font-family: 'Cairo', sans-serif;
    background: var(--surface);
    color: var(--text-primary);
    direction: rtl;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.25rem;
    color: white;
}

.logo-text {
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: inherit;
}

.nav-item:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.nav-item.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(250, 164, 26, 0.3);
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.logout-btn {
    color: rgba(255,255,255,0.5) !important;
}
.logout-btn:hover {
    color: var(--error) !important;
    background: rgba(220, 38, 38, 0.1) !important;
}

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

/* ── Topbar ── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 500;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
}

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

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

.admin-info {
    text-align: left;
    display: flex;
    flex-direction: column;
}

.admin-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.admin-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.25rem;
}

/* ── Content ── */
.content {
    flex: 1;
    padding: 24px;
}

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    color: #065F46;
}

.alert-error {
    background: var(--error-bg);
    color: #991B1B;
}

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

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

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-info h3 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-info .stat-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.blue { background: #DBEAFE; color: var(--furniture); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: #F3E8FF; color: var(--cranes); }

/* ── Cards ── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
}

.card-body {
    padding: 24px;
}

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
}

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

thead th {
    padding: 12px 16px;
    text-align: right;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

tbody tr:hover {
    background: rgba(250, 164, 26, 0.03);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending { background: var(--warning-bg); color: #92400E; }
.badge-assigned { background: var(--info-bg); color: #1E40AF; }
.badge-on_the_way { background: #FFF7ED; color: #C2410C; }
.badge-completed { background: var(--success-bg); color: #065F46; }
.badge-cancelled { background: var(--error-bg); color: #991B1B; }

.badge-roadside { background: #FFF3E0; color: var(--roadside); }
.badge-furniture { background: #E8F0FE; color: var(--furniture); }
.badge-goods { background: #E8F5E9; color: var(--goods); }
.badge-cranes { background: #F3E8FF; color: var(--cranes); }

.badge-available { background: var(--success-bg); color: #065F46; }
.badge-busy { background: var(--warning-bg); color: #92400E; }
.badge-offline { background: #F3F4F6; color: #6B7280; }

/* ── Service Icon ── */
.service-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.service-icon.roadside { background: var(--roadside); }
.service-icon.furniture { background: var(--furniture); }
.service-icon.goods { background: var(--goods); }
.service-icon.cranes { background: var(--cranes); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(250, 164, 26, 0.3);
}

.btn-secondary {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: #E5E7EB;
}

.btn-danger {
    background: var(--error);
    color: white;
}
.btn-danger:hover {
    background: #B91C1C;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* ── Forms ── */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: 'Cairo', sans-serif;
    background: white;
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

select.form-control {
    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='%234B5563' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
    padding-left: 36px;
}

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

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

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

.filters .form-group {
    margin-bottom: 0;
    min-width: 160px;
}

.filters .form-control {
    height: 40px;
}

/* ── Pagination ── */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    gap: 4px;
}

.pagination-wrapper .page-link,
.pagination-wrapper a,
.pagination-wrapper span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.pagination-wrapper a:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.pagination-wrapper .active span,
.pagination-wrapper span[aria-current="page"] {
    background: var(--primary);
    color: white;
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.95rem;
    margin-top: 8px;
}

/* ── Detail Grid ── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item .label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}

.detail-item .value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal {
    background: var(--card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    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-light);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

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

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close {
        display: block;
    }
    .main-wrapper {
        margin-right: 0;
    }
    .menu-toggle {
        display: block;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .filters {
        flex-direction: column;
    }
    .topbar {
        padding: 0 16px;
    }
}

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

/* ── Auth Pages ── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    padding: 20px;
}

.auth-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card .logo .logo-icon {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
    margin: 0 auto 12px;
    border-radius: var(--radius);
}

.auth-card .logo h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.auth-card .logo p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.auth-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 1rem;
}

/* ── Utility ── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
