/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Loading Screen */
.loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    z-index: 9999;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Auth Screen */
.auth-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
}

.auth-container {
    text-align: center;
    color: white;
    padding: 2rem;
}

.auth-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    opacity: 0.9;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-large {
    padding: 1.25rem 2rem;
    font-size: 1.25rem;
    min-height: 64px;
}

.btn-hero {
    width: 100%;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--surface);
    cursor: pointer;
    font-size: 1.25rem;
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    background: var(--surface);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    gap: 1rem;
}

.header-left h1 {
    font-size: 1.25rem;
}

.header-stats {
    display: flex;
    gap: 1rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 600;
}

.stat-label {
    font-size: 1.25rem;
}

/* Navigation */
.app-nav {
    background: var(--surface);
    display: flex;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}

.nav-btn {
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main Content */
.app-main {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Today Tab */
.today-header {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.today-header h2 {
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, #059669 100%);
    transition: width 0.5s ease;
}

#today-progress-text {
    text-align: center;
    font-weight: 600;
    color: var(--text-light);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.today-checklist {
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.checklist-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item .check {
    font-size: 1.5rem;
}

.checklist-item.completed .check {
    color: var(--success);
}

.checklist-item span:nth-child(2) {
    flex: 1;
}

.reward {
    font-weight: 600;
    color: var(--warning);
}

.today-log {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.log-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow);
}

.log-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.log-item-type {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--primary);
}

.log-item-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

.log-item-content {
    font-size: 0.875rem;
}

/* Quick Actions Tab */
.subtitle {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.action-category {
    margin-bottom: 2rem;
}

.action-category h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.action-card {
    background: var(--surface);
    border: 2px solid var(--border);
    padding: 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
}

.action-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Tasks Tab */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-item {
    background: var(--surface);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.task-title {
    font-weight: 600;
    flex: 1;
}

.task-category-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.task-done-criteria {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

.task-actions {
    display: flex;
    gap: 0.5rem;
}

/* Reframe Tab */
.reframes-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.reframe-item {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.reframe-trigger {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.reframe-thought {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: #fee;
    border-left: 3px solid var(--danger);
    border-radius: 4px;
}

.reframe-balanced {
    padding: 0.75rem;
    background: #efe;
    border-left: 3px solid var(--success);
    border-radius: 4px;
}

.reframe-distortions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.distortion-tag {
    background: var(--border);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Experiments Tab */
.experiment-templates {
    margin-bottom: 2rem;
}

.experiment-level {
    margin-bottom: 1.5rem;
}

.experiment-level h3 {
    margin-bottom: 0.75rem;
}

.experiment-card {
    display: block;
    width: 100%;
    background: var(--surface);
    border: 2px solid var(--border);
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    text-align: left;
}

.experiment-card:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.experiments-log {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.experiment-item {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--warning);
}

/* Timer Tab */
.timer-display {
    background: var(--surface);
    padding: 3rem 2rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.timer-time {
    font-size: 4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.5rem;
}

.timer-label {
    color: var(--text-light);
    font-size: 1.125rem;
}

.timer-presets {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.preset-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.preset-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.timer-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.timer-controls .btn {
    flex: 1;
}

.timer-reminder {
    background: #fef3c7;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--warning);
}

.timer-reminder p {
    margin-bottom: 0.5rem;
}

.timer-reminder p:last-child {
    margin-bottom: 0;
}

/* Stats Tab */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-card .stat-label {
    color: var(--text-light);
    font-size: 0.875rem;
}

.badges-section, .settings-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.badges-section h3, .settings-section h3 {
    margin-bottom: 1rem;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.badge {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    background: var(--bg);
}

.badge-icon-large {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.badge.unlocked {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
}

.badge.locked {
    opacity: 0.3;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-family: inherit;
    font-size: 1rem;
}

.modal-content textarea {
    min-height: 100px;
    resize: vertical;
}

.modal-content label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Wizard Modal */
.wizard-modal {
    max-width: 600px;
}

.wizard-step {
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.wizard-back {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.wizard-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.wizard-option {
    padding: 1.5rem;
    background: var(--surface);
    border: 3px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
}

.wizard-option:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.wizard-option small {
    display: block;
    font-size: 0.875rem;
    font-weight: normal;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.wizard-templates {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.wizard-template {
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.wizard-template:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.wizard-custom {
    display: flex;
    gap: 0.5rem;
}

.wizard-custom input {
    flex: 1;
}

.wizard-preview {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.wizard-timeboxes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.wizard-timebox {
    padding: 1rem;
    border: 2px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.wizard-timebox.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.wizard-complete-text {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
}

.wizard-complete-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.recovery-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.recovery-option {
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    transition: all 0.2s;
}

.recovery-option:hover {
    border-color: var(--success);
    background: #f0fdf4;
}

/* Shame Modal */
.shame-modal {
    max-width: 500px;
}

.shame-subtitle {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.shame-checklist {
    margin-bottom: 1.5rem;
}

.shame-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.shame-checkbox input {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.shame-actions h3 {
    margin-bottom: 1rem;
}

.shame-action {
    display: block;
    width: 100%;
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.shame-action:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

/* Onboarding Modal */
.onboarding-modal {
    max-width: 600px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
}

.sortable-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.sortable-item {
    padding: 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: move;
}

.distortion-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.distortion-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Celebration */
.celebration {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s;
}

.celebration-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.celebration-emoji {
    font-size: 5rem;
    animation: bounce 0.6s infinite;
}

@keyframes popIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Badge Notification */
.badge-notification {
    position: fixed;
    top: 5rem;
    right: 1rem;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    animation: slideInRight 0.5s;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
    }
    to {
        transform: translateX(0);
    }
}

.badge-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}

.badge-icon {
    font-size: 1.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 1rem;
    }
    
    .header-stats {
        gap: 0.5rem;
    }
    
    .stat {
        font-size: 0.875rem;
    }
    
    .app-main {
        padding: 1rem;
    }
    
    .action-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .timer-time {
        font-size: 3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .wizard-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .wizard-timeboxes {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.5rem;
    }
    
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
}
