/* eSIM Compatibility Check — mobile-first styles */

:root {
    --bg: #f5f5f5;
    --bg-tg: #f0f0f0;
    --card-bg: #fff;
    --card-shadow: rgba(0,0,0,0.08);
    --card-shadow-light: rgba(0,0,0,0.06);
    --heading: #1a1a2e;
    --text: #333;
    --text-secondary: #555;
    --hint: #888;
    --hint-light: #aaa;
    --border: #e4e4e4;
    --border-light: #f0f0f0;
    --placeholder: #a8a8a8;
    --hover-bg: #f5f9ff;
    --active-bg: #e8f0fe;
    --link: #2196F3;
    --link-hover: #1565C0;
    --cta-hover: #1976D2;
    --clear-bg: #d0d0d0;
    --clear-hover: #b0b0b0;
    --arrow-color: #c4c4c4;
    --skeleton-bg: #e8e8e8;
    --check-bg: #fffbf0;
    --check-border: #f5e6c8;
    --apple-bg: #f0f5ff;
    --apple-text: #4a6fa5;
    --logo-bg: #f1f3f6;
    --yes: #27ae60;
    --no: #e74c3c;
    --check: #f39c12;
    --yes-bg: #e8f8ef;
    --no-bg: #fde8e8;
    --check-badge-bg: #fef5e7;
    --check-text: #e67e22;
    --toggle-bg: #ddd;
    --toggle-knob: #fff;
    --debug-bg: #1a1a2e;
    --debug-toggle-bg: #eee;
    --debug-toggle-color: #999;
    --debug-text: #a0e0a0;
    --focus: #2196F3;
}

[data-theme="dark"] {
    --bg: #1a1a1a;
    --bg-tg: #1a1a1a;
    --card-bg: #2a2a2a;
    --card-shadow: rgba(0,0,0,0.3);
    --card-shadow-light: rgba(0,0,0,0.2);
    --heading: #f0f0f0;
    --text: #ddd;
    --text-secondary: #bbb;
    --hint: #999;
    --hint-light: #777;
    --border: #444;
    --border-light: #3a3a3a;
    --placeholder: #777;
    --hover-bg: #333;
    --active-bg: #3a3a3a;
    --link: #64b5f6;
    --link-hover: #90caf9;
    --cta-hover: #1976D2;
    --clear-bg: #555;
    --clear-hover: #777;
    --arrow-color: #666;
    --skeleton-bg: #3a3a3a;
    --check-bg: #2a2518;
    --check-border: #4a3f2e;
    --apple-bg: #1e2a3a;
    --apple-text: #7aa3d4;
    --logo-bg: #353535;
    --yes: #4cdb80;
    --no: #f87171;
    --check: #f5b041;
    --yes-bg: #1a3a25;
    --no-bg: #3a1a1a;
    --check-badge-bg: #3a2f1a;
    --check-text: #f5b041;
    --toggle-bg: #555;
    --toggle-knob: #ddd;
    --debug-bg: #111;
    --debug-toggle-bg: #333;
    --debug-toggle-color: #888;
    --focus: #64b5f6;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 16px calc(72px + env(safe-area-inset-bottom, 0px));
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.3s, color 0.3s;
}

body.tg-mode { background: var(--bg-tg); padding-top: 8px; }

button { font-family: inherit; }

.hidden { display: none !important; }

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

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

header, .search-section, .state, #main, .debug-panel { width: 100%; max-width: 480px; }

/* ---------- Header ---------- */
header { text-align: center; margin-bottom: 14px; }

header h1 { font-size: 22px; font-weight: 700; color: var(--heading); line-height: 1.25; }

.subtitle { margin-top: 6px; font-size: 14px; color: var(--hint); line-height: 1.4; }

.tg-mode header { display: none; }

/* ---------- Search (sticky) ---------- */
.search-section {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 6px 0 10px;
    margin-bottom: 6px;
    background: var(--bg);
    transition: background 0.3s;
}

.tg-mode .search-section { background: var(--bg-tg); padding-top: 0; }

#device-search {
    width: 100%;
    height: 50px;
    padding: 0 48px 0 16px;
    border: 2px solid var(--border);
    border-radius: 14px;
    font-size: 16px;            /* 16px keeps iOS from zooming the page on focus */
    font-family: inherit;
    outline: none;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s, background 0.3s, color 0.3s;
    -webkit-appearance: none;
    appearance: none;
}

#device-search:focus { border-color: var(--link); outline: none; }
#device-search::placeholder { color: var(--placeholder); }

.search-clear {
    position: absolute;
    right: 4px;
    top: 6px;
    width: 44px;
    height: 50px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.search-clear::before {
    content: "\00d7";
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--clear-bg);
    font-size: 18px;
    transition: background 0.15s;
}

.search-clear:active::before { background: var(--clear-hover); }

/* ---------- States ---------- */
.state { animation: fadeIn 0.25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }

/* ---------- Loading ---------- */
.loading-skeleton {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 2px 12px var(--card-shadow-light);
}

.skeleton-image { width: 110px; height: 110px; border-radius: 50%; background: var(--skeleton-bg); margin: 0 auto 16px; }
.skeleton-text { height: 18px; background: var(--skeleton-bg); border-radius: 9px; margin: 8px auto; width: 60%; }
.skeleton-text.short { width: 40%; }
.pulse { animation: pulse 1.5s ease-in-out infinite; }
.detecting-text { text-align: center; margin-top: 14px; color: var(--hint); font-size: 14px; }

/* ---------- Result card ---------- */
.result-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 26px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 2px 16px var(--card-shadow);
    animation: slideUp 0.35s ease;
    border-top: 5px solid var(--check);
    transition: background 0.3s, box-shadow 0.3s;
}

.result-card.result-yes { border-top-color: var(--yes); }
.result-card.result-no { border-top-color: var(--no); }
.result-card.result-check { border-top-color: var(--check); }

.result-caption {
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--hint);
    margin-bottom: 14px;
    min-height: 0;
}

.result-caption:empty { display: none; }

.device-image-wrap {
    width: 104px; height: 104px;
    border-radius: 50%;
    background: var(--logo-bg);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
    overflow: hidden;
    transition: background 0.3s;
}

.device-image-wrap img { width: 84px; height: 84px; object-fit: contain; }

.device-image-wrap .vendor-logo { width: 100%; height: 100%; }
.device-image-wrap .vendor-logo img { width: 56px; height: 56px; max-width: 60%; }

.device-vendor {
    font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px;
}

.device-vendor:empty { display: none; }

.device-model { font-size: 22px; font-weight: 700; color: var(--heading); margin-bottom: 18px; line-height: 1.25; }

.result-badge {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 10px 18px 10px 12px;
    border-radius: 999px;
    font-size: 16px; font-weight: 600;
}

.result-badge.badge-yes { background: var(--yes-bg); color: var(--yes); }
.result-badge.badge-no { background: var(--no-bg); color: var(--no); }
.result-badge.badge-check { background: var(--check-badge-bg); color: var(--check-text); }

.result-icon.status-dot { width: 26px; height: 26px; font-size: 15px; animation: popIn 0.4s ease 0.15s both; }

.result-hint { margin-top: 12px; font-size: 14px; color: var(--text-secondary); line-height: 1.45; max-width: 320px; }

/* Status dots (lists and badge) */
.status-dot {
    flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    color: #fff; font-size: 13px; font-weight: 700; line-height: 1;
}

.status-dot.status-yes { background: var(--yes); }
.status-dot.status-no { background: var(--no); }
.status-dot.status-check { background: var(--check); }

/* Instructions */
.check-instructions {
    width: 100%;
    text-align: left;
    margin-top: 18px;
    padding: 14px 14px 12px;
    background: var(--check-bg);
    border-radius: 12px;
    border: 1px solid var(--check-border);
}

.check-instructions h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; color: var(--text); }

.instruction-item {
    display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 10px; font-size: 14px; color: var(--text-secondary); line-height: 1.5;
}

.instruction-item:last-child { margin-bottom: 0; }
.instruction-icon { flex-shrink: 0; font-size: 16px; }

.apple-note {
    width: 100%;
    margin-top: 12px; padding: 10px 14px;
    background: var(--apple-bg); border-radius: 10px;
    font-size: 13px; color: var(--apple-text); line-height: 1.5;
}

/* CTA */
.cta-button {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%;
    min-height: 52px;
    margin-top: 20px;
    padding: 0 24px;
    background: var(--link);
    color: #fff;
    font-size: 17px; font-weight: 600;
    border: none; border-radius: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.cta-button:active { transform: scale(0.98); background: var(--cta-hover); }
.cta-arrow { font-size: 18px; }

/* Secondary action under the card */
.result-actions { margin-top: 14px; text-align: center; }
.result-actions-text { font-size: 14px; color: var(--hint); margin-bottom: 8px; }
.result-actions-text:empty { display: none; }

.btn-secondary {
    display: flex; align-items: center; justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    background: var(--card-bg);
    color: var(--link);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-size: 16px; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:active { background: var(--active-bg); }

/* ---------- Step headers ---------- */
.step-header { margin: 2px 2px 10px; }
.step-header h2 { font-size: 18px; font-weight: 700; color: var(--heading); line-height: 1.3; }
.step-note { font-size: 13px; color: var(--hint); margin-top: 3px; line-height: 1.4; }

.step-header-model { display: flex; align-items: center; gap: 8px; margin-left: -4px; }
.step-header-vendor { display: flex; align-items: center; gap: 12px; min-width: 0; }
.step-header-vendor .vendor-logo { width: 36px; height: 36px; }
.step-header-vendor .step-note { margin-top: 1px; }

.back-button {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border: none; border-radius: 50%;
    background: transparent;
    color: var(--link);
    font-size: 30px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

.back-button:active { background: var(--active-bg); }
.back-button .back-arrow { position: relative; top: -2px; }

/* ---------- Lists ---------- */
.list-card {
    background: var(--card-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--card-shadow-light);
    transition: background 0.3s, box-shadow 0.3s;
}

.list-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid var(--border-light);
    background: transparent;
    color: var(--text);
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--active-bg); }

.list-item-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list-item-name { flex: 1; min-width: 0; color: var(--text); line-height: 1.3; }
.list-item-sub { font-size: 13px; color: var(--hint); margin-top: 2px; }
.list-item-arrow { font-size: 22px; color: var(--arrow-color); margin-left: auto; line-height: 1; }

.list-loading { padding: 18px 16px; color: var(--hint); font-size: 15px; }

.empty-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 22px 18px;
    text-align: center;
    color: var(--hint);
    font-size: 15px;
    box-shadow: 0 2px 8px var(--card-shadow-light);
}

.empty-card p { margin-bottom: 14px; }

.not-found-row {
    margin-top: 14px;
    text-align: center;
    font-size: 14px;
    color: var(--hint);
    line-height: 1.5;
}

.link-button {
    background: none; border: none;
    color: var(--link);
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    padding: 10px 8px;      /* ~44px tall tap target */
    min-height: 44px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---------- Vendor logos ---------- */
.vendor-logo {
    width: 30px; height: 30px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}

.vendor-logo img { max-width: 30px; max-height: 30px; width: auto; height: auto; object-fit: contain; transition: filter 0.3s; }

[data-theme="dark"] .vendor-logo-dark img { filter: brightness(0) invert(0.8); }

/* ---------- Bottom bar ---------- */
.bottom-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: center; gap: 14px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--hint-light);
    z-index: 10;
    transition: background 0.3s, color 0.3s;
}

.lang-select-wrap { display: inline-flex; align-items: center; }

.lang-select {
    -webkit-appearance: none;
    appearance: none;
    background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    height: 34px;
    padding: 0 28px 0 12px;
    cursor: pointer;
}

.theme-toggle {
    position: relative;
    display: inline-block;
    width: 56px; height: 32px;
    border-radius: 16px;
    background: var(--toggle-bg);
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.3s;
}

.theme-toggle .toggle-knob {
    position: absolute; top: 3px; left: 3px;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--toggle-knob);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform 0.3s;
}

[data-theme="dark"] .theme-toggle .toggle-knob { transform: translateX(24px); }

.theme-toggle-icon { position: absolute; top: 50%; transform: translateY(-50%); font-size: 14px; line-height: 1; pointer-events: none; }
.theme-toggle-icon.sun { left: 7px; }
.theme-toggle-icon.moon { right: 6px; }

/* ---------- Debug panel ---------- */
.debug-panel { margin-top: 16px; }

.debug-toggle {
    text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 1px;
    color: var(--debug-toggle-color); cursor: pointer; padding: 6px;
    background: var(--debug-toggle-bg); border-radius: 8px; user-select: none;
}

.debug-details { margin-top: 6px; background: var(--debug-bg); border-radius: 10px; padding: 12px; overflow-x: auto; }

.debug-details pre {
    font-family: "SF Mono", "Fira Code", monospace; font-size: 11px; color: var(--debug-text);
    white-space: pre-wrap; word-break: break-all; line-height: 1.6;
}

/* ---------- Hover only where a pointer exists ---------- */
@media (hover: hover) {
    .list-item:hover { background: var(--hover-bg); }
    .cta-button:hover { background: var(--cta-hover); }
    .cta-button:hover .cta-arrow { transform: translateX(3px); }
    .btn-secondary:hover { border-color: var(--link); }
    .link-button:hover { color: var(--link-hover); }
    .back-button:hover { background: var(--hover-bg); }
    .search-clear:hover::before { background: var(--clear-hover); }
}

/* ---------- Small phones ---------- */
@media (max-width: 360px) {
    body { padding-left: 12px; padding-right: 12px; }
    .result-card { padding: 22px 16px 20px; }
    .device-model { font-size: 20px; }
    .list-item { padding-left: 14px; padding-right: 14px; }
}

/* ---------- Short viewports (landscape phones) ---------- */
@media (max-height: 500px) {
    header { margin-bottom: 8px; }
    .subtitle { display: none; }
    .result-card { padding: 18px 16px; }
    .device-image-wrap { width: 72px; height: 72px; margin-bottom: 10px; }
    .device-image-wrap img { width: 56px; height: 56px; }
}

/* ---------- Tablets / desktop ---------- */
@media (min-width: 600px) {
    body { padding-top: 32px; }
    header, .search-section, .state, #main, .debug-panel { max-width: 520px; }
    header h1 { font-size: 26px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
