/* ============================================================
   Driver Pages – Redesigned UI (Admin Dashboard Reference)
   Fonts: DM Sans (body) + Outfit (headings)
   Primary: #2563eb / Slate palette
   ============================================================ */

/* --- CSS Variables ------------------------------------------ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-lighter: #60a5fa;
    --bg-body: #f1f5f9;
    --bg-white: #ffffff;
    --text-dark: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #2563eb;
    --info-light: #eff6ff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 14px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
    --shadow-md: 0 1px 3px rgba(15,23,42,0.06), 0 0 0 1px rgba(15,23,42,0.04);
    --shadow-lg: 0 4px 16px rgba(15,23,42,0.08);
    --shadow-xl: 0 8px 24px rgba(15,23,42,0.12);
    --font-main: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', 'DM Sans', sans-serif;
    --transition: all 0.15s ease;
}

/* --- Base --------------------------------------------------- */
body {
    font-family: var(--font-main);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.5;
}

body, div, p, span {
    font-family: var(--font-main);
}

h1, h2, h3, h4, h5, h6,
.modal-title {
    font-family: var(--font-heading);
}

/* --- Navbar ------------------------------------------------- */
.nav-bar-custom {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 8px 0;
}

.nav-logo-img {
    height: 34px;
    width: auto;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* --- Driver Name -------------------------------------------- */
.driver-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--text-dark);
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

/* --- Rating Hero Card --------------------------------------- */
.rating-hero-card {
    text-align: center;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 24px 32px;
    max-width: 260px;
    border-top: 3px solid var(--warning);
}

.rating-hero-value {
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: 800;
    color: var(--warning);
    line-height: 1;
    margin-bottom: 4px;
}

.rating-hero-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rating-hero-stars {
    color: var(--warning);
    font-size: 1.1rem;
}

.rating-hero-stars i {
    margin: 0 1px;
}

/* --- Sort Bar ----------------------------------------------- */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sort-bar-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.sort-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sort-pill {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-main);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.sort-pill:hover {
    border-color: var(--primary-lighter);
    color: var(--primary);
    background: var(--info-light);
}

.sort-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* --- Reviews Grid ------------------------------------------- */
.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

/* --- Review Card -------------------------------------------- */
.review-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.review-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.review-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.review-rating-badge {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--warning);
    background: var(--warning-light);
    padding: 4px 14px;
    border-radius: var(--radius-md);
    min-width: 48px;
    text-align: center;
    line-height: 1.3;
}

.review-meta {
    display: flex;
    flex-direction: column;
}

.review-author {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dark);
}

.review-time {
    font-size: 0.72rem;
    color: var(--text-light);
}

.review-content {
    font-size: 0.84rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    line-height: 1.55;
    flex: 1;
}

/* --- Skill Ratings ------------------------------------------ */
.review-skills {
    border-top: 1px solid var(--border-light);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.review-skill-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.review-skill-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.review-skill-stars {
    display: flex;
    gap: 2px;
    font-size: 0.78rem;
}

.star-filled {
    color: var(--warning);
}

.star-empty {
    color: #e2e8f0;
}

/* --- Empty State -------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    background: var(--info-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.75rem;
    color: var(--primary);
}

.empty-state-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.empty-state-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- Buttons ------------------------------------------------ */
.btn {
    font-family: var(--font-main);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

.btn-primary,
.btn-info {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-info:hover {
    background: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-dark {
    background: var(--bg-body) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
}

.btn-dark:hover {
    background: #e2e8f0 !important;
    color: var(--text-dark) !important;
}

.btn-outline-secondary {
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--bg-body);
    color: var(--text-dark);
    border-color: var(--text-light);
}

.btn-danger {
    background: var(--danger) !important;
    border-color: var(--danger) !important;
}

.btn-danger:hover {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
}

/* --- Form Controls ------------------------------------------ */
.form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-bottom: 0.375rem;
}

/* --- Tables ------------------------------------------------- */
.table {
    font-family: var(--font-main);
    font-size: 0.875rem;
    margin-bottom: 0;
}

.table thead th {
    background: var(--bg-body);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    border-top: none;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: #fafbfc;
}

/* --- Modal Styling ------------------------------------------ */
.modal-content {
    border: none !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-xl) !important;
    overflow: hidden;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    background: var(--bg-white);
}

.modal-header .modal-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dark);
}

.modal-body {
    padding: 1.25rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.modal-footer {
    border-top: 1px solid var(--border-color) !important;
    padding: 0.875rem 1.25rem !important;
    background: var(--bg-white);
    gap: 8px;
}

/* --- IFTA Modal Specifics ----------------------------------- */
.IFTAReport .modal-header {
    background: linear-gradient(135deg, var(--primary), #06b6d4);
    border-bottom: none;
}

.IFTAReport .modal-header .modal-title {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.IFTAReport .modal-header .btn-close,
.IFTAReport .modal-header .close {
    color: #fff;
    opacity: 0.8;
    filter: brightness(0) invert(1);
}

/* Duration radio pills */
.duration-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.duration-pill:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.duration-pill:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.duration-pill:has(input:checked),
.duration-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.duration-pill input[type="radio"] {
    display: none;
}

/* Instructions list */
.ifta-instructions {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.ifta-instructions li {
    margin-bottom: 6px;
}

.ifta-instructions a {
    color: var(--primary);
    font-weight: 500;
}

/* --- Select2 ------------------------------------------------ */
.select2 {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    padding: 4px 0 !important;
}

.select2,
.select2-results {
    font-size: 0.85rem !important;
    font-family: var(--font-main) !important;
}

.select2-container--default .select2-selection--single {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    height: 38px !important;
    padding: 4px 8px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px !important;
    color: var(--text-primary) !important;
}

.select2-dropdown {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--info-light) !important;
    color: var(--primary) !important;
}

/* --- SweetAlert2 Overrides ---------------------------------- */
.swal2-popup {
    font-family: var(--font-main) !important;
    border-radius: var(--radius-lg) !important;
}

.swal2-title {
    font-family: var(--font-heading) !important;
    font-weight: 600 !important;
    color: var(--text-dark) !important;
}

.swal2-styled.swal2-confirm {
    background-color: var(--primary) !important;
    border-radius: var(--radius-md) !important;
    font-weight: 500 !important;
    padding: 0.5rem 1.5rem !important;
}

.swal2-styled.swal2-confirm:hover {
    background-color: var(--primary-dark) !important;
}

/* --- Animations --------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Scrollbar ---------------------------------------------- */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Skeleton Loading --------------------------------------- */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
}

.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-100 { width: 100%; }

.skeleton-badge {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.skeleton-hero {
    text-align: center;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 24px 32px;
    max-width: 260px;
    margin: 0 auto;
    border-top: 3px solid var(--border-color);
}

.skeleton-hero .skeleton-rating {
    width: 80px;
    height: 48px;
    margin: 0 auto 8px;
    border-radius: var(--radius-md);
}

.skeleton-hero .skeleton-label {
    width: 100px;
    height: 10px;
    margin: 0 auto 12px;
    border-radius: 6px;
}

.skeleton-hero .skeleton-stars {
    width: 120px;
    height: 16px;
    margin: 0 auto;
    border-radius: 6px;
}

/* --- Stagger Animation -------------------------------------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.review-card.stagger-in {
    opacity: 0;
    animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.sort-pill {
    position: relative;
    overflow: hidden;
}

.sort-pill .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: rippleEffect 0.5s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to { transform: scale(4); opacity: 0; }
}

/* --- Error State -------------------------------------------- */
.error-state {
    text-align: center;
    padding: 60px 20px;
}

.error-state-icon {
    width: 72px;
    height: 72px;
    background: var(--danger-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 1.75rem;
    color: var(--danger);
}

.error-state-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.error-state-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-main);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
}

.btn-retry:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* --- Stat Summary Bar --------------------------------------- */
.stat-summary-bar {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.stat-overview {
    text-align: center;
    min-width: 100px;
    flex-shrink: 0;
}

.stat-overview-rating {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--warning);
    line-height: 1;
}

.stat-overview-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-breakdown {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.breakdown-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.breakdown-label {
    width: 14px;
    text-align: right;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.breakdown-bar {
    flex: 1;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.breakdown-bar-fill {
    height: 100%;
    background: var(--warning);
    border-radius: 4px;
    width: 0;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.breakdown-count {
    width: 24px;
    font-size: 0.7rem;
    color: var(--text-light);
    flex-shrink: 0;
}

/* --- Search Input ------------------------------------------- */
.review-search-wrapper {
    position: relative;
    max-width: 320px;
    margin-bottom: 16px;
}

.review-search-wrapper .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.85rem;
    pointer-events: none;
}

.review-search-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: var(--transition);
}

.review-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.review-search-input::placeholder {
    color: var(--text-light);
}

.review-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.review-no-results i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-light);
}

/* --- Driver Not Found State --------------------------------- */
.driver-not-found {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.driver-not-found.d-none {
    display: none !important;
}

.driver-not-found-card {
    text-align: center;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px 48px;
    max-width: 420px;
    width: 90%;
}

.driver-not-found-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
}

.driver-not-found-icon svg {
    width: 100%;
    height: 100%;
}

.driver-not-found-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.driver-not-found-text {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

.driver-not-found-hint {
    font-size: 0.78rem;
    color: var(--text-light);
    background: var(--bg-body);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 0;
}

/* --- Enhanced Empty State SVG ------------------------------- */
.empty-state-svg {
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
}

.empty-state-svg svg {
    width: 100%;
    height: 100%;
}

/* --- Toast Notifications (Driver) --------------------------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-notification {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: var(--text-primary);
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid var(--primary);
    max-width: 340px;
}

.toast-notification.toast-success { border-left-color: var(--success); }
.toast-notification.toast-error   { border-left-color: var(--danger); }
.toast-notification.toast-warning { border-left-color: var(--warning); }

.toast-notification.toast-out {
    animation: toastSlideOut 0.25s ease-in forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* --- Responsive --------------------------------------------- */
@media (max-width: 576px) {
    .reviews-grid {
        grid-template-columns: 1fr;
    }

    .sort-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .rating-hero-card {
        max-width: 100%;
    }

    .driver-name {
        font-size: 1.2rem;
    }

    .review-rating-badge {
        font-size: 1.3rem;
        padding: 4px 10px;
    }
}
