/* Flow One / driver shell UI - Mobile-first (shared by one-driver, CRM chat, checkout) */

*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --primary-color: #0b5f59;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --accent-amber: #f59e0b;
    --accent-amber-soft: #fffbeb;
    --success-color: #059669;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #ecfdf8;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.15rem;
    --radius-xl: 1.25rem;
    --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.06);
    --shadow-md: 0 8px 24px -8px rgb(15 23 42 / 0.18);
    --shadow-card: 0 4px 16px -4px rgb(15 118 110 / 0.14);
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --touch-min: 48px;
}

.app2 {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
}

.app2-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(15, 118, 110, 0.12);
    padding: 0.55rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-top: calc(0.55rem + var(--safe-top));
    backdrop-filter: blur(12px);
}

.app2-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 640px;
    margin: 0 auto;
}

.app2-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
}

.app2-logo-img {
    height: 28px;
    width: auto;
}

.app2-logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app2-logo-badge {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-left: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: var(--primary-light);
    border: none;
}

.app2-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app2-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.app2-icon-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.app2-icon-btn:active {
    background: var(--bg-tertiary);
}

.app2-dropdown {
    position: absolute;
    top: 100%;
    right: 1rem;
    margin-top: 0.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    overflow: hidden;
}

.app2-dropdown[hidden] {
    display: none !important;
}

.app2-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    min-height: var(--touch-min);
    font-family: inherit;
}

.app2-dropdown-item:hover,
.app2-dropdown-item:active {
    background: var(--bg-tertiary);
}

.app2-dropdown-btn {
    font-family: inherit;
}

/* Main */
.app2-main {
    flex: 1;
    min-width: 0;
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-bottom: calc(1rem + var(--safe-bottom));
}

.app2-view {
    display: none;
}

.app2-view.app2-view-active,
.app2-view:not([hidden]) {
    display: block;
}

.app2-view[hidden] {
    display: none !important;
}

.app2-step-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    min-width: 0;
}

.app2-step-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.app2-step-desc {
    width: 100%;
    min-width: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.app2-back {
    order: -1;
}

/* Form */
.app2-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.app2-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    position: relative;
    overflow: visible;
}

.app2-field label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.app2-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    box-sizing: border-box;
}

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

.app2-input-readonly {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: default;
}

.app2-btn-location {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-color);
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.app2-btn-location:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.app2-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: 40;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-top: 0;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.app2-suggestions:empty {
    display: none;
}

.app2-suggestion-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.9rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.app2-suggestion-item:last-child {
    border-bottom: none;
}

.app2-suggestion-item:hover,
.app2-suggestion-item:active {
    background: var(--bg-tertiary);
}

/* Nav */
.app2-nav {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.app2-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-lg);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-height: var(--touch-min);
    text-decoration: none;
    border: none;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

.app2-btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    flex: 1;
    min-width: 140px;
}

.app2-btn-primary:active {
    opacity: 0.95;
}

.app2-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.app2-btn-full {
    width: 100%;
}

/* Options row (upload / manual) */
.app2-options-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (min-width: 420px) {
    .app2-options-row {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.app2-option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.35rem 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
    box-shadow: var(--shadow-card);
    min-height: 7.5rem;
}

.app2-option-card:active {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.app2-option-icon {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.app2-option-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.app2-option-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.app2-upload-msg {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.app2-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.app2-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.app2-item-label {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app2-item-remove {
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.app2-past-job-item .app2-item-label {
    white-space: normal;
}
.app2-btn-small {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Summary */
.app2-summary {
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.app2-summary-p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.app2-summary-p:last-child {
    margin-bottom: 0;
}

/* Progress */
.app2-progress-view {
    padding: 2rem 1rem;
    text-align: center;
}

.app2-progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.app2-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    border-radius: 999px;
    transition: width 0.3s ease;
}

.app2-progress-msg {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Route view */
.app2-map-container {
    height: 180px;
    width: 100%;
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-card);
}

@media (min-width: 480px) {
    .app2-map-container {
        height: 220px;
    }
}

.app2-route-metrics {
    margin-bottom: 1rem;
}

.app2-metrics-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.app2-metrics-row span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.od-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.od-route-stops-toolbar {
    margin-bottom: 0.65rem;
}

.od-route-stops-gel-hint {
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    padding: 0.5rem 0.65rem;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-color);
}

.od-route-stops-search-row {
    margin-bottom: 0.25rem;
}

.od-route-stops-search-field {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.od-route-stops-search-icon {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.od-route-stops-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
}

.od-route-stops-search-clear {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.od-route-stops-search-clear:hover,
.od-route-stops-search-clear:focus {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.od-gel-detour-row {
    margin-top: 0.45rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
}

.od-gel-detour-result {
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-secondary);
    max-width: 100%;
}

.od-gel-detour-nav {
    width: 100%;
}

.od-gel-detour-nav-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.35rem 0;
}

.od-gel-detour-nav-btns {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
    gap: 0.4rem;
}

.od-gel-detour-nav-btns .app2-btn-nav {
    flex: 1 1 auto;
    min-width: 6.5rem;
}

.app2-route-stops {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.app2-stop {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.app2-stop-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.9rem;
}

.app2-stop-info {
    flex: 1;
    min-width: 0;
}

.app2-stop-address {
    display: block;
    font-size: 0.95rem;
}

.app2-stop-tracking {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.app2-stop-done-wrap {
    margin-top: 0.5rem;
}

.app2-stop-done-wrap .app2-btn-small {
    margin-left: 0;
}

.app2-stop-done-btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    text-align: center;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.app2-stop-done-btn--done {
    background: rgba(15, 118, 110, 0.12);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.app2-stop-done-btn--done:hover,
.app2-stop-done-btn--done:focus {
    background: rgba(15, 118, 110, 0.2);
    color: var(--primary-color);
}

.app2-stop.app2-stop-next {
    border-left: 3px solid var(--primary-color);
    background: rgba(15, 118, 110, 0.08);
}

.app2-stop-next-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.app2-stop-nav {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: stretch;
    min-width: 8.25rem;
}

.app2-btn-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.app2-stop-nav .app2-btn-nav {
    width: 100%;
    box-sizing: border-box;
}

.app2-btn-nav:hover,
.app2-btn-nav:focus {
    background: var(--primary-color);
    color: white;
}

.app2-btn-nav-waze {
    background: #33ccff;
    color: #091c45;
    border-color: #33ccff;
}

.app2-btn-nav-waze:hover,
.app2-btn-nav-waze:focus {
    background: #091c45;
    color: #33ccff;
    border-color: #091c45;
}

.app2-route-actions {
    margin-top: 1rem;
}

.app2-route-actions .app2-btn {
    width: 100%;
}

.app2-google-maps-blocks {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.app2-google-maps-blocks .app2-btn-route-block {
    width: 100%;
}

/* In-app navigation instructions panel */
.app2-nav-instructions {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    overflow: hidden;
}

.app2-nav-instructions[hidden] {
    display: none !important;
}

.app2-nav-instructions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-color);
}

.app2-nav-instructions-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.app2-nav-instructions-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    max-height: 280px;
    overflow-y: auto;
}

.app2-nav-instruction-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

.app2-nav-instruction-item:last-child {
    border-bottom: none;
}

.app2-nav-instruction-item .app2-nav-instruction-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.75rem;
}

.app2-nav-instruction-item .app2-nav-instruction-text {
    flex: 1;
    min-width: 0;
}

.app2-nav-instruction-item .app2-nav-instruction-dist {
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Sheet modal */
.app2-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.app2-sheet-overlay[hidden] {
    display: none !important;
}

.app2-sheet {
    background: var(--bg-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 1rem);
}

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

.app2-sheet-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.app2-sheet-close {
    flex-shrink: 0;
}

.app2-sheet-body {
    padding: 1.25rem;
}

.app2-sheet-body .app2-field {
    margin-bottom: 1rem;
}

.app2-sheet-body .app2-btn-full {
    margin-top: 0.5rem;
}

/* AI Wizard modal: chat needs min height */
.app2-sheet-ai-wizard .app2-sheet-body {
    min-height: 320px;
    display: flex;
    flex-direction: column;
}
.app2-sheet-ai-wizard .ai-wizard-chat-wrap {
    flex: 1;
    min-height: 280px;
}
.app2-sheet-ai-wizard .ai-wizard-messages {
    max-height: 200px;
}
.app2-sheet-ai-wizard .ai-wizard-chat-header {
    display: none;
}
.app2-sheet-ai-wizard .ai-wizard-chat-body {
    padding: 0;
}
.app2-sheet-ai-wizard .ai-wizard-input {
    min-height: 52px;
}
