/**
 * Driver Portal - Mobile-First CSS
 * Lightweight (<10KB), optimized for mobile devices
 */

/* ============================================
   RESET & BASE STYLES
   ============================================ */

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

:root {
    /* Colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --warning-color: #f59e0b;
    --bg-color: #f3f4f6;
    --surface-color: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #d1d5db;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Typography */
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;

    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.login-header .subtitle {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
}

/* ============================================
   FORM STYLES
   ============================================ */

.login-form {
    background: var(--surface-color);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.form-control {
    width: 100%;
    padding: 0.875rem var(--spacing-md);
    font-size: var(--font-size-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    /* Large tap targets for mobile */
    min-height: 48px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

.form-hint {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

/* Checkbox Group */
.checkbox-group {
    margin-bottom: var(--spacing-lg);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label span {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.btn {
    display: inline-block;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 0.875rem var(--spacing-lg);
    font-size: var(--font-size-lg);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-large {
    width: 100%;
    min-height: 52px;
    font-size: var(--font-size-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   ALERT STYLES
   ============================================ */

.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--error-color);
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning-color);
}

/* ============================================
   FOOTER STYLES
   ============================================ */

.login-footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
}

.help-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.version-info {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* Small devices (phones in portrait) */
@media (max-width: 576px) {
    .login-page {
        padding: var(--spacing-md);
    }

    .login-form {
        padding: var(--spacing-lg);
    }

    .login-header h1 {
        font-size: var(--font-size-xl);
    }
}

/* Larger devices */
@media (min-width: 768px) {
    .login-container {
        max-width: 440px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   DRIVER PAGES STYLES
   ============================================ */

.driver-page {
    background-color: var(--bg-color);
    min-height: 100vh;
    padding-bottom: var(--spacing-xl);
}

.page-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

/* Page Header */
.page-header {
    background: var(--surface-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.page-header h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.page-header p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.driver-name {
    font-weight: 600;
    color: var(--text-primary);
}

/* Back Button */
.btn-back {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    padding: var(--spacing-sm);
}

/* Form Card */
.form-card {
    background: var(--surface-color);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.form-card h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

/* ============================================
   FILTER TABS
   ============================================ */

.filter-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    background: var(--surface-color);
    padding: var(--spacing-sm);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.filter-tab {
    flex: 1;
    text-align: center;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.15s ease;
}

.filter-tab.active {
    background: var(--primary-color);
    color: white;
}

/* ============================================
   DELIVERY ORDER CARDS
   ============================================ */

.order-count {
    text-align: center;
    padding: var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.do-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.do-card-container {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.do-card {
    padding: var(--spacing-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
    display: block;
}

.do-card:active {
    transform: scale(0.98);
}

.do-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.do-number {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.do-card-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.customer-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.customer-address {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.do-card-meta {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

.meta-label {
    font-weight: 600;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending { background: #f3f4f6; color: #6b7280; }
.status-assigned { background: #dbeafe; color: #1e40af; }
.status-accepted { background: #d1fae5; color: #065f46; }
.status-enroute { background: #fef3c7; color: #92400e; }
.status-arrived { background: #fed7aa; color: #9a3412; }
.status-delivered { background: #dcfce7; color: #166534; }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-cancelled { background: #f3f4f6; color: #6b7280; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-md);
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.empty-state h3 {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-secondary);
}

/* ============================================
   DO DETAIL PAGE
   ============================================ */

.info-card {
    background: var(--surface-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.link-phone {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.quick-actions .btn {
    flex: 1;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
    padding: 0.875rem var(--spacing-lg);
}

.btn-accept { background-color: var(--success-color); color: white; }
.btn-enroute { background-color: var(--warning-color); color: white; }
.btn-arrived { background-color: #dc2626; color: white; }
.btn-complete { background-color: var(--primary-color); color: white; }
.btn-failed { background-color: #6b7280; color: white; }

/* Event Timeline */
.event-timeline {
    background: var(--surface-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: var(--spacing-lg);
}

.event-timeline h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.event-item {
    padding: var(--spacing-md);
    border-left: 3px solid var(--primary-color);
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-lg);
}

.event-time {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.event-status {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.event-notes, .event-reason {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface-color);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.modal-actions button {
    flex: 1;
}

/* ============================================
   SIGNATURE CANVAS
   ============================================ */

.signature-container {
    position: relative;
    margin-bottom: var(--spacing-md);
}

.signature-canvas {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    touch-action: none;
    width: 100%;
    background: white;
    cursor: crosshair;
}

.btn-clear-signature {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: white;
    border: 1px solid var(--border-color);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

/* ============================================
   PHOTO UPLOAD
   ============================================ */

.form-control-file {
    width: 100%;
    padding: var(--spacing-md);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    cursor: pointer;
}

.photo-preview {
    margin: var(--spacing-md) 0;
    text-align: center;
}

.photo-preview img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.photos-grid {
    background: var(--surface-color);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: var(--spacing-lg);
}

.photos-grid h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--spacing-md);
}

.photo-item {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
}

.photo-thumbnail {
    aspect-ratio: 1;
    background: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-xs);
}

.photo-type {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-align: center;
}

.photo-caption {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-align: center;
    margin-top: var(--spacing-xs);
}

/* ============================================
   RESPONSIVE - DRIVER PAGES
   ============================================ */

@media (max-width: 576px) {
    .page-container {
        padding: var(--spacing-sm);
    }

    .filter-tabs {
        font-size: var(--font-size-sm);
    }

    .quick-actions {
        flex-direction: column;
    }

    .modal-content {
        padding: var(--spacing-lg);
    }
}
