/* =====================================================
   Driver Mobile App Styles
   ===================================================== */

:root {
    --driver-color: #667eea;
    --driver-color-light: #667eea33;
    --driver-color-dark: #667eeaCC;
}

* {
    font-family: 'Sarabun', sans-serif;
}

body {
    background-color: #f5f5f5;
    padding-bottom: 80px;
    -webkit-tap-highlight-color: transparent;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--driver-color) 0%, var(--driver-color-dark) 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h5 {
    margin: 0;
    font-weight: 600;
    font-size: 20px;
}

.header small {
    opacity: 0.9;
    font-size: 14px;
}

.header .status-indicator {
    width: 10px;
    height: 10px;
    background: #4CAF50;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Content Sections */
.content-section {
    display: none;
    padding: 20px 15px;
    animation: fadeIn 0.3s ease-in;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards */
.info-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: none;
    transition: all 0.3s;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.info-card h6 {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
    font-weight: 600;
}

.info-card .value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.info-card .unit {
    font-size: 14px;
    color: #999;
    font-weight: 400;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-card i {
    font-size: 30px;
    color: var(--driver-color);
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: #333;
}

.stat-card .label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Route Card */
.route-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.route-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: var(--driver-color);
}

.route-card .route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.route-card .route-title {
    font-weight: 600;
    color: #333;
    font-size: 16px;
}

.route-card .route-point {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
    padding: 5px;
    border-radius: 8px;
}

.route-card .route-point:hover {
    background: var(--driver-color-light);
}

.route-card .route-point:last-child {
    margin-bottom: 0;
}

.route-card .route-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 18px;
    flex-shrink: 0;
}

.route-card .route-icon.start {
    background: #4CAF50;
    color: white;
}

.route-card .route-icon.waypoint {
    background: #2196F3;
    color: white;
}

.route-card .route-icon.end {
    background: #F44336;
    color: white;
}

.route-card .route-line {
    position: absolute;
    left: 20px;
    top: 40px;
    bottom: 0;
    width: 2px;
    background: #e0e0e0;
    z-index: -1;
}

.route-card .route-info {
    flex: 1;
}

.route-card .route-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.route-card .route-address {
    font-size: 14px;
    color: #666;
}

.route-card .route-icon.checked {
    background: #4CAF50 !important;
    position: relative;
}

.route-card .route-icon.checked i {
    visibility: hidden;
}

.route-card .route-icon.checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    font-size: 18px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.checkin-status {
    font-size: 12px;
    color: #4CAF50;
    margin-top: 5px;
    font-weight: 600;
}

.checkin-status i {
    margin-right: 5px;
}

/* Route Summary */
.route-summary {
    background: var(--driver-color-light);
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.route-summary-item {
    text-align: center;
}

.route-summary-item .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--driver-color);
}

.route-summary-item .label {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.route-card .route-point.checked {
    cursor: default;
    opacity: 0.8;
}

.route-card .route-point.checked:hover {
    background: transparent;
}

/* Task Card */
.task-card {
    background: white;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #2196F3;
    transition: all 0.3s;
    cursor: pointer;
}

.task-card:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.task-card.priority-low {
    border-left-color: #4CAF50;
}

.task-card.priority-normal {
    border-left-color: #2196F3;
}

.task-card.priority-high {
    border-left-color: #FF9800;
}

.task-card.priority-urgent {
    border-left-color: #F44336;
}

.task-card .task-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.task-card .task-title {
    font-weight: 600;
    color: #333;
    font-size: 16px;
    margin-bottom: 5px;
}

.task-card .task-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #666;
}

.task-card .task-meta i {
    margin-right: 5px;
    color: #999;
}

/* Checkin Button */
.checkin-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    width: 100%;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.checkin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.checkin-btn:active {
    transform: translateY(0);
}

.checkin-btn i {
    font-size: 24px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.quick-action-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    text-decoration: none;
    color: #333;
    transition: all 0.3s;
}

.quick-action-btn:hover {
    border-color: var(--driver-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    color: var(--driver-color);
}

.quick-action-btn i {
    font-size: 30px;
    margin-bottom: 8px;
    display: block;
    color: var(--driver-color);
}

.quick-action-btn span {
    font-weight: 600;
    font-size: 14px;
}

/* Expense Form */
.expense-form {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    padding: 12px 15px;
    font-size: 16px;
    transition: all 0.3s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--driver-color);
    box-shadow: 0 0 0 0.2rem var(--driver-color-light);
}

.btn-primary {
    background: var(--driver-color);
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--driver-color-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px 0;
    z-index: 1000;
}

.bottom-nav .nav-item {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: #666;
    position: relative;
}

.bottom-nav .nav-item.active {
    color: var(--driver-color);
}

.bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--driver-color);
    border-radius: 0 0 3px 3px;
}

.bottom-nav .nav-item i {
    font-size: 24px;
    display: block;
    margin-bottom: 5px;
}

.bottom-nav .nav-item span {
    font-size: 12px;
    font-weight: 600;
}

.bottom-nav .badge {
    position: absolute;
    top: 5px;
    right: calc(50% - 20px);
    background: #F44336;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    min-width: 18px;
}

/* Checkpoint List */
.checkpoint-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    transition: all 0.3s;
}

.checkpoint-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.checkpoint-item .icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--driver-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
}

.checkpoint-item .info {
    flex: 1;
}

.checkpoint-item .location {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.checkpoint-item .time {
    font-size: 13px;
    color: #666;
}

.checkpoint-item .type {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--driver-color-light);
    color: var(--driver-color);
    border-radius: 10px;
    margin-left: 10px;
}

/* Expense List */
.expense-item {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expense-item .expense-info {
    flex: 1;
}

.expense-item .category {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.expense-item .description {
    font-size: 14px;
    color: #666;
}

.expense-item .amount {
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-overlay.show {
    display: flex;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
    border-color: var(--driver-color);
    border-right-color: transparent;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
    font-size: 16px;
}

/* Route Map */
.route-map-container {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
}

#routeMap {
    height: 400px;
    width: 100%;
    border-radius: 10px;
    z-index: 1;
}

.map-controls {
    position: absolute;
    top: 25px;
    right: 25px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.map-controls .btn {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

/* Map Markers */
.map-checkin-btn {
    background: var(--driver-color) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    font-size: 14px !important;
}

.current-location-marker {
    width: 20px;
    height: 20px;
    background: #4285F4;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.current-location-marker::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    border: 2px solid #4285F4;
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 2s infinite;
}

.route-marker {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.route-marker.start {
    background: #4CAF50;
}

.route-marker.waypoint {
    background: #2196F3;
}

.route-marker.end {
    background: #F44336;
}

.route-marker.checkin {
    background: #4CAF50;
}

.route-marker.checkin i {
    font-size: 16px;
}

/* Directions Panel */
.directions-panel {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.directions-panel.show {
    display: block;
}

.directions-panel h6 {
    font-weight: 700;
    color: #333;
    margin-bottom: 15px;
    position: sticky;
    top: 0;
    background: white;
    padding: 5px 0;
}

.direction-step {
    padding: 10px;
    border-left: 3px solid #e0e0e0;
    margin-bottom: 10px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.direction-step:hover {
    background: #f8f9fa;
    border-left-color: var(--driver-color);
}

.direction-step .step-number {
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #666;
}

.direction-step.active .step-number {
    background: var(--driver-color);
    border-color: var(--driver-color);
    color: white;
}

.direction-step .instruction {
    font-size: 14px;
    color: #333;
    margin-bottom: 2px;
}

.direction-step .distance {
    font-size: 12px;
    color: #666;
}

/* Hide Leaflet Routing Machine Controls */
.leaflet-routing-container {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 375px) {
    .header {
        padding: 15px;
    }

    .header h5 {
        font-size: 18px;
    }

    .content-section {
        padding: 15px 10px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card {
        padding: 15px;
    }

    .quick-actions {
        gap: 10px;
    }

    #routeMap {
        height: 300px;
    }

    .map-controls {
        top: 15px;
        right: 15px;
    }

    .map-controls .btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* iOS Safe Area */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: calc(20px + env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #fff;
    }

    .info-card,
    .stat-card,
    .route-card,
    .task-card,
    .expense-form,
    .bottom-nav,
    .checkpoint-item,
    .expense-item,
    .directions-panel {
        background: #2a2a2a;
        color: #fff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }

    .form-control,
    .form-select {
        background: #333;
        border-color: #444;
        color: #fff;
    }

    .form-control:focus,
    .form-select:focus {
        background: #333;
        border-color: var(--driver-color);
        color: #fff;
    }

    .checkpoint-item {
        background: #333;
    }

    .quick-action-btn {
        background: #2a2a2a;
        border-color: #444;
        color: #fff;
    }

    .quick-action-btn:hover {
        background: #333;
        color: var(--driver-color);
    }

    .direction-step {
        border-left-color: #444;
    }

    .direction-step:hover {
        background: #333;
    }
}

/* Checkpoint Notification */
.checkpoint-notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--driver-color);
    color: white;
    padding: 15px 20px;
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    animation: slideUp 0.3s ease-out;
}

.checkpoint-notification i {
    font-size: 20px;
}

.checkpoint-notification button {
    background: white;
    color: var(--driver-color);
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 10px;
    cursor: pointer;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Update route point checked status */
.route-card .route-point.checked {
    position: relative;
    opacity: 0.8;
}

.route-card .route-point.checked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(76, 175, 80, 0.05);
    border-radius: 8px;
    pointer-events: none;
}

/* Animate icon change */
.route-card .route-icon.checked {
    animation: checkmarkPop 0.3s ease-out;
}

@keyframes checkmarkPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Popup styling */
.leaflet-popup-content {
    margin: 13px 19px;
    line-height: 1.5;
}

.leaflet-popup-content p {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
}

.leaflet-popup-content .btn {
    font-size: 14px;
    padding: 6px 12px;
}

.leaflet-popup-content .btn i {
    margin-right: 5px;
}

/* Progress Bar */
.route-progress {
    margin-top: 15px;
}

.route-progress .progress {
    height: 8px;
    background-color: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.route-progress .progress-bar {
    background-color: #4CAF50;
    transition: width 0.3s ease;
}