
/* --------------------------------
    Theme Variables (Light/Dark)
----------------------------------- */
:root {
    --bg: #f9fafb;
    --text: #1f2937;
    --card: #ffffff;
    --primary: #22c55e;
    --accent: #3b82f6;
    --muted: #6b7280;
    --done: #9ca3af;
    --shadow: 0 2px 6px rgba(0,0,0,0.8);
}

body.dark {
    --bg: #111827;
    --text: #f3f4f6;
    --card: #1f2937;
    --primary: #4ade80;
    --accent: #60a5fa;
    --muted: #9ca3af;
    --done: #6b7280;
    --shadow: 0 2px 6px rgba(0,0,0,0.6);
}

/* ======================
    Base Styles
======================== */

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 28px 12px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

h1, h2, h3,
.app-title,
.section-title,
.stats-subtitle,
.calendar-month-label {
    font-family: "Poppins", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button {
    font-weight: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    transition: background 0.2s ease, tranform 0.15s ease;
}

button:active {
    transform: scale(0.97);
}

/* Primary buttons (shared styles) */
.btn-done, 
#habit-form button, 
.calendar-controls button,
#new-quote {
    background: var(--accent);
    color: white;
}

.btn-done:hover,
#habit-form button:hover,
.calendar-controls button:hover,
#new-quote:hover {
    background: #2563eb;
}

/* ============================
    Layout Containers & Cards
================================ */
.container {
    width: 100%;
    max-width: 720px;
}

.card {
    background: var(--card);
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

/* ======================
    Header
======================== */
.header-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #f97316, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

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

.username-display {
    font-size: 0.85rem;
    color: var(--muted);
}

.logout-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--muted);
    font-size: 0.8rem;
    padding: 5px 10px;
}

.logout-btn:hover {
    background: var(--muted);
    color: var(--card);
}

.theme-btn {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.title-icon {
    width: 18px;
    height: 18px;
    vertical-align: -4px;
    margin-right: 6px;
    color: var(--accent);
}

/* ======================
    Habit Input Form
======================== */
#habit-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

#habit-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
}

/* ======================
    Habit List & Items
======================== */
.habit-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.habit-list li {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: var(--card);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.habit-name {
    font-weight: 600;
    font-size: 1.05rem;
    display: inline-block;
}

.habit-list li > .meta {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.92rem;
    color: var(--muted);
}

/* Item buttons */
.habit-list li button {
    margin-left: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-delete {
    background: #ef4444;
    color: white;
}

.btn-delete:hover {
    background: #b91c1c;
}

/* completed habit state */
.habit-list li.done .habit-name {
    text-decoration: line-through;
    color: var(--done);
}

/* ======================
    Progress Bar
======================== */
.progress {
    flex: 1;
    height: 8px;
    background: #eee;
    border-radius: 6px;
    overflow: hidden;
}

.bar {
    height: 100%;
    width: 0%;
    transition: width .25s ease;
    background: var(--accent);
}

.progress-label {
    font-size: 0.82rem;
    color: var(--muted);
}

/* ================================
    Mini 7-Day Calendar (per habit)
================================== */
.calendar {
    display: flex;
    gap: 6px;
}

.day-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: #eee;
    border: 1px solid #ddd;
}

.day-box.done-day {
    background: var(--accent);
    border-color: transparent;
}

.day-box.future-day {
    background-color: rgba(77, 171, 247, 0.1);
    border: 1px dashed var(--accent, #ccc);
    opacity: 0.5;
}

/* ======================
    Monthly Calendar
======================== */
.calendar-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.calendar-month-label {
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7,1fr);
    gap: 6px;
    align-items: start;
}

/* Calendar day cell */
.day-cell {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    border: 1px solid rgba(0,0,0,0.05);
    padding: 6px;
}

body.dark .day-cell {
    border: 1px solid rgba(255,255,255,0.08);
}

.day-cell.empty {
    background: transparent;
    border: none;
    pointer-events: none;
}

/* Status indicators */
.day-cell.partial {
    background: #f59e0b;
    color: white;
}

.day-cell.full {
    background: var(--primary);
    color: white;
}

/* ======================
    Stats Section
======================== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--card);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}

.stats-subtitle {
    font-size: 0.92rem;
    font-weight: 600;
    margin: 14px 0 8px 0;
    color: var(--muted);
}

.stats-habit-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stats-habit-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: var(--card);
    border-radius: 6px;
    font-size: 0.9rem;
    gap: 8px;
}

.stats-habit-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-habit-numbers {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.stats-empty {
    color: var(--muted);
    font-size: 0.9rem;
    padding: 8px 0;
}

.stats-trend {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 80px;
    background: var(--card);
    border-radius: 8px;
    padding: 8px;
    box-shadow: var(--shadow);
}

.trend-bar {
    flex: 1;
    min-height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    transition: height 0.2s ease;
}

/* ======================
    Quotes
======================== */
.quote-text {
    font-style: italic;
    margin: 8px 0 12px 0;
    color: var(--muted);
}

.quote-controls {
    display: flex;
    gap: 8px;
}

/* ======================
    Accessibility utility
======================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ======================
    Auth (Sign in / Sign up)
======================== */
.auth-body {
    align-items: center;
}

.auth-container {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.auth-app-title {
    margin: 0 0 6px 0;
    font-size: 2.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #f97316, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-tagline {
    margin: 0 0 24px 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.auth-card {
    width: 100%;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    background: transparent;
    color: var(--muted);
    padding: 8px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.auth-tab.active {
    background: var(--accent);
    color: white;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-form input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 0.95rem;
}

.auth-error {
    color: #ef4444;
    font-size: 0.85rem;
    margin: 0;
    text-align: left;
}

.auth-submit {
    background: var(--accent);
    color: white;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.auth-submit:hover {
    background: #2563eb;
}

/* ======================
    Tooltip
======================== */
.tooltip {
  position: absolute;
  background: var(--card);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  pointer-events: none;
  opacity: 0.95;
  z-index: 1000;
  max-width: 240px;
  line-height: 1.4;
}