/* ===================================
   Habit Tracker Mini — Styles
   Dark mode, Lime Green palette
   =================================== */

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

:root {
    --primary: #84CC16;
    --primary-light: #A3E635;
    --primary-dark: #65A30D;
    --accent: #BEF264;
    --bg-900: #0D1A05;
    --bg-800: #121F09;
    --bg-700: #1A2B0E;
    --bg-600: #233815;
    --bg-500: #2E461D;
    --text-100: #F0FAE7;
    --text-200: #C5D8A8;
    --text-300: #8A9D6F;
    --border: rgba(132, 204, 22, 0.1);
    --glass: rgba(13, 26, 5, 0.9);
    --glass-border: rgba(132, 204, 22, 0.15);
    --danger: #EF4444;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    min-height: 100vh;
    background: var(--bg-900);
    color: var(--text-100);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-500);
    border-radius: 3px;
}

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

/* --- Header --- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-800);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    font-size: 24px;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    gap: 8px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: var(--font);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #000;
    border: none;
    box-shadow: 0 2px 12px rgba(132, 204, 22, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(132, 204, 22, 0.4);
}

.btn-secondary {
    background: var(--bg-700);
    color: var(--text-200);
}

.btn-secondary:hover {
    background: var(--bg-600);
    border-color: var(--primary);
    color: var(--text-100);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-300);
    padding: 8px 0;
    margin-bottom: 16px;
}

.btn-back:hover {
    color: var(--primary-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
    border-radius: var(--radius);
}

/* --- Main --- */
.main {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

/* --- Views --- */
.view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

/* --- Dashboard --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.today-date {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-100);
}

.today-progress {
    font-size: 13px;
    color: var(--text-300);
    margin-top: 4px;
}

/* --- Habits List --- */
.habits-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.habit-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.habit-card:hover {
    border-color: rgba(132, 204, 22, 0.25);
    background: var(--bg-700);
    transform: translateY(-1px);
}

.habit-card.completed {
    border-color: rgba(132, 204, 22, 0.3);
}

.habit-card.completed::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.habit-emoji {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.habit-info {
    flex: 1;
    min-width: 0;
}

.habit-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-100);
}

.habit-streak {
    font-size: 12px;
    color: var(--text-300);
    margin-top: 2px;
}

.habit-streak .streak-fire {
    color: var(--primary-light);
    font-weight: 600;
}

.habit-check-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--bg-500);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 18px;
    flex-shrink: 0;
}

.habit-check-btn:hover {
    border-color: var(--primary);
    background: rgba(132, 204, 22, 0.08);
}

.habit-check-btn.checked {
    border-color: var(--primary);
    background: var(--primary);
    animation: checkBounce 0.3s ease;
}

@keyframes checkBounce {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.habit-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-600);
    border-radius: 10px;
    font-size: 10px;
    color: var(--text-300);
    margin-top: 4px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.5s ease-out;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--text-200);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-300);
    margin-bottom: 24px;
}

/* --- Detail View --- */
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.detail-emoji {
    font-size: 48px;
}

.detail-name {
    font-size: 22px;
    font-weight: 700;
}

.detail-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg-600);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text-300);
    margin-top: 4px;
}

.detail-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 32px;
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.stat-card-lg {
    padding: 20px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-light);
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-300);
}

/* --- Heatmap --- */
.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-300);
    margin-bottom: 12px;
}

.heatmap-section {
    margin-top: 4px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 12px;
    justify-content: flex-end;
}

.heatmap-legend-label {
    font-size: 10px;
    color: var(--text-300);
    margin: 0 4px;
}

.heatmap-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.heatmap-container {
    display: grid;
    grid-template-columns: repeat(53, 1fr);
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.heatmap-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--bg-600);
    cursor: pointer;
    transition: var(--transition);
}

.heatmap-day:hover {
    transform: scale(1.3);
    z-index: 2;
}

.heatmap-day[title] {
    position: relative;
}

/* --- Form --- */
.form-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-100);
}

.habit-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
}

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

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-300);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-group input,
.form-group select {
    padding: 10px 14px;
    background: var(--bg-700);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-100);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(132, 204, 22, 0.15);
}

.emoji-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.emoji-picker input {
    width: 60px;
    text-align: center;
    font-size: 24px;
}

.emoji-suggestions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.emoji-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-700);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-btn:hover {
    background: var(--bg-600);
    border-color: var(--primary);
    transform: scale(1.1);
}

/* --- Stats Overview --- */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.stats-habits-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-habit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stats-habit-emoji {
    font-size: 22px;
}

.stats-habit-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-200);
}

.stats-habit-bar-wrapper {
    width: 120px;
    height: 6px;
    background: var(--bg-600);
    border-radius: 3px;
    overflow: hidden;
}

.stats-habit-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.stats-habit-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
    min-width: 40px;
    text-align: right;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 10px 24px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    backdrop-filter: blur(16px);
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Milestone Popup --- */
.milestone-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.milestone-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.milestone-content {
    padding: 24px 40px;
    background: var(--glass);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    backdrop-filter: blur(20px);
    text-align: center;
    box-shadow: 0 0 40px rgba(132, 204, 22, 0.3);
}

.milestone-emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.milestone-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* --- Responsive --- */
@media (max-width: 700px) {
    .header {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-right {
        flex-wrap: wrap;
        gap: 4px;
    }

    .main {
        padding: 16px;
    }

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

    .heatmap-container {
        grid-template-columns: repeat(26, 1fr);
    }

    .habit-card {
        padding: 12px 14px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 16px;
    }

    .header-right .btn span {
        display: none;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 12px;
    }

    .btn-lg {
        width: 100%;
        justify-content: center;
    }
}