/* Softphone Portal — mobile-first stylesheet for the Cloud Softphone web tab.
   Deliberately standalone (no Bootstrap/SmartAdmin): five screens of stacked cards
   rendered in a ~375px webview. */

:root {
    --bg: #f2f4f7;
    --card: #ffffff;
    --text: #1a2233;
    --text-muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-press: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warn-bg: #fef9c3;
    --warn-text: #854d0e;
    --radius: 12px;
    --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px; /* >=16px prevents iOS focus zoom */
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0 0 .5rem 0; font-weight: 600; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .75rem 0; }

/* ---- Shell ---- */

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom));
}

.page.no-nav { padding-bottom: 24px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding: 10px 2px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.topbar .title { font-size: 1.15rem; font-weight: 700; }
.topbar .who { font-size: .8rem; color: var(--text-muted); text-align: right; }

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
    flex: 1;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: .75rem;
    font-weight: 600;
}

.bottom-nav a.active { color: var(--primary); }
.bottom-nav .nav-icon { font-size: 1.25rem; line-height: 1; }

/* ---- Cards ---- */

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.card-title h2 { margin: 0; }

.hint { color: var(--text-muted); font-size: .85rem; margin: .25rem 0 0; }

/* ---- Form rows ---- */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }

input[type="text"], input[type="tel"], select {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input:disabled, select:disabled { background-color: var(--bg); color: var(--text-muted); }

/* ---- Toggle switch rows ---- */

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: var(--tap);
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
}

.switch-row:last-child { border-bottom: none; }
.switch-row .switch-label { font-size: .95rem; }
.switch-row .switch-sub { display: block; font-size: .78rem; color: var(--text-muted); }

.switch {
    position: relative;
    flex: 0 0 auto;
    width: 50px;
    height: 30px;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background .15s ease;
    pointer-events: none;
}

.switch .slider::before {
    content: "";
    position: absolute;
    width: 26px;
    height: 26px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,.25);
    transition: transform .15s ease;
}

.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: .5; }

/* ---- Radio strategy cards ---- */

.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
}

.radio-card input[type="radio"] { width: 20px; height: 20px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--primary); }
.radio-card.selected { border-color: var(--primary); background: #eff6ff; }
.radio-card.disabled { opacity: .55; cursor: not-allowed; }
.radio-card .radio-title { font-weight: 600; font-size: .95rem; }
.radio-card .radio-sub { font-size: .8rem; color: var(--text-muted); }
.radio-card .radio-body { flex: 1; }
.radio-card .radio-body .field { margin: 10px 0 0; }

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-press); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
    min-width: var(--tap);
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
}

/* ---- Save bar ---- */

.save-bar {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom));
    z-index: 15;
    padding: 8px 0;
}

.page.no-nav .save-bar { bottom: 8px; }

/* ---- Sub-tabs (period / panel selection) ---- */

.subtabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.subtabs button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.subtabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- Lists ---- */

.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: var(--tap);
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.item-row:last-child { border-bottom: none; }
.item-row .item-main { flex: 1; min-width: 0; }
.item-row .item-title { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .item-sub { font-size: .8rem; color: var(--text-muted); }

/* ---- Badges + alerts ---- */

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-info { background: #dbeafe; color: #1e40af; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-ok { background: #dcfce7; color: #166534; }

.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: .9rem;
}

.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---- Weekday hours rows ---- */

.day-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
}

.day-row:last-child { border-bottom: none; }
.day-row .day-name { flex: 0 0 44px; font-weight: 600; font-size: .9rem; }
.day-row .day-times { flex: 1; display: flex; align-items: center; gap: 6px; }
.day-row .day-times select { min-height: 40px; padding: 6px 26px 6px 8px; font-size: .9rem; }
.day-row .day-times .to { color: var(--text-muted); font-size: .8rem; }
.day-row .closed-note { flex: 1; color: var(--text-muted); font-size: .9rem; }

/* ---- Loading / centered states ---- */

.center-screen {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.center-screen .big-icon { font-size: 3rem; margin-bottom: 12px; }

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

#blazor-error-ui {
    background: var(--warn-bg);
    color: var(--warn-text);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
