/**
 * Shipment Tracker - Main Styles
 * Mobile-First Responsive Layout
 *
 * @author Wayne Fong (wayneef84)
 * @version 1.0.0
 */

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

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

html {
    /* Use dynamic viewport height for mobile */
    height: 100dvh;
    height: 100vh; /* Fallback */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
                 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-gradient);
    height: 100dvh;
    height: 100vh; /* Fallback */
    overflow: hidden;

    /* Safe area insets for notched devices */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);

    /* Touch optimization */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Allow text selection in specific areas */
input,
textarea,
.selectable,
.detail-panel {
    user-select: text;
    -webkit-user-select: text;
}

/* ============================================================
   LAYOUT CONTAINER
   ============================================================ */

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-primary);
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

/* ============================================================
   HEADER
   ============================================================ */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--header-bg);
    border-bottom: 3px solid var(--primary-color);
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

/* Icon Buttons */
.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--btn-bg);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--btn-hover);
    transform: scale(1.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
    position: fixed;
    /* top: calc(20px + env(safe-area-inset-top)); */
    right: 20px;

    bottom: calc(20px + env(safe-area-inset-bottom));
    /* left: 20px; */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.toast {
    background: var(--toast-bg);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
    font-size: 0.9rem;
}

.toast.toast-success { background: var(--success-color); }
.toast.toast-error { background: var(--error-color); }
.toast.toast-info { background: var(--info-color); }
.toast.toast-warning { background: var(--warning-color); }

.toast.fade-out {
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================================
   PANELS (Settings, Export)
   ============================================================ */

.settings-panel,
.export-panel {
    position: absolute;
    top: 70px;
    right: 10px;
    background: var(--panel-bg);
    border: 3px solid var(--primary-color);
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    z-index: 200;
    max-width: 400px;
    width: calc(100vw - 40px);
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    animation: popIn 0.2s ease-out;
}

.settings-panel.hidden,
.export-panel.hidden {
    display: none;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Panel header (sticky title) */
.panel-header {
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--panel-bg);
    z-index: 10;
    margin: -20px -20px 0 -20px; /* Negative margin to extend to edges */
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
}

.panel-header h2 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.3rem;
}

/* Scrollable content area */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem 1rem 1rem;
}

.settings-panel h2,
.export-panel h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Collapsible headers */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.collapsible-header:hover {
    color: var(--primary-color);
}

.collapsible-header .expand-icon {
    font-size: 0.75rem;
    transition: transform 0.2s;
    display: inline-block;
}

.collapsible-header.expanded .expand-icon {
    transform: rotate(90deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

kbd {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.settings-panel label,
.export-panel label {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.75rem;
}

.settings-panel label span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.settings-panel input[type="password"],
.settings-panel input[type="text"],
.settings-panel input[type="number"] {
    padding: 0.6rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
}

.settings-panel input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.toggle-visibility {
    margin-left: 0.5rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border-color);
    background: var(--btn-bg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.settings-actions,
.export-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ============================================================
   EXPORT PANEL
   ============================================================ */

.export-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.export-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--btn-bg);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.export-option:hover {
    border-color: var(--primary-color);
    background: var(--btn-hover);
    transform: translateX(5px);
}

.export-icon {
    font-size: 2rem;
}

.export-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.export-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.export-filters {
    margin-bottom: 1rem;
}

/* ============================================================
   ADD TRACKING SECTION
   ============================================================ */

.add-tracking-section {
    padding: 1.5rem 1rem;
    background: var(--section-bg);
    border-bottom: 2px solid var(--border-light);
    flex-shrink: 0;
}

.add-tracking-section h2 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.add-tracking-form {
    margin-bottom: 1rem;
    justify-items: center;
}

.form-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.form-row input,
.form-row select {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-options {
    margin-top: 0.75rem;
}

.form-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-options input[type="date"] {
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
}

.bulk-import {
    margin-top: 1rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

/* Icon-expand button (shows icon only, expands on hover/click) */
.btn-icon-expand {
    padding: 0.5rem;
    flex: initial;
    width: auto;
    max-width: 44px;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.3s ease, padding 0.3s ease;
}

.btn-icon-expand .icon {
    display: inline-block;
    font-size: 1.2rem;
}

.btn-icon-expand .text {
    display: inline-block;
    margin-left: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-icon-expand:hover,
.btn-icon-expand:focus,
.btn-icon-expand.expanded {
    max-width: 300px;
    padding: 0.5rem 1rem;
}

.btn-icon-expand:hover .text,
.btn-icon-expand:focus .text,
.btn-icon-expand.expanded .text {
    opacity: 1;
}

/* Details button with icon */
.btn-details {
    /* display: flex; */
    align-items: center;
    gap: 0.25rem;
    padding: 0rem 0rem;
    /* padding: 0.4rem 0.8rem; */
    font-size: 0.85rem;
}

.btn-details .btn-icon {
    font-size: 1rem;
}

.btn-details .btn-text {
    display: inline;
}

/* Hide text on mobile, show icon only */
@media (max-width: 767px) {
    .btn-details .btn-text {
        display: none;
    }

    .btn-details {
        padding: 0.5rem;
    }
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-primary:active,
.btn-secondary:active,
.btn-danger:active {
    transform: translateY(0);
}

/* Icon-only buttons (for table actions) */
.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-only:hover {
    background: var(--hover-color);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-icon-only:active {
    transform: scale(0.95);
}

.btn-icon-only.btn-danger {
    background: #fee2e2;
    border-color: #ef4444;
}

.btn-icon-only.btn-danger:hover {
    background: #fecaca;
}

/* ============================================================
   STATISTICS DASHBOARD
   ============================================================ */

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: var(--section-bg);
    border-bottom: 2px solid var(--border-light);
    flex-shrink: 0;
}

.stats-container.hidden {
    display: none;
}

.stat-card {
    background: var(--stat-bg);
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card.active {
    border-color: #1e40af; /* Primary blue border */
    box-shadow: 0 4px 16px rgba(30, 64, 175, 0.3); /* Fancy blue glow */
    transform: translateY(-1px);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.95); /* White for contrast */
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85); /* Light white */
    font-weight: 600;
}

/* Compact stat cards: label: # format */
.stat-card-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
}

.stat-label-compact {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 600;
}

.stat-value-compact {
    font-size: 1.1rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.95);
}

/* ============================================================
   FILTER BAR
   ============================================================ */

.filter-bar {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--section-bg);
    border-bottom: 2px solid var(--border-light);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9); /* Light white for better contrast */
    white-space: nowrap;
}

.filter-group select,
.filter-group input {
    flex: 1;
    padding: 0.6rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* ============================================================
   TRACKING TABLE
   ============================================================ */

.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
}

#trackingTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#trackingTable thead {
    position: sticky;
    top: 0;
    background: var(--table-header-bg);
    z-index: 10;
}

#trackingTable th {
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary-color);
    white-space: nowrap;
}

#trackingTable th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

#trackingTable th.sortable:hover {
    background: rgba(0, 0, 0, 0.05);
}

#trackingTable th.sortable.sorted {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

#trackingTable th .sort-indicator {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    opacity: 0.6;
}

#trackingTable td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    text-align: center;
}

#trackingTable tbody tr {
    transition: background 0.2s;
    cursor: pointer;
}

#trackingTable tbody tr:hover {
    background: var(--row-hover);
}

#trackingTable tbody tr.delivered {
    opacity: 0.7;
}

/* Status columns */
.status-icon-column {
    width: 40px;
    padding: 0.75rem 0.25rem !important;
}

.status-text-column {
    min-width: 120px;
}

/* Hide status text on narrow widths (< 1200px), keep icon visible */
@media (max-width: 1199px) {
    .status-text-column {
        display: none;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* ============================================================
   DETAIL PANEL (Slide-in)
   ============================================================ */

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: var(--panel-bg);
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.detail-panel:not(.hidden) {
    transform: translateX(0);
}

.back-to-top-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1e40af;
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
}

.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top-btn:hover {
    background: #1e3a8a;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.back-to-top-btn:active {
    transform: translateY(0);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--header-bg);
    border-bottom: 3px solid var(--primary-color);
    flex-shrink: 0;
}

.detail-header h2 {
    font-size: 1.2rem;
    color: var(--primary-color);
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

#detailInfo {
    font-size: 0.85em;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.detail-section dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.detail-section dt {
    font-weight: 600;
    color: var(--text-secondary);
}

.detail-section dd {
    color: var(--text-primary);
}

.event-timeline {
    position: relative;
    padding-left: 2rem;
}

.event-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.event-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.event-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--panel-bg);
}

.event-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.event-desc {
    color: var(--text-primary);
    font-weight: 600;
}

.event-location {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

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

.footer {
    padding: 1rem;
    text-align: center;
    background: var(--footer-bg);
    border-top: 2px solid var(--border-light);
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.footer p {
    margin: 0.25rem 0;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer .legal {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

/* ============================================================
   RESPONSIVE DESIGN (Tablet & Desktop)
   ============================================================ */

@media (min-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .settings-panel,
    .export-panel {
        width: 400px;
    }

    .add-tracking-section {
        padding: 1.5rem 2rem;
    }

    .stats-container {
        padding: 1.5rem 2rem;
    }

    .filter-bar {
        padding: 1rem 2rem;
    }

    .table-container {
        padding: 1.5rem 2rem;
    }

    #trackingTable {
        font-size: 1rem;
    }

    .detail-panel {
        max-width: 600px;
    }

    .toast-container {
        max-width: 400px;
    }

    /* Hide mobile FABs on tablet and up */
    .mobile-filter-toggle,
    .mobile-add-toggle {
        display: none !important;
    }
}

@media (min-width: 1024px) {
    .form-row {
        flex-wrap: nowrap;
        width: 750px;
    }

    .export-options {
        flex-direction: row;
    }

    .export-option {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Payload Viewer */
.payload-viewer {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    max-height: 400px;
    overflow: auto;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
}

.payload-viewer pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.json-key {
    color: var(--primary-color);
    font-weight: 500;
}

.json-string {
    color: var(--success-color);
}

.json-number {
    color: var(--info-color);
}

.json-boolean {
    color: var(--warning-color);
}

.json-null {
    color: var(--text-tertiary);
    font-style: italic;
}

/* Links in JSON payload */
.payload-viewer a {
    color: #60a5fa;
    text-decoration: underline;
    cursor: pointer;
}

.payload-viewer a:hover {
    color: #3b82f6;
    text-decoration: none;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-pickup { background: var(--status-pickup); color: white; }
.status-transit { background: var(--status-transit); color: white; }
.status-delivery { background: var(--status-delivery); color: white; }
.status-delivered { background: var(--status-delivered); color: white; }
.status-exception { background: var(--status-exception); color: white; }
.status-failed { background: var(--status-failed); color: white; }

/* ============================================================
   CONTENT WRAPPER (for split view on desktop)
   ============================================================ */

.content-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ============================================================
   MOBILE CARDS (< 768px)
   ============================================================ */

.mobile-cards-container {
    display: none; /* Hidden on desktop, shown on mobile */
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Critical for flexbox overflow */
}

.shipment-card {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: visible;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Prevent cards from shrinking */
}

.shipment-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.shipment-card.expanded {
    border-color: var(--primary-color);
}

/* Card Header (Always Visible) */
.card-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.card-status-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
}

.card-info {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.card-awb {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    word-break: break-all;
}

.card-awb-full {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9rem;
}

.card-carrier {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-duplicate-badge {
    display: inline-block;
    background: var(--warning-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 0.5rem;
    font-weight: 600;
}

.card-expand-icon {
    font-size: 1.2rem;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.shipment-card.expanded .card-expand-icon {
    transform: rotate(180deg);
}

/* Card Body (Expanded Details) */
.card-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.shipment-card.expanded .card-body {
    max-height: 1000px; /* Large enough for content */
}

.card-details {
    padding: 0 1rem 1rem 1rem;
    border-top: 1px solid var(--border-color);
}

.card-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

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

.card-detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-detail-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    text-align: right;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.card-actions button,
.card-actions a {
    flex: 1;
    font-size: 0.85rem;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.card-actions .btn-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.card-actions .btn-text {
    display: inline;
}

/* Mobile: Hide button text, show only icons centered */
@media (max-width: 767px) {
    .card-actions .btn-text {
        display: none;
    }

    .card-actions button,
    .card-actions a {
        padding: 0.75rem;
        min-width: 48px;
        min-height: 48px;
    }

    .card-actions .btn-icon {
        font-size: 1.5rem;
    }
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Mobile: Show cards, hide table */
@media (max-width: 767px) {
    body {
        padding-bottom: 0; /* Bottom bar handles safe area inset */
    }

    .mobile-cards-container {
        display: flex;
    }

    .table-container {
        display: none;
    }

    /* Hide add tracking form on mobile (bottom bar Add button shows it) */
    .add-tracking-section {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-primary);
        z-index: 200;
        overflow-y: auto;
        padding: 1rem;
        padding-top: calc(env(safe-area-inset-top) + 1rem);
        padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
    }

    .add-tracking-section.visible-mobile {
        display: block;
    }

    /* Close button for mobile add form */
    .mobile-add-close-btn {
        display: none !important;
        position: fixed;
        top: calc(env(safe-area-inset-top) + 0.5rem);
        right: 1rem;
        font-size: 2rem;
        color: var(--text-primary);
        cursor: pointer;
        z-index: 201;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: var(--bg-secondary);
        border-radius: 50%;
        border: 1px solid var(--border-color);
        padding: 0;
        line-height: 1;
    }

    .add-tracking-section.visible-mobile .mobile-add-close-btn {
        display: flex !important;
    }

    .mobile-add-close-btn:active {
        background: var(--border-color);
    }

    /* Hide desktop stats container on mobile (bottom bar replaces it) */
    .stats-container {
        display: none !important;
    }

    /* Add padding to mobile cards container to account for bottom bar */
    .mobile-cards-container {
        padding: 1rem 1rem 200px 1rem;
    }

    /* Hide filter bar on mobile by default */
    .filter-bar {
        display: none;
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .filter-bar.visible {
        display: flex;
    }

    /* Force search input visibility on mobile when filter bar is open */
    .filter-group.filter-group-search.hidden {
        display: flex !important;
    }

    #searchToggleBtn {
        display: none !important;
    }

    /* Mobile Bottom Bar (2-row controls) */
    .mobile-bottom-bar {
        display: block !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-top: 2px solid var(--border-color);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .bottom-bar-row {
        display: flex;
        gap: 0.25rem;
        padding: 0.5rem;
    }

    .bottom-bar-row.stat-filters {
        border-top: 1px solid var(--border-color);
    }

    .bottom-bar-row.actions {
        border-bottom: 1px solid var(--border-color);
    }

    /* Stat filter buttons: hide label, show only icon + count */
    .stat-filter-btn .btn-label {
        display: none !important;
    }

    .bottom-bar-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        padding: 0.5rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
    }

    .bottom-bar-btn:active {
        transform: scale(0.95);
        background: var(--hover-color);
    }

    .bottom-bar-btn.active {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

    .bottom-bar-btn.active .btn-count {
        color: white;
    }

    .btn-icon {
        font-size: 1.25rem;
        line-height: 1;
    }

    .btn-label {
        font-size: 0.75rem;
        font-weight: 500;
        line-height: 1;
    }

    .btn-count {
        font-size: 0.875rem;
        font-weight: 700;
        color: var(--primary-color);
        line-height: 1;
    }

    .bottom-bar-btn.active .btn-label {
        color: white;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group label {
        display: block;
        margin-bottom: 0.25rem;
        font-size: 0.85rem;
        color: var(--text-secondary);
    }

    .filter-group select,
    .filter-group input {
        width: 100%;
        min-height: 44px; /* Touch target size */
        font-size: 1rem;
    }

    /* Mobile Sort Menu */
    .mobile-sort-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        z-index: 200;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        max-height: 60vh;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-sort-menu.visible {
        transform: translateY(0);
    }

    .sort-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        background: var(--bg-primary);
        z-index: 10;
    }

    .sort-menu-header h3 {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--text-primary);
    }

    .sort-menu-header .close-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-secondary);
        border: none;
        border-radius: 50%;
        font-size: 1.25rem;
        cursor: pointer;
        color: var(--text-secondary);
        transition: all 0.2s;
    }

    .sort-menu-header .close-btn:active {
        transform: scale(0.9);
        background: var(--hover-color);
    }

    .sort-menu-options {
        padding: 0.5rem;
    }

    .sort-option {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 1rem;
        margin-bottom: 0.5rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        text-align: left;
    }

    .sort-option:active {
        transform: scale(0.98);
        background: var(--hover-color);
    }

    .sort-option.active {
        background: var(--primary-color);
        border-color: var(--primary-color);
        color: white;
    }

    .sort-option .sort-label {
        font-size: 1rem;
        font-weight: 500;
    }

    .sort-option .sort-direction {
        font-size: 0.875rem;
        opacity: 0.8;
    }

    .sort-option.active .sort-direction {
        opacity: 1;
    }
}

/* Tablet: Show table with overlay detail panel */
@media (min-width: 768px) and (max-width: 1023px) {
    .mobile-cards-container {
        display: none;
    }

    .table-container {
        display: flex;
    }

    .detail-panel {
        width: 100%;
        max-width: 600px;
    }
}

/* Desktop: Show table + split view detail panel */
@media (min-width: 1024px) {
    .mobile-cards-container {
        display: none;
    }

    /* Split view: content-wrapper holds table and detail panel side-by-side */
    .content-wrapper {
        display: flex;
        flex-direction: row; /* Table left, Detail right */
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .table-container {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }

    .detail-panel {
        position: relative;
        flex: 0 0 40%;
        /* max-width: 500px; */
        max-width: 350px;
        transform: none !important;
        box-shadow: none;
        border-left: 2px solid var(--border-color);
        overflow-y: auto;
    }

    .detail-panel.hidden {
        display: none;
    }

    /* Hide actions column when detail panel is visible */
    body.detail-open .actions-column {
        /* display: none; */
    }
}

/* ============================================================
   DEBUG MENU
   ============================================================ */

.debug-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border-radius: 10px 10px 0 0;
}

.debug-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.debug-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.debug-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.debug-content {
    padding: 1rem;
}

.debug-section {
    margin-bottom: 1.5rem;
}

.debug-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.debug-btn {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.debug-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.debug-btn:active {
    transform: translateY(0);
}

.debug-btn-sm {
    display: inline-block;
    width: calc(50% - 0.25rem);
    padding: 0.5rem;
    font-size: 0.75rem;
}

.debug-btn-sm:nth-child(odd) {
    margin-right: 0.5rem;
}

.debug-btn-warning {
    background: #f59e0b;
}

.debug-btn-warning:hover {
    background: #d97706;
}

.debug-btn-danger {
    background: #ef4444;
}

.debug-btn-danger:hover {
    background: #dc2626;
}

.debug-info {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Dark overlay when debug menu is open */
.debug-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

/* ============================================================
   ICON COLOR DIFFERENTIATION (v1.2.0)
   ============================================================ */

/* Import button - green tint */
.btn-import {
    filter: hue-rotate(90deg) saturate(1.2);
}

/* Export button - blue tint */
.btn-export {
    filter: hue-rotate(200deg) saturate(1.2);
}

/* ============================================================
   DATA MANAGEMENT MODAL (v1.2.0)
   ============================================================ */

.data-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.data-modal.hidden {
    display: none;
}

.data-modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.data-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 2px solid var(--border-color);
}

.data-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.data-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    line-height: 1;
}

.data-modal-close:hover {
    color: var(--text-primary);
}

.data-modal-body {
    padding: 1.25rem;
}

.data-modal-section {
    margin-bottom: 1.5rem;
}

.data-modal-section:last-child {
    margin-bottom: 0;
}

.data-modal-section h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.data-modal-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--btn-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
}

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

.data-modal-btn:last-child {
    margin-bottom: 0;
}

.data-modal-btn .btn-icon {
    font-size: 1.25rem;
}

.data-modal-btn .btn-label {
    flex: 1;
}

.data-modal-btn .btn-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 0.125rem;
}

.data-modal-btn.btn-caution {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.data-modal-btn.btn-caution:hover {
    background: rgba(59, 130, 246, 0.2);
}

.data-modal-btn.btn-warning {
    border-color: var(--warning-color);
    background: rgba(245, 158, 11, 0.1);
}

.data-modal-btn.btn-warning:hover {
    background: rgba(245, 158, 11, 0.2);
}

/* ============================================================
   DOCUMENT MANAGEMENT STYLES
   ============================================================ */

/* Compliance column in table */
.compliance-column {
    text-align: center;
    white-space: nowrap;
    font-size: 1rem;
}

/* Documents section in detail panel */
.doc-icons-preview {
    margin-left: 0.5rem;
    font-size: 0.9rem;
}

.no-documents {
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.5rem 0;
}

.document-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.document-icon {
    font-size: 1.25rem;
}

.document-label {
    flex: 1;
    font-size: 0.9rem;
}

.document-actions {
    display: flex;
    gap: 0.25rem;
}

.document-actions .btn-icon-only {
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
}

/* Document Modal */
.document-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.document-modal.hidden {
    display: none;
}

.document-modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.document-modal-content h3 {
    margin-bottom: 1rem;
}

.document-modal-content .form-group {
    margin-bottom: 1rem;
}

.document-modal-content label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.document-modal-content select,
.document-modal-content input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.document-modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.document-modal-actions button {
    padding: 0.5rem 1rem;
}

/* Documents List Modal (Manage all documents for a shipment) */
.documents-list-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.documents-list-modal.hidden {
    display: none;
}

.documents-list-modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.documents-list-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.documents-list-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.documents-list-modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    color: var(--text-secondary);
}

.documents-list-modal-close:hover {
    color: var(--text-primary);
}

.documents-list-modal-body {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.documents-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.documents-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.documents-list-item-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.documents-list-item-info {
    flex: 1;
    min-width: 0;
}

.documents-list-item-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.documents-list-item-url {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.documents-list-item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.documents-list-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.documents-list-item-actions button:hover {
    background: var(--bg-hover);
}

.documents-list-item-actions button.btn-danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.documents-list-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.documents-list-add-btn {
    width: 100%;
    margin-top: 1rem;
}

.documents-list-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* Docs button in Actions column */
.btn-docs {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-docs:hover {
    background: var(--bg-hover);
}

/* Collapsible header for documents section */
.collapsible-header .expand-icon {
    display: inline-block;
    transition: transform 0.2s;
    margin-right: 0.25rem;
}

.collapsible-header.expanded .expand-icon {
    transform: rotate(90deg);
}

/* Default: collapsed */
.collapsible-content {
    display: none;
}

.collapsible-header.expanded + .collapsible-content {
    display: block;
}

/* ============================================================
   SVG ICONS & ANIMATIONS
   ============================================================ */

.status-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white; /* Ensure SVG stroke is white */
}

.icon-svg {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
    vertical-align: middle;
}

/* Animations */
@keyframes drive {
    0% { transform: translateX(-2px); }
    50% { transform: translateX(2px); }
    100% { transform: translateX(-2px); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes bounce-y {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Status-specific animations */
.status-transit .icon-svg,
.card-status-icon .icon-truck {
    animation: drive 2s infinite ease-in-out;
}

.status-exception .icon-svg,
.card-status-icon .icon-alert {
    animation: pulse 1.5s infinite;
}

.status-delivery .icon-svg,
.status-delivered .icon-svg,
.card-status-icon .icon-check {
    /* No animation for delivered */
}

.status-out_for_delivery .icon-svg,
.card-status-icon .icon-home {
    animation: bounce-y 2s infinite;
}

/* Ensure mobile card icons are white */
.card-status-icon {
    color: white;
}

/* ============================================================
   COUNTDOWN TIMER
   ============================================================ */

.countdown-container {
    background: var(--bg-secondary);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease-out;
}

.countdown-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.countdown-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.countdown-part {
    background: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.countdown-badge.overdue {
    color: var(--error-color);
    font-weight: bold;
    font-size: 1.1rem;
    padding: 0.5rem;
    border: 2px dashed var(--error-color);
    border-radius: 6px;
    background: #fee2e2;
}

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

/* ============================================================
   BULK ACTIONS TOOLBAR
   ============================================================ */

.bulk-actions-toolbar {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--primary-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.2s ease-out;
}

.bulk-actions-toolbar.hidden {
    display: none;
}

.bulk-actions-controls {
    display: flex;
    gap: 0.5rem;
}

#selectedCount {
    font-weight: 600;
    color: var(--primary-color);
}

.checkbox-column {
    width: 40px;
    text-align: center;
}

.row-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    vertical-align: middle;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    min-width: auto;
    flex: initial; /* Don't stretch */
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
