/* =============================================================
   בתכלס אנחנו יכולים הכל — Design System
   רקע: כחול-סגול עמוק | קווים: זהב | אנרגיה: טורקיז + פוקסיה
   ============================================================= */

:root {
    --bg-deep: #0a0d2c;
    --bg-deep-2: #10143a;
    --bg-card: #141a48;
    --bg-card-soft: rgba(255, 255, 255, 0.045);
    --gold: #d4a853;
    --gold-soft: rgba(212, 168, 83, 0.35);
    --turquoise: #17e8d0;
    --fuchsia: #ff3ea5;
    --gradient-energy: linear-gradient(135deg, var(--turquoise) 0%, var(--fuchsia) 100%);
    --text-primary: #f6f4ff;
    --text-muted: #a7a9d6;
    --text-faint: #7477a3;
    --danger: #ff5470;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --shadow-glow: 0 8px 30px rgba(255, 62, 165, 0.18), 0 4px 18px rgba(23, 232, 208, 0.12);
    --font-display: 'Heebo', 'Assistant', sans-serif;
    --font-body: 'Assistant', 'Heebo', sans-serif;
}

* { box-sizing: border-box; }

html {
    color-scheme: dark; /* מונע מהדפדפן לצייר כפתורים/שדות בתמה בהירה של המערכת */
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

/* מבטל את העיצוב הילידי (native) של iOS/Android לאלמנטי טופס,
   כדי שהעיצוב שלנו (גרדיאנטים, רקעים כהים) יוצג במקום כפתורים/שדות ברירת מחדל */
button, input, textarea, select {
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    border-radius: 0;
}

/* מתקן את הצביעה הצהובה שדפדפנים מוסיפים אוטומטית לשדות עם autofill */
input:-webkit-autofill,
textarea:-webkit-autofill {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0px 1000px rgba(255,255,255,0.06) inset;
    box-shadow: 0 0 0px 1000px rgba(255,255,255,0.06) inset;
    transition: background-color 9999s ease-in-out 0s;
    caret-color: var(--text-primary);
}

body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 15% -10%, rgba(23, 232, 208, 0.14), transparent 60%),
        radial-gradient(ellipse 70% 50% at 100% 0%, rgba(255, 62, 165, 0.13), transparent 60%),
        var(--bg-deep);
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; }

button { font-family: inherit; cursor: pointer; }
textarea, input { font-family: inherit; }

a { color: var(--turquoise); text-decoration: none; }

.hidden { display: none !important; }

/* =============================== APP SHELL =============================== */

.app-shell {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: rgba(10, 13, 44, 0.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gold-soft);
}

.app-header-brand { display: flex; align-items: center; gap: 10px; }
.brand-emoji { font-size: 28px; filter: drop-shadow(0 0 8px rgba(212,168,83,0.6)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: 0.2px; }
.brand-sub { font-size: 12.5px; color: var(--text-muted); }

.btn-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    color: var(--gold);
    background: var(--bg-card-soft);
    border: 1px solid var(--gold-soft);
    transition: transform .15s ease, background .15s ease;
}
.btn-icon:active { transform: scale(0.92); background: rgba(212,168,83,0.15); }

/* =============================== MAIN / TABS =============================== */

.app-main {
    flex: 1;
    padding-bottom: 100px;
}

.tab-panel { display: none; animation: fadeSlideIn .35s ease; }
.tab-panel.active { display: block; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel-inner { padding: 22px 18px 10px; }

.panel-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 10px;
    background: var(--gradient-energy);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.panel-lead {
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.65;
    margin-bottom: 22px;
}

/* =============================== CARDS =============================== */

.timer-card, .converter-card, .gratitude-card, .rule-card {
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep-2) 100%);
    border: 1px solid var(--gold-soft);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-glow);
}

.timer-card { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }

/* =============================== FIELDS =============================== */

.field-label { font-size: 13px; color: var(--gold); font-weight: 600; margin-bottom: 6px; display: block; }

.field-textarea, .field-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 12px 14px;
    font-size: 15px;
    resize: vertical;
    transition: border-color .2s ease, box-shadow .2s ease;
}
.field-textarea:focus, .field-input:focus {
    outline: none;
    border-color: var(--turquoise);
    box-shadow: 0 0 0 3px rgba(23,232,208,0.15);
}
.field-textarea::placeholder, .field-input::placeholder { color: var(--text-faint); }

/* =============================== BUTTONS =============================== */

.btn-primary, .btn-secondary, .btn-ghost {
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 700;
    transition: transform .12s ease, filter .15s ease, opacity .15s ease;
}
.btn-primary {
    background: var(--gradient-energy);
    color: #0a0d2c;
    box-shadow: 0 6px 20px rgba(255,62,165,0.3);
}
.btn-secondary {
    background: transparent;
    color: var(--gold);
    border: 1.5px solid var(--gold);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.12);
}
.btn-block { width: 100%; display: block; }
.btn-primary:active, .btn-secondary:active, .btn-ghost:active { transform: scale(0.98); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.55; pointer-events: none; }

/* =============================== TIMER RING =============================== */

.timer-ring-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 6px auto;
}

.timer-ring { transform: rotate(-90deg); filter: drop-shadow(0 0 14px rgba(255,62,165,0.35)); }

.ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.08);
    stroke-width: 10;
}

.ring-progress {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 565.48; /* 2 * PI * 90 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset linear;
}

.timer-center {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-number { font-family: var(--font-display); font-size: 44px; font-weight: 800; line-height: 1; }
.timer-unit { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.timer-actions { display: flex; flex-direction: column; gap: 10px; }

.timer-message {
    text-align: center;
    font-size: 14px;
    color: var(--turquoise);
    min-height: 20px;
    font-weight: 600;
}

/* =============================== RULES GRID =============================== */

.rules-grid { display: flex; flex-direction: column; gap: 14px; }

.rule-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
}

.rule-number {
    flex-shrink: 0;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--gradient-energy);
    color: #0a0d2c;
    font-weight: 800;
    font-family: var(--font-display);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
}

.rule-content { flex: 1; }
.rule-title { font-size: 15.5px; font-weight: 700; color: var(--gold); margin-bottom: 4px; }
.rule-text { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin: 0; }

/* =============================== CONVERTER =============================== */

.converter-card { display: flex; flex-direction: column; gap: 12px; }
.converter-actions { display: flex; flex-direction: column; gap: 10px; }

.converted-box {
    background: rgba(23,232,208,0.08);
    border: 1px solid rgba(23,232,208,0.35);
    border-radius: var(--radius-sm);
    padding: 14px;
    animation: fadeSlideIn .3s ease;
}
.refined-box {
    background: rgba(255,62,165,0.08);
    border: 1px solid rgba(255,62,165,0.35);
}
.converted-label { font-size: 12px; font-weight: 700; color: var(--turquoise); display: block; margin-bottom: 6px; }
.refined-box .converted-label { color: var(--fuchsia); }
.converted-text { margin: 0; font-size: 14.5px; line-height: 1.6; }

/* =============================== GRATITUDE =============================== */

.gratitude-card { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

.segmented {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 4px;
}
.segmented-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    transition: background .2s ease, color .2s ease;
}
.segmented-btn.active {
    background: var(--gradient-energy);
    color: #0a0d2c;
}

.gratitude-list { display: flex; flex-direction: column; gap: 10px; }

.gratitude-item {
    background: var(--bg-card-soft);
    border: 1px solid rgba(255,255,255,0.08);
    border-inline-start: 3px solid var(--gold);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gratitude-item.evening { border-inline-start-color: var(--fuchsia); }
.gratitude-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-faint);
}
.gratitude-item-content { font-size: 14.5px; line-height: 1.55; }
.gratitude-delete {
    background: none; border: none; color: var(--text-faint); font-size: 12px;
    padding: 2px 6px;
}
.gratitude-delete:hover { color: var(--danger); }

.empty-state { color: var(--text-faint); text-align: center; font-size: 14px; padding: 30px 0; }

/* =============================== CHAT =============================== */

.chat-shell {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 74px - 78px);
    min-height: 420px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gold-soft);
}
.chat-avatar {
    width: 42px; height: 42px;
    background: var(--gradient-energy);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.chat-title { font-weight: 800; font-family: var(--font-display); font-size: 15px; }
.chat-status { font-size: 12px; color: var(--text-muted); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14.5px;
    line-height: 1.55;
    animation: fadeSlideIn .25s ease;
}
.chat-bubble p { margin: 0; }

.chat-bubble-assistant {
    align-self: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--gold-soft);
    border-start-start-radius: 4px;
}
.chat-bubble-user {
    align-self: flex-start;
    background: var(--gradient-energy);
    color: #0a0d2c;
    font-weight: 600;
    border-start-end-radius: 4px;
}
.chat-bubble-crisis {
    align-self: flex-end;
    background: rgba(255, 84, 112, 0.12);
    border: 1px solid rgba(255, 84, 112, 0.5);
}
.chat-bubble-crisis a {
    color: var(--danger);
    font-weight: 800;
    text-decoration: underline;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0 18px 8px;
}
.typing-indicator span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--gold-soft);
    background: rgba(10,13,44,0.9);
}
.chat-input {
    flex: 1;
    resize: none;
    max-height: 100px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 11px 16px;
    color: var(--text-primary);
    font-size: 14.5px;
}
.chat-input:focus { outline: none; border-color: var(--turquoise); }
.chat-send-btn {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-energy);
    color: #0a0d2c;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(255,62,165,0.35);
}
.chat-send-btn:active { transform: scale(0.92); }

/* =============================== BOTTOM NAV =============================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 560px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(10, 13, 44, 0.94);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--gold-soft);
    padding: 8px 6px calc(env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 30;
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 12px;
    transition: color .2s ease, transform .15s ease;
    flex: 1;
}
.nav-btn svg { transition: filter .2s ease; }
.nav-btn.active { color: var(--turquoise); }
.nav-btn.active svg { filter: drop-shadow(0 0 6px rgba(23,232,208,0.6)); }
.nav-btn:active { transform: scale(0.93); }

/* =============================== AUTH PAGES =============================== */

.auth-body {
    background:
        radial-gradient(ellipse 80% 50% at 15% -10%, rgba(23, 232, 208, 0.16), transparent 60%),
        radial-gradient(ellipse 70% 50% at 100% 10%, rgba(255, 62, 165, 0.16), transparent 60%),
        var(--bg-deep);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-deep-2) 100%);
    border: 1px solid var(--gold-soft);
    border-radius: var(--radius-lg);
    padding: 32px 26px;
    box-shadow: var(--shadow-glow);
    text-align: center;
}

.auth-logo { font-size: 40px; margin-bottom: 6px; filter: drop-shadow(0 0 10px rgba(212,168,83,0.5)); }
.auth-title {
    font-size: 21px;
    font-weight: 800;
    background: var(--gradient-energy);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}
.auth-subtitle { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; }

.auth-form { display: flex; flex-direction: column; gap: 12px; text-align: right; }
.auth-form .btn-primary { margin-top: 8px; }

.auth-switch { margin-top: 20px; font-size: 13.5px; color: var(--text-muted); }

.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    text-align: right;
    font-size: 13.5px;
}
.alert p { margin: 2px 0; }
.alert-error {
    background: rgba(255, 84, 112, 0.1);
    border: 1px solid rgba(255, 84, 112, 0.4);
    color: #ffb3c1;
}

/* =============================== SCROLLBAR =============================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--gold-soft); border-radius: 10px; }

/* =============================== REDUCED MOTION =============================== */

@media (prefers-reduced-motion: reduce) {
    .tab-panel, .chat-bubble, .converted-box { animation: none !important; }
    .ring-progress { transition: none !important; }
}

/* =============================== FOCUS VISIBILITY =============================== */

button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible {
    outline: 2px solid var(--turquoise);
    outline-offset: 2px;
}
