/* ====== بيورما - النمط الرسمي ====== */
:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --accent: #0f3460;
    --accent-light: #e94560;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #666666;
    --border: #e0e0e0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    line-height: 1.6;
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #999; }

/* ====== LOGIN ====== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    padding: 20px;
}

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

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

.login-logo img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 15px;
}

.login-logo h1 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 5px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

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

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

.form-group label i {
    margin-left: 5px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.searchable-select input {
    margin-bottom: 5px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* ====== BUTTONS ====== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--info); color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-info { background: var(--info); color: white; }
.btn-secondary { background: #6b7280; color: white; }
.btn-whatsapp { background: #25d366; color: white; }
.btn-whatsapp:hover { background: #1fb855; }
.btn-edit { background: #8b5cf6; color: white; }
.btn-edit:hover { background: #7c3aed; }

.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-logout { background: transparent; color: var(--danger); border: 1px solid var(--danger); width: 100%; justify-content: center; margin-top: 10px; }
.btn-logout:hover { background: var(--danger); color: white; }

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
}

.btn-icon:hover { background: #f0f0f0; }
.btn-icon.btn-edit { background: #ede9fe; color: #7c3aed; }
.btn-icon.btn-danger { background: #fef2f2; color: #dc2626; }
.btn-icon.btn-info { background: #eff6ff; color: #2563eb; }
.btn-icon.btn-whatsapp { background: #dcfce7; color: #16a34a; }
.btn-icon.btn-sm { width: 28px; height: 28px; font-size: 12px; }

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ====== DASHBOARD LAYOUT ====== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--primary);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 20px;
    margin-bottom: 5px;
}

.user-role {
    font-size: 12px;
    background: rgba(255,255,255,0.15);
    padding: 3px 12px;
    border-radius: 20px;
    display: inline-block;
}

.sidebar-menu {
    flex: 1;
    padding: 15px 10px;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 14px;
}

.menu-item:hover { background: rgba(255,255,255,0.1); color: white; }
.menu-item.active { background: var(--info); color: white; font-weight: 600; }

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    margin-bottom: 5px;
}

.user-info i { font-size: 24px; }

.main-content {
    flex: 1;
    margin-right: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h3 {
    flex: 1;
    font-size: 18px;
    color: var(--text);
}

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

.notification-btn {
    position: relative;
}

.badge {
    position: absolute;
    top: -2px;
    left: -2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content-area {
    flex: 1;
    padding: 25px;
}

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

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-info h3 { font-size: 24px; color: var(--text); }
.stat-info p { font-size: 13px; color: var(--text-secondary); }

/* ====== CARDS ====== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

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

.card-body { padding: 20px; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.mt-4 { margin-top: 25px; }
.mb-3 { margin-bottom: 15px; }

.amount-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.amount-row:last-child { border: none; }
.amount-row strong { color: var(--info); }

/* ====== TABLE ====== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h2 {
    font-size: 22px;
    color: var(--text);
}

.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

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

.data-table th {
    background: var(--primary);
    color: white;
    padding: 14px 16px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}

.data-table tr:hover { background: #f9fafb; }
.data-table tr:last-child td { border: none; }

.actions {
    display: flex;
    gap: 5px;
    white-space: nowrap;
}

.phone-actions {
    display: flex;
    align-items: center;
    gap: 5px;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); font-size: 13px; }
.text-danger { color: var(--danger); }

/* ====== FILTERS ====== */
.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input {
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--card-bg);
    min-width: 160px;
}

.filters-bar select:focus,
.filters-bar input:focus {
    outline: none;
    border-color: var(--info);
}

/* ====== STATUS BADGES ====== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-new { background: #dbeafe; color: #1e40af; }
.status-accepted { background: #dcfce7; color: #166534; }
.status-enroute { background: #fef3c7; color: #92400e; }
.status-onsite { background: #ede9fe; color: #5b21b6; }
.status-completed { background: #d1fae5; color: #065f46; }

.order-type-badge {
    background: #f3f4f6;
    color: var(--text);
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
}

.distance-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

/* ====== TASK CARDS ====== */
.tasks-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 15px;
}

.task-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

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

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

.task-card-header h4 { font-size: 16px; color: var(--text); }

.task-card-body {
    padding: 15px 18px;
}

.task-card-body p {
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.task-card-body p i { color: var(--text-secondary); width: 16px; }

.task-notes {
    background: #f9fafb;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px !important;
    color: var(--text-secondary) !important;
}

.task-card-actions {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.reminder-overdue {
    border-right: 4px solid var(--danger);
}

.section-title {
    margin: 25px 0 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ====== TABS ====== */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 5px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.tab.active { background: var(--info); color: white; }
.tab:hover:not(.active) { background: #f3f4f6; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ====== TASK DETAILS ====== */
.task-details .detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 15px;
    align-items: center;
}

.task-details .detail-row:last-child { border: none; }
.task-details .detail-row label { font-weight: 600; min-width: 120px; color: var(--text-secondary); }
.task-details .detail-row span { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.completion-img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.photo-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    object-fit: contain;
}

/* ====== NOTIFICATIONS ====== */
.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 15px;
    display: flex;
    gap: 15px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.notification-item:hover { box-shadow: var(--shadow-lg); }
.notification-item.unread { border-right: 4px solid var(--info); background: #f0f7ff; }

.notif-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--info);
    flex-shrink: 0;
}

.notif-content { flex: 1; }
.notif-content strong { display: block; margin-bottom: 3px; color: var(--text); }
.notif-content p { font-size: 13px; color: var(--text-secondary); margin: 0; }
.notif-content small { color: #999; font-size: 11px; }

/* ====== RATINGS ====== */
.ratings-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.rating-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.rating-stars { font-size: 20px; margin-bottom: 8px; }
.rating-client { font-weight: 600; color: var(--text); }
.rating-comment { font-style: italic; color: var(--text-secondary); margin: 5px 0; }

/* ====== RATING PAGE ====== */
.rating-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    padding: 20px;
}

.rating-card-page {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.rating-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
}

.rating-card-page h1 { color: var(--primary); font-size: 28px; margin-bottom: 5px; }
.rating-card-page h2 { color: var(--text-secondary); font-size: 18px; margin-bottom: 15px; }
.rating-card-page p { color: var(--text-secondary); margin-bottom: 20px; }

.stars-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    font-size: 36px;
}

.stars-selector .fa-star {
    color: #ddd;
    cursor: pointer;
    transition: var(--transition);
}

.stars-selector .fa-star:hover,
.stars-selector .fa-star.selected {
    color: #f59e0b;
    transform: scale(1.2);
}

.success-msg { padding: 20px; }
.success-msg i { font-size: 50px; color: var(--success); margin-bottom: 10px; }
.success-msg h3 { color: var(--text); margin-bottom: 5px; }

/* ====== PERMISSIONS ====== */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.perm-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: #f9fafb;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.perm-toggle:hover { background: #f0f0f0; }

.perm-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--info);
}

/* ====== MODAL ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.show { opacity: 1; }

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.show .modal { transform: translateY(0); }

.modal-lg { max-width: 700px; }

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { background: #f0f0f0; color: var(--text); }

.modal-body { padding: 22px; }

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

.empty-state i { font-size: 50px; margin-bottom: 15px; opacity: 0.5; }
.empty-state p { font-size: 16px; }

/* ====== LOADING ====== */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
    font-size: 18px;
}

.loading i { margin-left: 8px; }

/* ====== RECENT TASK ====== */
.recent-task {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.recent-task:last-child { border: none; }

/* ====== TOAST ====== */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateX(-100%);
    opacity: 0;
    transition: all 0.3s;
    box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .menu-toggle { display: block; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tasks-list { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; }
    .filters-bar select, .filters-bar input { min-width: auto; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .data-table th, .data-table td { padding: 10px 8px; font-size: 12px; }
    .modal { margin: 10px; max-height: 95vh; }
    .content-area { padding: 15px; }
    .topbar { padding: 12px 15px; }
    .permissions-grid { grid-template-columns: 1fr; }
    .ratings-list { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 25px; }
    .task-card-header { flex-direction: column; align-items: flex-start; }
}
