/* ==========================================================================
   tracking.yuk — AI Habit Tracker & Productivity Assistant (Tracky)
   Design Language: Modern Dark Theme with Blue (#5B8CFF) & Tosca (#38D0B0)
   Featuring TikTok/Snapchat-style 🔥 Multi-Gradient Streak Badges with CSS Flicker,
   Today's Plan Scheduler Timeline, and Working Habit Reminders
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
    /* Backgrounds & Surfaces (Calming Dark Theme) */
    --bg-app: #0d111a;
    --bg-surface: #151c2c;
    --bg-surface-elevated: #1e283d;
    --bg-surface-hover: #26334d;
    --bg-input: #0f1523;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --border-focus: #5B8CFF;

    /* Typography Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Primary Accent Colors (Calming & Motivating) */
    --accent-blue: #5B8CFF;
    --accent-blue-hover: #4677ee;
    --accent-blue-light: rgba(91, 140, 255, 0.14);
    --accent-blue-glow: rgba(91, 140, 255, 0.35);

    --accent-tosca: #38D0B0;
    --accent-tosca-light: rgba(56, 208, 176, 0.14);
    --accent-tosca-glow: rgba(56, 208, 176, 0.35);

    --accent-purple: #9D4EDD;
    --accent-orange: #FF6B35;
    --accent-warning: #F59E0B;
    --accent-danger: #EF4444;

    /* Gradients */
    --grad-primary: linear-gradient(135deg, #5B8CFF 0%, #38D0B0 100%);
    --grad-blue: linear-gradient(135deg, #5B8CFF 0%, #3a70eb 100%);
    --grad-tosca: linear-gradient(135deg, #38D0B0 0%, #059669 100%);
    --grad-purple: linear-gradient(135deg, #9D4EDD 0%, #5B8CFF 100%);
    --grad-flame: linear-gradient(135deg, #FF5E36 0%, #FF2E93 40%, #5B8CFF 75%, #9D4EDD 100%);

    /* Radii & Shadows */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-glow-blue: 0 0 20px rgba(91, 140, 255, 0.3);
    --shadow-glow-flame: 0 0 20px rgba(255, 94, 54, 0.35);

    /* Fonts */
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html,
body {
    height: 100%;
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
}

button {
    cursor: pointer;
    background: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* ==========================================================================
   APP CONTAINER & TOP HEADER
   ========================================================================== */
.app-container {
    max-width: 1540px;
    margin: 0 auto;
    padding: 20px 28px 40px 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    box-shadow: var(--shadow-sm);
    gap: 16px;
    flex-wrap: wrap;
}

/* ==========================================================================
   FEATURE 6: MODERN MINIMALIST LOGO (Icon + Text)
   ========================================================================== */
.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    user-select: none;
    cursor: default;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(91, 140, 255, 0.15) 0%, rgba(56, 208, 176, 0.15) 100%);
    border: 1.5px solid rgba(91, 140, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 16px rgba(91, 140, 255, 0.25);
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.brand-mark:hover {
    transform: translateY(-1px) scale(1.04);
    border-color: var(--accent-tosca);
    box-shadow: 0 6px 20px rgba(56, 208, 176, 0.35);
}

.brand-mark-ring {
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2px dashed rgba(56, 208, 176, 0.6);
    animation: spinSlowRing 16s linear infinite;
}

@keyframes spinSlowRing {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.brand-mark-check {
    width: 22px;
    height: 22px;
    color: var(--accent-tosca);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.brand-mark-check svg {
    width: 100%;
    height: 100%;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text-primary);
}

.brand-title .tracking {
    color: #ffffff;
}

.brand-title .dot {
    color: var(--accent-tosca);
}

.brand-title .yuk {
    color: var(--accent-blue);
}

.brand-tagline {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: var(--radius-full);
}

.date-chip svg {
    width: 15px;
    height: 15px;
    color: var(--accent-blue);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Reminder Notification Toggle Button in Header */
.btn-reminder-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 13px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-strong);
    background-color: var(--bg-surface-elevated);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-reminder-toggle:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.btn-reminder-toggle.active {
    background: var(--accent-tosca-light);
    border-color: rgba(56, 208, 176, 0.4);
    color: var(--accent-tosca);
}

.btn-reminder-toggle svg {
    width: 14px;
    height: 14px;
}

.quick-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-tosca);
    background: var(--accent-tosca-light);
    border: 1px solid rgba(56, 208, 176, 0.3);
    padding: 5px 12px;
    border-radius: var(--radius-full);
}

.pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--accent-tosca);
    box-shadow: 0 0 6px var(--accent-tosca);
}

.btn-icon-header {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-icon-header svg {
    width: 18px;
    height: 18px;
}

.btn-icon-header:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue);
    background-color: var(--bg-surface-hover);
}

/* ==========================================================================
   MAIN 2-COLUMN LAYOUT
   ========================================================================== */
.main-content-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 22px;
    align-items: start;
}

.dashboard-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.content-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast);
}

.content-card:hover {
    border-color: var(--border-strong);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.card-title-group h3 {
    font-size: 1.18rem;
    font-weight: 800;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.title-icon {
    width: 24px;
    height: 24px;
    margin-top: 2px;
}

.title-icon.icon-blue {
    color: var(--accent-blue);
}

.title-icon.icon-tosca {
    color: var(--accent-tosca);
}

.title-icon.icon-purple {
    color: var(--accent-purple);
}

.title-icon.icon-warning {
    color: var(--accent-warning);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.kpi-icon-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon-box svg {
    width: 22px;
    height: 22px;
}

.kpi-icon-box.bg-blue {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.kpi-icon-box.bg-tosca {
    background: var(--accent-tosca-light);
    color: var(--accent-tosca);
}

.kpi-icon-box.bg-purple {
    background: rgba(157, 78, 221, 0.14);
    color: var(--accent-purple);
}

.kpi-icon-box.bg-flame {
    background: rgba(255, 94, 54, 0.14);
}

.kpi-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.kpi-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-info h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin: 2px 0;
}

.kpi-sub {
    font-size: 0.73rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   FEATURE 9 & 8: TODAY'S PLAN / SMART HABIT SCHEDULER
   ========================================================================== */
.todays-plan-card {
    border-left: 4px solid var(--accent-blue);
}

.plan-header-badge {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    font-family: var(--font-mono);
}

.schedule-timeline-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-item-row {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    transition: all var(--transition-fast);
}

.schedule-item-row:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-strong);
}

.schedule-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.schedule-time-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
}

.schedule-time-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.schedule-dur-val {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.schedule-item-details {
    display: flex;
    flex-direction: column;
}

.schedule-item-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.schedule-item-title-row h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.schedule-item-meta {
    font-size: 0.74rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.schedule-item-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Status Badges for Today's Plan */
.plan-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: var(--radius-full);
}

.plan-status-pill.status-completed {
    background: var(--accent-tosca-light);
    color: var(--accent-tosca);
    border: 1px solid rgba(56, 208, 176, 0.3);
}

.plan-status-pill.status-now {
    background: rgba(91, 140, 255, 0.2);
    color: var(--accent-blue);
    border: 1px solid rgba(91, 140, 255, 0.5);
    animation: pulseNowBadge 2s infinite ease-in-out;
}

@keyframes pulseNowBadge {

    0%,
    100% {
        box-shadow: 0 0 0 rgba(91, 140, 255, 0);
    }

    50% {
        box-shadow: 0 0 10px rgba(91, 140, 255, 0.4);
    }
}

.plan-status-pill.status-upcoming {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.plan-status-pill.status-missed {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.btn-plan-quick-action {
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: var(--grad-blue);
    color: white;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-plan-quick-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-blue);
}

.btn-plan-quick-action.done {
    background: var(--accent-tosca-light);
    color: var(--accent-tosca);
    border: 1px solid rgba(56, 208, 176, 0.3);
    box-shadow: none;
    cursor: default;
}

/* ==========================================================================
   FEATURE 1: CHART.JS PROGRESS GRAPH CARD
   ========================================================================== */
.chart-timeframe-toggle {
    display: flex;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 3px;
}

.toggle-btn {
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-btn.active {
    background: var(--grad-blue);
    color: white;
    box-shadow: var(--shadow-sm);
}

.chart-container-wrapper {
    position: relative;
    height: 220px;
    width: 100%;
}

.chart-footer-insight {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.insight-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-tosca);
    box-shadow: 0 0 8px var(--accent-tosca);
    flex-shrink: 0;
}

/* ==========================================================================
   FEATURE 2: HABIT LIST & TIKTOK/SNAPCHAT STREAK BADGES
   ========================================================================== */
.habit-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pill-btn {
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.pill-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.pill-btn.active {
    background-color: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.pill-btn.text-warning {
    color: var(--accent-warning);
}

.pill-btn.text-warning.active {
    background-color: var(--accent-warning);
    color: #111;
}

.streak-legend-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.glow-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #FF5E36;
    box-shadow: 0 0 6px #FF5E36;
}

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

.habit-row-card {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: all var(--transition-fast);
}

.habit-row-card:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-strong);
}

.habit-row-card.completed {
    opacity: 0.78;
    background-color: rgba(30, 40, 61, 0.45);
}

.habit-row-card.completed .habit-row-text h4 {
    text-decoration: line-through;
    color: var(--text-muted);
}

.habit-row-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.custom-checkbox-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-strong);
    background-color: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: all var(--transition-fast);
}

.custom-checkbox-btn svg {
    width: 16px;
    height: 16px;
}

.custom-checkbox-btn:hover {
    border-color: var(--accent-tosca);
}

.habit-row-card.completed .custom-checkbox-btn {
    background: var(--grad-tosca);
    border-color: var(--accent-tosca);
    color: white;
    box-shadow: 0 0 10px var(--accent-tosca-glow);
}

.habit-row-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.habit-row-text {
    display: flex;
    flex-direction: column;
}

.habit-row-text h4 {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
}

.habit-row-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.meta-pill {
    background-color: rgba(255, 255, 255, 0.06);
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.habit-row-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ==========================================================================
   TIKTOK / SNAPCHAT MULTI-COLOR FLAME STREAK BADGE WITH CSS FLICKER
   ========================================================================== */
.streak-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px 4px 8px;
    background: rgba(255, 94, 54, 0.12);
    border: 1px solid rgba(255, 94, 54, 0.3);
    border-radius: var(--radius-full);
    position: relative;
    user-select: none;
    transition: all var(--transition-fast);
}

.flame-badge-svg {
    width: 19px;
    height: 19px;
    display: block;
    transform-origin: 50% 90%;
}

.streak-number {
    font-size: 0.88rem;
    font-weight: 800;
    font-family: var(--font-sans);
    background: linear-gradient(135deg, #FF6B35 0%, #FF2E93 50%, #5B8CFF 100%);
    l: text;
    -webkit-text-fill-color: transparent;
}

/* Subtle Organic Flame Flicker Keyframes */
.flicker-subtle {
    animation: flameSubtleFlicker 2.8s infinite ease-in-out;
}

.flicker-fast {
    animation: flameSubtleFlicker 1.8s infinite ease-in-out;
}

@keyframes flameSubtleFlicker {

    0%,
    100% {
        transform: scale(1) rotate(0deg) skewX(0deg);
        filter: drop-shadow(0 0 3px rgba(255, 94, 54, 0.4));
    }

    20% {
        transform: scale(1.05, 0.97) rotate(-1.5deg) skewX(-1deg);
        filter: drop-shadow(0 0 5px rgba(255, 46, 147, 0.5));
    }

    40% {
        transform: scale(0.98, 1.04) rotate(1.2deg) skewX(1deg);
        filter: drop-shadow(0 0 4px rgba(255, 94, 54, 0.6));
    }

    60% {
        transform: scale(1.03, 0.99) rotate(-0.8deg) skewX(-0.5deg);
        filter: drop-shadow(0 0 6px rgba(91, 140, 255, 0.5));
    }

    80% {
        transform: scale(0.99, 1.02) rotate(1deg) skewX(0.8deg);
        filter: drop-shadow(0 0 4px rgba(255, 94, 54, 0.4));
    }
}

/* Pop-in Celebration for newly formed streak */
.streak-pop-in {
    animation: streakPopInBurst 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes streakPopInBurst {
    0% {
        transform: scale(0);
        opacity: 0;
        box-shadow: 0 0 0 rgba(255, 94, 54, 0);
    }

    60% {
        transform: scale(1.3);
        opacity: 1;
        box-shadow: 0 0 25px rgba(255, 94, 54, 0.8);
    }

    100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 10px rgba(255, 94, 54, 0.3);
    }
}

/* Condition: Streak Dying (Hampir Padam) */
.streak-pill-badge.dying {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.45);
    animation: dyingPulseWarning 2.2s infinite ease-in-out;
}

.streak-pill-badge.dying .flame-badge-svg {
    filter: grayscale(80%) opacity(0.55);
    animation: none;
}

.streak-pill-badge.dying .streak-number {
    background: none;
    -webkit-text-fill-color: var(--text-secondary);
    color: var(--text-secondary);
}

@keyframes dyingPulseWarning {

    0%,
    100% {
        border-color: rgba(245, 158, 11, 0.3);
        box-shadow: 0 0 0 rgba(245, 158, 11, 0);
    }

    50% {
        border-color: rgba(245, 158, 11, 0.75);
        box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
    }
}

/* Condition: Milestone Streak (>7 or >30 Days) */
.streak-pill-badge.milestone {
    padding: 5px 12px 5px 10px;
    background: linear-gradient(135deg, rgba(255, 94, 54, 0.25) 0%, rgba(157, 78, 221, 0.25) 100%);
    border: 1px solid rgba(255, 46, 147, 0.5);
    box-shadow: 0 0 16px rgba(255, 94, 54, 0.45);
}

.streak-pill-badge.milestone::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: var(--radius-full);
    border: 1.5px solid rgba(255, 94, 54, 0.4);
    animation: milestoneAuraPulse 2.4s infinite ease-in-out;
    pointer-events: none;
}

@keyframes milestoneAuraPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.08);
        opacity: 0.1;
    }
}

.streak-pill-badge.milestone .flame-badge-svg {
    width: 22px;
    height: 22px;
}

.streak-pill-badge.milestone .streak-number {
    font-size: 0.95rem;
    font-weight: 900;
}

/* Row Action Buttons */
.habit-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn-subtle {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.icon-btn-subtle svg {
    width: 16px;
    height: 16px;
}

.icon-btn-subtle:hover {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.icon-btn-subtle.delete:hover {
    color: var(--accent-danger);
    background-color: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   FEATURE 1, 2, 3: TRACKY AI BUDDY PANEL & CONVERSATION
   ========================================================================== */
.ai-coach-panel {
    position: sticky;
    top: 20px;
}

.ai-chat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    min-height: 620px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: var(--bg-surface-elevated);
    border-bottom: 1px solid var(--border-subtle);
}

.ai-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar-orb {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #5B8CFF 0%, #38D0B0 50%, #9D4EDD 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
    box-shadow: 0 0 18px var(--accent-blue-glow);
}

.ai-avatar-orb svg {
    width: 22px;
    height: 22px;
}

.online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background-color: var(--accent-tosca);
    border: 2px solid var(--bg-surface);
}

.ai-identity-text {
    display: flex;
    flex-direction: column;
}

.ai-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-title-row h3 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffffff;
}

.badge-tracky-ai {
    font-size: 0.7rem;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(91, 140, 255, 0.25) 0%, rgba(56, 208, 176, 0.25) 100%);
    color: var(--accent-tosca);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(56, 208, 176, 0.3);
}

.badge-claude-model,
.badge-gemini-model,
.badge-ai-model {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    font-weight: 700;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.ai-status-sub {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.icon-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.icon-btn.danger:hover {
    color: var(--accent-danger);
    border-color: rgba(239, 68, 68, 0.4);
}

/* Live Context Drawer */
.injected-context-drawer {
    background-color: #0b0f19;
    border-bottom: 1px solid var(--border-strong);
    padding: 12px 16px;
    font-size: 0.75rem;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.context-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--accent-tosca);
    font-weight: 700;
    margin-bottom: 6px;
}

.context-drawer-header svg {
    width: 14px;
    height: 14px;
    margin-right: 4px;
}

.context-code-view {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    max-height: 140px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.4;
}

/* Chat Messages Scroll Box */
.chat-messages-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: msgFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.ai {
    align-self: flex-start;
}

.msg-avatar-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-surface-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.chat-msg.user .msg-avatar-icon {
    background: var(--accent-blue-light);
    border-color: rgba(91, 140, 255, 0.3);
}

.msg-bubble-content {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-primary);
    position: relative;
    word-break: break-word;
}

.chat-msg.user .msg-bubble-content {
    background: linear-gradient(135deg, #2b458b 0%, #1e3066 100%);
    border-color: rgba(91, 140, 255, 0.4);
    border-bottom-right-radius: 4px;
}

.chat-msg.ai .msg-bubble-content {
    border-bottom-left-radius: 4px;
}

.msg-bubble-content p {
    margin-bottom: 8px;
}

.msg-bubble-content p:last-child {
    margin-bottom: 0;
}

.msg-bubble-content ul,
.msg-bubble-content ol {
    margin-left: 18px;
    margin-bottom: 8px;
}

.msg-bubble-content li {
    margin-bottom: 4px;
}

.msg-bubble-content strong {
    color: #ffffff;
    font-weight: 700;
}

.msg-bubble-content code {
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent-tosca);
}

.msg-timestamp {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 5px;
    text-align: right;
}

/* Typing Indicator Animation */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 4px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--accent-tosca);
    animation: typingBounce 1.3s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Suggested Chips */
.suggested-chips-bar {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background-color: rgba(15, 21, 35, 0.6);
    border-top: 1px solid var(--border-subtle);
    scrollbar-width: none;
}

.suggested-chips-bar::-webkit-scrollbar {
    display: none;
}

.chip-btn {
    white-space: nowrap;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 6px 12px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.chip-btn:hover {
    background-color: var(--accent-blue-light);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

/* Chat Input Bar */
.chat-input-bar {
    padding: 14px 18px;
    background-color: var(--bg-surface-elevated);
    border-top: 1px solid var(--border-subtle);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    transition: border-color var(--transition-fast);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-blue-light);
}

.chat-input-wrapper textarea {
    flex: 1;
    background: none;
    resize: none;
    max-height: 110px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-primary);
}

.chat-input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.btn-send-chat {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--grad-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.btn-send-chat svg {
    width: 16px;
    height: 16px;
}

.btn-send-chat:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
}

.btn-send-chat:not(:disabled):hover {
    transform: scale(1.06);
    box-shadow: 0 0 12px var(--accent-blue-glow);
}

.chat-footer-note {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}

/* ==========================================================================
   MODALS: ADD/EDIT HABIT & INFO MODAL
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(7, 10, 18, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-box {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalSlideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px) scale(0.96);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--grad-tosca);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.modal-icon-badge.bg-blue {
    background: var(--grad-blue);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
}

.btn-modal-close {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.btn-modal-close:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-desc-note {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.req-star {
    color: var(--accent-danger);
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-blue-light);
}

.icon-selector-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.icon-radio-btn {
    cursor: pointer;
    position: relative;
}

.icon-radio-btn input {
    position: absolute;
    opacity: 0;
}

.icon-radio-btn span {
    display: block;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.icon-radio-btn input:checked+span {
    border-color: var(--accent-tosca);
    background-color: var(--accent-tosca-light);
    transform: scale(1.1);
}

.btn-primary {
    background: var(--grad-primary);
    color: white;
    font-weight: 700;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-blue);
}

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    font-weight: 700;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-focus);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   FEATURE 12: IN-APP TRACKY REMINDER POPUP / MODAL
   ========================================================================== */
.inapp-reminder-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(7, 10, 18, 0.8);
    backdrop-filter: blur(8px);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.inapp-reminder-box {
    background-color: var(--bg-surface);
    border: 1.5px solid var(--accent-tosca);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 30px var(--accent-tosca-glow);
    padding: 24px;
    text-align: center;
    animation: reminderBounceIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

@keyframes reminderBounceIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.reminder-pulse-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px auto;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(56, 208, 176, 0.2) 0%, rgba(91, 140, 255, 0.2) 100%);
    border: 2px solid var(--accent-tosca);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    animation: reminderAura 2s infinite ease-in-out;
}

@keyframes reminderAura {

    0%,
    100% {
        box-shadow: 0 0 0 rgba(56, 208, 176, 0);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 20px rgba(56, 208, 176, 0.6);
        transform: scale(1.06);
    }
}

.inapp-reminder-box h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.inapp-reminder-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.inapp-reminder-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-wrapper {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    padding: 11px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 260px;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.success {
    border-left: 4px solid var(--accent-tosca);
}

.toast.info {
    border-left: 4px solid var(--accent-blue);
}

.toast.warning {
    border-left: 4px solid var(--accent-warning);
}

.toast.danger {
    border-left: 4px solid var(--accent-danger);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================================== */
@media (max-width: 1180px) {
    .main-content-grid {
        grid-template-columns: 1fr;
    }

    .ai-coach-panel {
        position: static;
    }

    .ai-chat-card {
        height: 600px;
    }
}

@media (max-width: 860px) {
    .app-container {
        padding: 14px 14px 30px 14px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .habit-row-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .habit-row-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border-subtle);
    }

    .schedule-item-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .schedule-item-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border-subtle);
    }
}

@media (max-width: 520px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}