/**
 * SBC Cargo Tracker v2.0.0
 * Kargo takip sayfası — WebView + Mobile + Desktop uyumlu
 * 
 * WebView dikkat noktaları:
 * - -webkit- prefix her yerde
 * - position:fixed/sticky kullanmıyoruz (WebView sorunlu)
 * - 100vw kullanmıyoruz (scrollbar kayması)
 * - touch-action ve tap highlight kontrollü
 * - min-height: 44px tüm butonlarda (Apple HIG)
 * - safe-area-inset destekli padding
 */

/* ============================================
   RESET & BASE
   ============================================ */
.sbc-ct {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    line-height: 1.5;
    color: #1a1a2e;
}

.sbc-ct *, .sbc-ct *::before, .sbc-ct *::after {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* WebView tap highlight kaldır */
.sbc-ct button,
.sbc-ct a,
.sbc-ct input {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* ============================================
   TABS
   ============================================ */
.sbc-ct-tabs {
    display: -webkit-flex;
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 0;
    gap: 0;
}

.sbc-ct-tab {
    -webkit-flex: 1;
    flex: 1;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    min-height: 48px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #9ca3af;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.sbc-ct-tab.active {
    color: #1a1a2e;
    border-bottom-color: #e94560;
}

.sbc-ct-tab-icon {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.sbc-ct-tab-icon svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   PANELS
   ============================================ */
.sbc-ct-panel {
    display: none;
}

.sbc-ct-panel.active {
    display: block;
}

/* ============================================
   SEARCH BOX
   ============================================ */
.sbc-ct-search-box {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-top: 16px;
    -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.03);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.03);
    border: 1px solid #f0f0f0;
}

.sbc-ct-desc {
    color: #6b7280;
    font-size: 13px;
    line-height: 1.6;
    margin: 0 0 16px;
}

/* ============================================
   INPUT GROUP
   ============================================ */
.sbc-ct-input-group {
    display: -webkit-flex;
    display: flex;
    gap: 8px;
}

.sbc-ct-input {
    -webkit-flex: 1;
    flex: 1;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    color: #1a1a2e;
    background: #fafafa;
    -webkit-transition: border-color 0.2s, background 0.2s;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
}

.sbc-ct-input:focus {
    border-color: #e94560;
    background: #fff;
}

.sbc-ct-input::-webkit-input-placeholder { color: #b0b0b0; }
.sbc-ct-input::placeholder { color: #b0b0b0; }

/* ============================================
   BUTTONS
   ============================================ */
.sbc-ct-submit-btn {
    display: -webkit-inline-flex;
    display: inline-flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 20px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    -webkit-transition: background 0.2s, -webkit-transform 0.1s;
    transition: background 0.2s, transform 0.1s;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    white-space: nowrap;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.sbc-ct-submit-btn:hover {
    background: #e94560;
}

.sbc-ct-submit-btn:active {
    -webkit-transform: scale(0.97);
    transform: scale(0.97);
}

.sbc-ct-submit-btn--full {
    width: 100%;
    margin-top: 4px;
}

.sbc-ct-submit-btn svg {
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

/* ============================================
   FORM FIELDS
   ============================================ */
.sbc-ct-form-field {
    margin-bottom: 12px;
}

.sbc-ct-form-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   CARRIER CHIPS
   ============================================ */
.sbc-ct-carrier-select {
    margin-top: 14px;
}

.sbc-ct-carrier-label {
    font-size: 12px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.sbc-ct-chips {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 6px;
}

.sbc-ct-chip {
    display: -webkit-inline-flex;
    display: inline-flex;
    -webkit-align-items: center;
    align-items: center;
    padding: 7px 14px;
    min-height: 36px;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    -webkit-transition: all 0.15s ease;
    transition: all 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    white-space: nowrap;
}

.sbc-ct-chip.active {
    border-color: #1a1a2e;
    background: #1a1a2e;
    color: #fff;
}

/* ============================================
   RESULT CARDS
   ============================================ */
.sbc-ct-result {
    margin-top: 16px;
}

.sbc-ct-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 12px;
    -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.03);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.03);
    border: 1px solid #f0f0f0;
}

.sbc-ct-card--error {
    border-color: #fecaca;
    background: #fef2f2;
}

.sbc-ct-card--error p {
    color: #dc2626;
    margin: 0;
    font-size: 14px;
    text-align: center;
    padding: 8px 0;
}

/* Carrier row in result */
.sbc-ct-card-carrier {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sbc-ct-card-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.sbc-ct-card-meta {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sbc-ct-card-meta strong {
    font-size: 15px;
    color: #1a1a2e;
}

.sbc-ct-card-meta code {
    font-size: 13px;
    color: #6b7280;
    background: none;
    padding: 0;
    letter-spacing: 0.5px;
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
    /* Uzun takip no'ları taşmasın */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.sbc-ct-card-btn {
    display: block;
    text-align: center;
    min-height: 48px;
    line-height: 48px;
    padding: 0 24px;
    background: #e94560;
    color: #fff !important;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none !important;
    -webkit-transition: background 0.2s, -webkit-transform 0.1s;
    transition: background 0.2s, transform 0.1s;
    touch-action: manipulation;
}

.sbc-ct-card-btn:hover {
    background: #d63851;
    color: #fff !important;
}

.sbc-ct-card-btn:active {
    -webkit-transform: scale(0.98);
    transform: scale(0.98);
}

.sbc-ct-card-note {
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
    margin: 12px 0 0;
    line-height: 1.5;
}

/* ============================================
   ORDER RESULT — TIMELINE (JS render)
   ============================================ */
.sbc-ct-order-header {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 8px;
}

.sbc-ct-order-label {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
}

.sbc-ct-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.sbc-ct-badge--processing { background: #dbeafe; color: #2563eb; }
.sbc-ct-badge--completed { background: #d1fae5; color: #059669; }
.sbc-ct-badge--delivered { background: #d1fae5; color: #059669; }
.sbc-ct-badge--on-hold { background: #fef3c7; color: #d97706; }
.sbc-ct-badge--cancelled { background: #fee2e2; color: #dc2626; }
.sbc-ct-badge--shipped { background: #d1fae5; color: #059669; }

/* Timeline in result */
.sbc-ct-timeline {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: flex-start;
    align-items: flex-start;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 4px;
}

.sbc-ct-step {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: center;
    align-items: center;
    position: relative;
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
}

.sbc-ct-step:last-child {
    -webkit-flex: 0 0 auto;
    flex: 0 0 auto;
}

.sbc-ct-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: #fff;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    color: #d1d5db;
    z-index: 2;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.sbc-ct-step-dot svg {
    display: none;
}

.sbc-ct-step.done .sbc-ct-step-dot {
    background: #1a1a2e;
    border-color: #1a1a2e;
    color: #fff;
}

.sbc-ct-step.done .sbc-ct-step-dot svg {
    display: block;
}

.sbc-ct-step.current .sbc-ct-step-dot {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
    -webkit-box-shadow: 0 0 0 4px rgba(233,69,96,0.12);
    box-shadow: 0 0 0 4px rgba(233,69,96,0.12);
}

.sbc-ct-step-line {
    position: absolute;
    top: 13px;
    left: calc(50% + 14px);
    right: calc(-50% + 14px);
    height: 2px;
    background: #e5e7eb;
}

.sbc-ct-step.done .sbc-ct-step-line {
    background: #1a1a2e;
}

.sbc-ct-step-label {
    font-size: 10px;
    font-weight: 700;
    color: #b0b0b0;
    margin-top: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.sbc-ct-step.done .sbc-ct-step-label {
    color: #1a1a2e;
}

.sbc-ct-step.current .sbc-ct-step-label {
    color: #e94560;
}

/* Shipment inside order result */
.sbc-ct-shipment {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 8px;
}

.sbc-ct-shipment-info {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sbc-ct-shipment-info strong {
    font-size: 14px;
    color: #1a1a2e;
    display: block;
}

.sbc-ct-shipment-info code {
    font-size: 12px;
    color: #6b7280;
    background: none;
    padding: 0;
    letter-spacing: 0.5px;
    font-family: "SF Mono", "Menlo", monospace;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sbc-ct-shipment-date {
    font-size: 11px;
    color: #9ca3af;
    display: block;
}

/* ============================================
   LOADING
   ============================================ */
.sbc-ct-loading {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
}

.sbc-ct-loader {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #e94560;
    border-radius: 50%;
    -webkit-animation: sbc-spin 0.7s linear infinite;
    animation: sbc-spin 0.7s linear infinite;
}

@-webkit-keyframes sbc-spin { to { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }
@keyframes sbc-spin { to { transform: rotate(360deg); } }

.sbc-ct-loading p {
    color: #6b7280;
    font-size: 13px;
    margin: 0;
}

/* ============================================
   CARRIER GRID
   ============================================ */
.sbc-ct-carriers {
    margin-top: 24px;
}

.sbc-ct-carriers-title {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sbc-ct-carrier-grid {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 4px;
}

.sbc-ct-carrier-item {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-height: 48px;
    background: #fff;
    border-radius: 10px;
    text-decoration: none !important;
    color: #1a1a2e !important;
    border: 1px solid #f0f0f0;
    -webkit-transition: all 0.15s ease;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.sbc-ct-carrier-item:hover,
.sbc-ct-carrier-item:active {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1a1a2e !important;
}

.sbc-ct-carrier-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
}

.sbc-ct-carrier-text {
    -webkit-flex: 1;
    flex: 1;
    font-size: 14px;
    font-weight: 600;
}

.sbc-ct-carrier-chevron {
    color: #d1d5db;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    -webkit-transition: color 0.15s;
    transition: color 0.15s;
}

.sbc-ct-carrier-item:hover .sbc-ct-carrier-chevron {
    color: #e94560;
}

/* ============================================
   MOBILE / WEBVIEW RESPONSIVE
   ============================================ */

/* WebView genelde 360-414px genişliğinde */
@media (max-width: 480px) {
    .sbc-ct {
        padding: 0 12px;
        /* safe area (notch) desteği */
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .sbc-ct-search-box {
        padding: 16px;
        border-radius: 12px;
    }

    .sbc-ct-tab {
        padding: 12px 8px;
        font-size: 13px;
        gap: 6px;
    }

    .sbc-ct-tab-icon svg {
        width: 16px;
        height: 16px;
    }

    /* Chip'ler mobilde horizontal scroll */
    .sbc-ct-chips {
        -webkit-flex-wrap: nowrap;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
        margin: 0 -4px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .sbc-ct-chips::-webkit-scrollbar {
        display: none;
    }

    .sbc-ct-input-group {
        -webkit-flex-direction: column;
        flex-direction: column;
    }

    .sbc-ct-submit-btn {
        width: 100%;
    }

    /* Timeline labels küçült */
    .sbc-ct-step-dot {
        width: 24px;
        height: 24px;
    }

    .sbc-ct-step-dot svg {
        width: 10px;
        height: 10px;
    }

    .sbc-ct-step-line {
        top: 11px;
        left: calc(50% + 12px);
        right: calc(-50% + 12px);
    }

    .sbc-ct-step-label {
        font-size: 8px;
        letter-spacing: 0;
    }

    .sbc-ct-card {
        padding: 16px;
        border-radius: 12px;
    }

    .sbc-ct-card-btn {
        min-height: 44px;
        line-height: 44px;
        font-size: 14px;
        border-radius: 10px;
    }
}

/* Çok küçük ekranlar (eski telefonlar, 320px) */
@media (max-width: 360px) {
    .sbc-ct {
        padding: 0 8px;
    }

    .sbc-ct-search-box {
        padding: 14px 12px;
    }

    .sbc-ct-tab {
        font-size: 12px;
        padding: 10px 6px;
    }

    .sbc-ct-step-label {
        font-size: 7px;
    }

    .sbc-ct-step-dot {
        width: 20px;
        height: 20px;
    }

    .sbc-ct-step-line {
        top: 9px;
        left: calc(50% + 10px);
        right: calc(-50% + 10px);
    }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .sbc-ct {
        max-width: 560px;
    }
}

/* ============================================
   WEBVIEW SPECIFIC FIXES
   ============================================ */

/* Android WebView'da input zoom engelleme */
@media screen and (max-width: 480px) {
    .sbc-ct-input {
        font-size: 16px; /* iOS zoom'u engeller */
    }
}

/* Koyu mod desteği (bazı WebView'lar force dark mode) */
@media (prefers-color-scheme: dark) {
    .sbc-ct-card,
    .sbc-ct-search-box,
    .sbc-ct-carrier-item {
        /* Açık renk kalmasını garanti et */
        color-scheme: light;
    }
}

/* High contrast / Accessibility */
@media (prefers-contrast: high) {
    .sbc-ct-chip.active {
        border-width: 3px;
    }
    
    .sbc-ct-step-dot {
        border-width: 3px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sbc-ct-loader {
        -webkit-animation: none;
        animation: none;
        border-top-color: #e94560;
        opacity: 0.7;
    }
    
    .sbc-ct *,
    .sbc-ct *::before,
    .sbc-ct *::after {
        -webkit-transition-duration: 0s !important;
        transition-duration: 0s !important;
    }
}
