:root {
    --primary: #6c5ce7;
    --primary-hover: #5649c0;
    --secondary: #fd79a8;
    --bg-main: #dfe6e9;
    --bg-card: #ffffff;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --shadow: 0 8px 30px rgba(0,0,0,0.12);
    --danger: #e74c3c;
    --success: #00b894;
    --xp-bar: linear-gradient(90deg, #00b894, #0984e3);
}

[data-theme="dark"] {
    --primary: #a29bfe;
    --primary-hover: #8278d9;
    --secondary: #e84393;
    --bg-main: #1e272e;
    --bg-card: #2d3436;
    --text-main: #dfe6e9;
    --text-muted: #b2bec3;
    --shadow: 0 8px 30px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s, color 0.3s;
}

/* --- GRID LAYOUT --- */
.container {
    width: 100%;
    max-width: 1100px;
    display: grid;
    gap: 20px;
    margin-top: 20px;
    grid-template-columns: 1fr;
    grid-template-areas: 
        "header"
        "stats"
        "timer"
        "tasks"
        "analytics"
        "quote";
}

/* Grid Area Assignments */
header { grid-area: header; }
.stats-bar { grid-area: stats; }
.timer-card { grid-area: timer; }
.tasks-card { grid-area: tasks; }
.analytics-card { grid-area: analytics; }
.quote-container { grid-area: quote; }

/* --- COMPONENTS --- */
.card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

header { text-align: center; }
.pro-badge { background: var(--primary); color: white; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; vertical-align: middle; }

/* Level & Streak */
.level-container {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 15px;
}
.level-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.streak-badge { background: rgba(0,0,0,0.05); padding: 5px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: 700; }
.streak-badge.active { background: #ffeaa7; color: #d35400; border: 1px solid #fab1a0; }

.xp-bar-background { height: 8px; background: var(--bg-main); border-radius: 5px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: var(--xp-bar); transition: width 0.5s; }
.meta-row { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }

/* Timer */
.timer-display { font-size: 4.5rem; font-weight: 700; color: var(--primary); text-align: center; margin: 10px 0; font-variant-numeric: tabular-nums; }
.timer-controls { display: flex; gap: 10px; margin-bottom: 15px; }
button { border: none; cursor: pointer; padding: 10px; border-radius: 10px; font-weight: 600; width: 100%; transition: 0.2s; }
.primary-btn { background: var(--primary); color: white; font-size: 1.1rem; }
.primary-btn:hover { background: var(--primary-hover); }
.hidden { display: none; }

.timer-options { display: flex; justify-content: center; gap: 10px; margin-bottom: 20px; }
.mode-btn { background: none; color: var(--text-muted); width: auto; }
.mode-btn.active { background: var(--primary); color: white; }
.settings-btn { width: auto; background: none; font-size: 1.2rem; }

/* Spotify */
.spotify-wrapper { margin-top: 20px; border-top: 2px solid var(--bg-main); padding-top: 15px; }
.spotify-header { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.9rem; font-weight: 600; }
#playlist-select { padding: 5px; border-radius: 5px; border: 1px solid var(--bg-main); background: var(--bg-main); color: var(--text-main); }

/* Tasks */
.input-group { display: flex; gap: 10px; margin-bottom: 20px; }
#task-input { flex-grow: 1; padding: 12px; border: 2px solid var(--bg-main); border-radius: 10px; background: var(--bg-main); color: var(--text-main); }
.add-task-btn { width: 50px; background: var(--primary); color: white; font-size: 1.5rem; }
ul { list-style: none; padding: 0; }
li { background: var(--bg-main); padding: 12px; border-radius: 10px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; cursor: grab; }
li.completed span { text-decoration: line-through; opacity: 0.5; }
.delete-btn { background: none; color: var(--danger); width: auto; }

/* Chart */
.chart-box { position: relative; height: 200px; width: 100%; }

/* Quote & Theme */
.quote-container { text-align: center; padding: 15px; font-style: italic; color: var(--text-muted); background: var(--bg-card); border-radius: 12px; }
#theme-toggle { position: fixed; top: 20px; right: 20px; width: 50px; background: var(--bg-card); box-shadow: var(--shadow); z-index: 100; border-radius: 50%; }

/* Modal */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); align-items: center; justify-content: center; z-index: 200; backdrop-filter: blur(5px); }
.modal-content { background: var(--bg-card); padding: 25px; border-radius: 20px; width: 90%; max-width: 350px; }
.setting-row { margin-bottom: 15px; }
.setting-row input { width: 100%; padding: 8px; margin-top: 5px; background: var(--bg-main); border: 1px solid var(--bg-main); color: var(--text-main); }
.close { float: right; cursor: pointer; font-size: 1.5rem; }
.save-btn { background: var(--primary); color: white; margin-top: 10px; }

/* --- DESKTOP VIEW --- */
@media (min-width: 900px) {
    .container {
        grid-template-columns: 1fr 1.5fr;
        grid-template-rows: auto auto 1fr auto;
        grid-template-areas: 
            "header header"
            "stats stats"
            "timer tasks"
            "timer analytics"
            "quote quote";
        align-items: start;
    }
    .timer-card { position: sticky; top: 20px; }
    header { display: flex; justify-content: space-between; align-items: center; background: var(--bg-card); padding: 20px; border-radius: 20px; box-shadow: var(--shadow); }
    .level-container { margin-top: 0; min-width: 300px; box-shadow: none; background: var(--bg-main); }
    header h1 { text-align: left; margin: 0; }
    header p { text-align: left; margin: 0; }
}
