/**
 * ManageTrans — app-level UI polish (Velzon theme)
 */

:root {
    --mt-card-radius: 12px;
    --mt-stat-icon-size: 3rem;
}

/* Sidebar logo */
.app-menu .navbar-brand-box .logo-lg {
    width: 220px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}

.app-menu .navbar-brand-box .logo-lg img {
    max-width: 100%;
    height: auto;
    max-height: 100px;
    width: auto;
}

/* Shared utilities */
.mt-note-truncate {
    max-width: 200px;
}

.header-profile-user.bg-primary-subtle {
    width: 32px;
    height: 32px;
    min-width: 32px;
}

.dropdown-item.btn-logout {
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

/* Empty state */
.mt-empty-state {
    min-height: 120px;
}

/* ---------- Trip cards ---------- */
.trip-card {
    background: var(--vz-secondary-bg, #fff);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--mt-card-radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.trip-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.trip-card.trip-status-warning { border-left: 4px solid #f59e0b; }
.trip-card.trip-status-secondary { border-left: 4px solid #64748b; }
.trip-card.trip-status-info { border-left: 4px solid #06b6d4; }
.trip-card.trip-status-success { border-left: 4px solid #10b981; }
.trip-card.trip-status-danger,
.trip-card.trip-status-bg-danger {
    border-left: 5px solid #ef4444 !important;
}

.trip-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.trip-card.trip-status-bg-danger .trip-card-header,
.trip-card.trip-status-danger .trip-card-header {
    background: #fef2f2;
    border-bottom: 1px solid #fee2e2;
}

.trip-card-main { flex: 1; min-width: 0; }

.trip-card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.trip-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    background: #e2e8f0;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.trip-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: -0.01em;
}

.status-pill {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
}

.status-pill.status-warning { background: #fef3c7; color: #b45309; }
.status-pill.status-secondary { background: #f1f5f9; color: #475569; }
.status-pill.status-info { background: #cffafe; color: #0891b2; }
.status-pill.status-success { background: #d1fae5; color: #047857; }
.status-pill.status-danger,
.status-pill.status-bg-danger {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border: 1px solid #fca5a5 !important;
    font-weight: 700;
}

.trip-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: #475569;
    background: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-weight: 500;
}

.meta-pill i {
    font-size: 0.9rem;
    color: #94a3b8;
}

.meta-pill.meta-crew {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.meta-pill.meta-crew i { color: #3b82f6; }

.trip-card-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    transition: all 0.2s ease;
}

.btn-action:hover {
    background: #f8fafc;
    color: #334155;
    border-color: #cbd5e1;
}

.btn-action-edit {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.btn-action-edit:hover {
    background: #0b5ed7;
    border-color: #0b5ed7;
    color: #fff;
}

.btn-action-delete:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.trip-card-crews {
    padding: 1.25rem 1.5rem;
}

.crews-section-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

.crews-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
}

.crews-label i {
    margin-right: 0.4rem;
    opacity: 0.9;
}

.trip-crews-table {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #f1f5f9;
}

.trip-crews-table thead th {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.trip-crews-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

.trip-crews-table tbody tr:last-child { border-bottom: none; }
.trip-crews-table tbody tr:nth-child(even) { background: #fafbfc; }
.trip-crews-table tbody tr:hover { background: #f1f5f9 !important; }

.trip-crews-table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    vertical-align: middle;
    color: #334155;
}

.crew-index {
    color: #94a3b8;
    font-weight: 600;
    width: 2.5rem;
    font-size: 0.8125rem;
}

.crew-name {
    font-weight: 600;
    color: #0f172a;
}

.crew-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 0.6rem;
    vertical-align: middle;
    border-radius: 8px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4338ca;
    font-size: 0.6875rem;
    font-weight: 700;
}

.route-cell { font-size: 0.8125rem; }
.route-from, .route-to { color: #475569; }
.route-arrow {
    color: #cbd5e1;
    margin: 0 0.35rem;
    font-size: 0.7rem;
}

.crews-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed #e2e8f0;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
}

.crews-empty i {
    font-size: 1.5rem;
    opacity: 0.5;
}

.trip-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: var(--mt-card-radius);
}

.trip-empty-icon {
    width: 5rem;
    height: 5rem;
    margin: 0 auto 1.25rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.25rem;
    color: #94a3b8;
}

.trip-empty-state h5 { color: #334155; font-weight: 600; }

.assign-driver-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.assign-driver-inline .assign-driver-select {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border-color: #cbd5e1;
    min-width: 120px;
    /* Selects size to their longest option; cap it so the Assign button stays inline. */
    max-width: 190px;
}

.assign-driver-inline .assign-driver-btn {
    white-space: nowrap;
}

.trips-list-card {
    border-radius: var(--mt-card-radius);
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.trips-list-card .card-header {
    background: var(--vz-secondary-bg, #fff);
}

.trips-list-card .card-body {
    background: #f8fafc;
}

.filter-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

/* Trip card / crew table mobile */
@media (max-width: 767.98px) {
    .trip-card-header {
        flex-direction: column;
        gap: 1rem;
    }

    .trip-card-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .assign-driver-inline {
        width: 100%;
    }

    .assign-driver-inline .assign-driver-select {
        flex: 1;
        min-width: 0;
        max-width: none;
    }
}

/* ---------- Installable app ---------- */

/* Fallback trigger for pages without a topbar (login, error pages) */
.pwa-install-floating {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1030;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.6rem 1.1rem;
    border: 0;
    border-radius: 999px;
    background: var(--vz-primary, #405189);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 6px 18px rgba(64, 81, 137, 0.35);
}

/* Keep content clear of the iOS home indicator when running installed */
@media (display-mode: standalone) {
    .footer {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    #page-topbar {
        padding-top: env(safe-area-inset-top);
    }
}

/* ---------- Shared responsive behaviour ---------- */

/* Wide tables should scroll their own container rather than stretch the page */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Data-entry grids stay legible by scrolling instead of crushing every column */
.table-wide {
    min-width: 900px;
}

/*
 * Crew entry grids have 13 columns of inputs. Without a floor the inputs collapse to
 * a few pixels each on a phone, so the table scrolls instead — with the row controls
 * pinned so "remove row" is always reachable.
 */
.table-crews {
    min-width: 1500px;
}

.table-crews thead th:last-child,
.table-crews tbody td:last-child {
    position: sticky;
    right: 0;
    background: #fff;
    box-shadow: -5px 0 6px -5px rgba(0, 0, 0, 0.25);
}

.table-crews thead th:last-child {
    background: #f8f9fa;
}

.table-scroll-hint {
    display: none;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    color: #878a99;
    font-size: 0.8125rem;
}

@media (max-width: 1199.98px) {
    .table-scroll-hint {
        display: flex;
    }
}

/*
 * Activity descriptions can contain long unbreakable values (tokens, ids, urls). A flex
 * child defaults to its min-content width, so without these it stretches the page.
 */
.activity-timeline .flex-grow-1 {
    min-width: 0;
}

.activity-timeline p {
    overflow-wrap: anywhere;
}

/* Two-column key/value tables on detail pages */
.table-details th {
    width: 34%;
    min-width: 130px;
    font-weight: 600;
}

/* Square media that shrinks with its column instead of forcing a fixed size */
.mt-profile-photo {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.mt-inline-map {
    width: 100%;
    height: 400px;
    border-radius: 8px;
}

@media (max-width: 575.98px) {
    .mt-inline-map {
        height: 260px;
    }
}

/* DataTables export buttons (neutral grey, distinct from page actions) */
.dt-buttons .btn {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.dt-buttons .btn:hover,
.dt-buttons .btn:focus {
    background-color: #5c636a;
    border-color: #565e64;
    color: #fff;
}

@media (max-width: 991.98px) {
    /* DataTables' export row and length/search controls stack on narrow screens */
    .dt-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    /*
     * The DataTables stylesheet is pushed after this file, so its own mobile rules win
     * on source order at equal specificity. The extra wrapper class outranks them.
     */
    div.dataTables_wrapper.dt-bootstrap5 div.dataTables_filter,
    div.dataTables_wrapper.dt-bootstrap5 div.dataTables_length {
        text-align: left;
    }

    /* Label wraps "Search:" plus the input, so it has to share the width */
    div.dataTables_wrapper.dt-bootstrap5 div.dataTables_filter label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

    div.dataTables_wrapper.dt-bootstrap5 div.dataTables_filter input {
        flex: 1;
        width: auto;
        min-width: 0;
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    /* Titles, breadcrumbs and header actions wrap instead of colliding */
    .page-title-box {
        gap: 0.5rem;
    }

    .card-header > .d-flex,
    .page-title-right {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Comfortable touch targets */
    .btn-action {
        width: 40px;
        height: 40px;
    }

    .table-responsive .btn-sm,
    .card-header .btn-sm {
        min-height: 34px;
    }

    /* Reclaim horizontal space that padding would otherwise eat.
       Only the card's own padding is reduced: shrinking .page-content would break the
       grid's negative gutters and push the whole page sideways. */
    .card-body {
        padding: 1rem;
    }

    /* Dialogs use the full width of a phone screen */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
        margin: 0;
    }

    /* Long, unbroken values (emails, tokens, URLs) must not widen the page */
    .table td,
    .table th {
        word-break: break-word;
    }

    /* Preformatted payloads (activity log details) scroll rather than stretch */
    pre {
        overflow: auto;
    }

    .table-nowrap td,
    .table-nowrap th {
        word-break: normal;
    }
}

