/* ============================================================================
   Fraley Tutors — Notification Settings (Phase 7b)
   Self-contained styles. Brand variables come from /brand.css (injected by
   scripts/inject_pwa_meta.py). Layout/header/login styles deliberately mirror
   portal.css so the page reads as part of the suite without depending on it
   (the redesign on master churns portal.css/tutor.css).
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--brand-gradient, linear-gradient(160deg, #0d1b2a 0%, #162d44 100%));
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* ---- Header --------------------------------------------------------------- */
header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    max-width: 120px;
    height: auto;
    flex-shrink: 0;
}

.header-text { text-align: left; }

header h1 {
    color: var(--brand-teal, #00cec9);
    font-size: 2.2em;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    font-size: 1.05em;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.user-email { font-size: 13px; color: #666; }

.nav-link {
    display: inline-block;
    padding: 8px 18px;
    border: 2px solid var(--brand-teal, #00cec9);
    border-radius: 8px;
    color: var(--brand-teal, #00cec9);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.nav-link:hover { background: var(--brand-teal, #00cec9); color: white; }

.logout-btn {
    padding: 8px 18px;
    background: transparent;
    border: 2px solid var(--brand-teal, #00cec9);
    border-radius: 8px;
    color: var(--brand-teal, #00cec9);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.logout-btn:hover { background: var(--brand-teal, #00cec9); color: white; }

/* ---- Cards ---------------------------------------------------------------- */
.settings-card {
    background: white;
    border-radius: 15px;
    padding: 28px 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
}

.settings-card h2 {
    color: var(--brand-navy, #0d1b2a);
    font-size: 1.25em;
    margin-bottom: 6px;
}

.card-intro, .device-status {
    color: #666;
    font-size: 14px;
    margin-bottom: 18px;
}

.device-status { font-weight: 600; color: #333; }

.device-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.primary-btn {
    padding: 11px 22px;
    background: var(--brand-teal, #00cec9);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.primary-btn:hover:not(:disabled) { background: var(--brand-teal-hover, #00b3ae); }
.primary-btn:disabled, .secondary-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.secondary-btn {
    padding: 11px 22px;
    background: transparent;
    color: #c0392b;
    border: 2px solid #c0392b;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.secondary-btn:hover:not(:disabled) { background: #c0392b; color: white; }

.device-note {
    color: #888;
    font-size: 13px;
    line-height: 1.5;
}

.inline-msg {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
}
.inline-msg.ok  { background: #e7f8f1; color: #1b7a52; }
.inline-msg.err { background: #fdecea; color: #c0392b; }

/* ---- Toggles -------------------------------------------------------------- */
.toggles { display: flex; flex-direction: column; }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #eee;
}
.toggle-row:last-child { border-bottom: none; }

.toggle-text { flex: 1; min-width: 0; }
.toggle-label { font-weight: 600; font-size: 15px; color: #333; }
.toggle-desc  { font-size: 13px; color: #888; margin-top: 2px; }

.loading-row, .error-row { color: #888; font-size: 14px; padding: 8px 0; }
.error-row { color: #c0392b; }

.saved-tag {
    font-size: 12px;
    min-width: 56px;
    text-align: right;
    white-space: nowrap;
}
.saved-tag.saving { color: #999; }
.saved-tag.ok     { color: #1b7a52; }
.saved-tag.err    { color: #c0392b; }

/* iOS-style switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 28px;
    transition: background 0.2s;
}
.slider::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--brand-teal, #00cec9); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:disabled + .slider { opacity: 0.6; cursor: not-allowed; }

/* ---- Login overlay (mirrors portal.css) ----------------------------------- */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--brand-gradient, linear-gradient(160deg, #0d1b2a 0%, #162d44 100%));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.login-box {
    background: white;
    border-radius: 20px;
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.login-logo { max-width: 120px; height: auto; margin-bottom: 20px; }
.login-box h2 { color: var(--brand-teal, #00cec9); font-size: 1.8em; margin-bottom: 6px; }
.login-subtitle { color: #888; font-size: 0.95em; margin-bottom: 30px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form input {
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
    outline: none;
}
.login-form input:focus { border-color: var(--brand-teal, #00cec9); }
.login-form button {
    padding: 14px;
    background: var(--brand-teal, #00cec9);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.login-form button:hover:not(:disabled) { background: var(--brand-teal-hover, #00b3ae); }
.login-form button:disabled { opacity: 0.65; cursor: not-allowed; }
.login-error { color: #c0392b; font-size: 14px; min-height: 18px; }

/* ---- Small screens -------------------------------------------------------- */
@media screen and (max-width: 640px) {
    .header-content { flex-wrap: wrap; }
    .header-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
    header h1 { font-size: 1.8em; }
}
