/* ============================================================
   Screen Time Accountability — Styles
   Digital wellness dark mode with warning orange-red
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #FF6348;
    --primary-light: #FF7F50;
    --secondary: #2ED573;
    --accent: #ECCC68;
    --bg: #1A1A2E;
    --bg-elevated: #16213E;
    --bg-surface: #0F3460;
    --bg-card: #16213E;
    --bg-hover: #1F3A6E;
    --text-primary: #E8E8F0;
    --text-secondary: #A0A0C0;
    --text-muted: #6060A0;
    --border: #2A2A50;
    --success: #2ED573;
    --warning: #ECCC68;
    --danger: #FF6348;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 50px;
    --shadow: 0 4px 20px rgba(0, 0, 0, .3);
    --transition: 200ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 100px;
}

/* --- Header --- */
.header {
    text-align: center;
    padding: 32px 0 24px;
}

.header-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: var(--text-secondary);
    font-size: .9rem;
    margin-top: 4px;
}

/* --- Summary Cards --- */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.summary-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.summary-label {
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn:hover {
    background: var(--bg-hover);
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    opacity: .9;
}

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

/* --- Category Section --- */
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.category-card.social::before {
    background: var(--primary);
}

.category-card.entertainment::before {
    background: var(--accent);
}

.category-card.news::before {
    background: #3498DB;
}

.category-card.shopping::before {
    background: #e056de;
}

.category-card.productive::before {
    background: var(--secondary);
}

.cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cat-name {
    font-weight: 700;
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cat-time {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.limit-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.limit-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .5s ease;
}

.limit-fill.ok {
    background: var(--secondary);
}

.limit-fill.warn {
    background: var(--accent);
}

.limit-fill.over {
    background: var(--danger);
}

.limit-text {
    font-size: .75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.cat-sites {
    margin-top: 8px;
    font-size: .8rem;
    color: var(--text-secondary);
}

/* --- Heatmap --- */
.heatmap-section {
    margin-bottom: 24px;
}

.heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.heatmap-label {
    font-size: .7rem;
    color: var(--text-muted);
    text-align: center;
    padding: 4px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    position: relative;
}

.heatmap-cell.level-0 {
    background: var(--border);
}

.heatmap-cell.level-1 {
    background: rgba(46, 213, 115, .2);
}

.heatmap-cell.level-2 {
    background: rgba(46, 213, 115, .4);
}

.heatmap-cell.level-3 {
    background: rgba(236, 204, 104, .4);
}

.heatmap-cell.level-4 {
    background: rgba(255, 99, 72, .4);
}

.heatmap-cell.level-5 {
    background: rgba(255, 99, 72, .7);
}

.heatmap-cell[title] {
    cursor: help;
}

/* --- Leaderboard --- */
.leaderboard {
    margin-bottom: 24px;
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: .85rem;
}

.rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    background: var(--bg-surface);
    flex-shrink: 0;
}

.rank.top {
    background: var(--danger);
    color: #fff;
}

.lb-name {
    flex: 1;
}

.lb-time {
    font-weight: 700;
    color: var(--danger);
}

/* --- Focus Session --- */
.focus-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
}

.focus-timer {
    font-size: 3rem;
    font-weight: 800;
    margin: 16px 0;
    font-variant-numeric: tabular-nums;
}

.focus-status {
    font-size: .85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.focus-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
}

/* --- Settings Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .8rem;
    text-align: center;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: .85rem;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 200;
}

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

@media (max-width: 640px) {
    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }

    .focus-timer {
        font-size: 2.5rem;
    }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}