/* style.css */
:root {
    --bg-app: #0f111a;
    --bg-card: #1a1d29;
    --bg-input: #252a36;
    --primary: #6c5ce7;
    --primary-dark: #5649c0;
    --accent: #00cec9;
    --danger: #ff7675;
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --border-radius: 16px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-app: #f5f6fa;
        --bg-card: #ffffff;
        --bg-input: #eef0f6;
        --text-main: #2d3436;
        --text-muted: #636e72;
        --border-radius: 16px;
    }
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0; padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 600px; /* Tablet/Desktop constraint */
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--bg-card);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.logo-area { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 24px; }
h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }

.streak-badge {
    background: linear-gradient(135deg, #fdcb6e, #e17055);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 10px rgba(225, 112, 85, 0.4);
}

/* Main Content Area */
main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

.hidden-view { display: none !important; }
.active-view { animation: fadeIn 0.3s ease-in-out; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

h2 { margin-top: 0; font-size: 22px; margin-bottom: 16px; }
h3 { font-size: 16px; margin-bottom: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sub-text { color: var(--text-muted); font-size: 14px; margin-top: -10px; margin-bottom: 20px; }

/* Forms & Inputs */
.workout-form, .goal-form {
    background-color: var(--bg-card);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-bottom: 20px;
}

.input-group { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
input, select {
    background-color: var(--bg-input);
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 12px;
    border-radius: 10px;
    font-size: 16px;
    transition: 0.2s;
}
input:focus, select:focus { border-color: var(--primary); }
.row-inputs { display: flex; gap: 10px; }
.row-inputs .input-group { flex: 1; }

.btn-primary, .btn-secondary, .btn-cancel {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
}
.btn-primary { background-color: var(--primary); color: white; margin-top: 8px; }
.btn-primary:active { transform: scale(0.97); filter: brightness(0.9); }
.btn-secondary { background-color: var(--bg-input); color: var(--text-main); margin-top: 10px; }
.full-width-btn { width: 100%; margin-top: 15px; }
.btn-cancel { background-color: transparent; color: var(--text-muted); }

/* Lists */
.log-list, .pb-list, .goals-list {
    list-style: none; padding: 0; margin: 0;
}
.empty-state, .empty-item {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-style: italic;
    background: var(--bg-input);
    border-radius: 10px;
    margin-top: 10px;
}
.log-item, .pb-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 15px;
    background-color: var(--bg-card);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.log-ex { font-weight: 600; }
.log-meta { color: var(--accent); font-weight: 700; }

/* Progress Cards */
.progress-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
.card { background-color: var(--bg-card); border-radius: var(--border-radius); padding: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

.goal-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background-color: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 10px;
}
.goal-info { display: grid; }
.goal-title { font-size: 14px; font-weight: 600; color: var(--text-main); }
.goal-meta { font-size: 11px; color: var(--accent); text-align: right; margin-top: 2px; }
.goal-track {
    grid-column: 1 / span 3;
    height: 6px;
    background-color: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.goal-fill { height: 100%; background-color: var(--primary); border-radius: 3px; transition: width 0.5s ease; }
.delete-goal {
    background: transparent; border: none; color: var(--danger); font-size: 20px; cursor: pointer; line-height: 1;
}

/* Stickers Grid */
.stickers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.badge {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
    transition: transform 0.2s;
    border: 2px solid transparent;
}
.badge.unlocked { border-color: rgba(255, 215, 0, 0.3); }
.badge-icon svg { width: 40px; height: 40px; margin-bottom: 8px; }
.badge.locked { opacity: 0.5; }
.badge h4 { margin: 0 0 4px 0; font-size: 14px; }
.badge p { margin: 0; font-size: 11px; color: var(--text-muted); }

/* Tabs */
.tab-bar {
    display: flex;
    background-color: var(--bg-card);
    padding: 8px 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    cursor: pointer;
    border-radius: 10px;
}
.tab-btn.active { color: var(--primary); background-color: rgba(108, 92, 231, 0.1); }

/* Modals */
/* The goal modal is a <dialog>: it MUST be display:none while closed, so the
   flex layout is applied only to the [open] state. Forcing display:flex on the
   closed dialog overrode the browser's hidden state and made Cancel appear
   dead. */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none; /* hidden until [open] */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    border: none;
    padding: 0;
}
.modal[open] { display: flex; }
.modal-content {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 400px;
    animation: fadeIn 0.2s;
}
.modal-actions { display: flex; gap: 10px; margin-top: 10px; }
.modal-actions button { flex: 1; }

/* Toast Notifications */
.unlock-toast {
    position: fixed;
    top: 20px; left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(46, 204, 113, 0.4);
    z-index: 2000;
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.unlock-toast.fade-out { opacity: 0; transform: translate(-50%, -20px); transition: 0.5s; pointer-events: none;}
@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -30px); } to { opacity: 1; transform: translate(-50%, 0); }}
