/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --success-hover: #059669;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--radius);
    color: white;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.tagline {
    opacity: 0.9;
    font-size: 1rem;
}

/* Card styles */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.category-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
}

.category-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.category-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Challenge Display */
.challenge-display {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: var(--radius-sm);
    padding: 24px;
    margin-bottom: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.challenge-content {
    text-align: center;
}

.challenge-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.5;
}

.challenge-meta {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 16px;
}

.challenge-meta span {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.difficulty {
    background: var(--warning-color);
    color: white;
}

.difficulty.easy {
    background: var(--success-color);
}

.difficulty.medium {
    background: var(--warning-color);
}

.difficulty.hard {
    background: var(--danger-color);
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 10px;
}

.btn:last-child {
    margin-right: 0;
}

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

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

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

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: var(--text-primary);
}

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

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    color: white;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* Progress Bar */
.progress-bar-container {
    margin-bottom: 24px;
}

.progress-bar-container label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.progress-bar {
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #34d399);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.progress-text {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* History List */
.history-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.history-list li {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-list li:last-child {
    border-bottom: none;
}

.history-list .empty-state {
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-category {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
}

/* Reminder Form */
.reminder-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input[type="time"] {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    width: 100%;
    max-width: 200px;
}

.form-group input[type="time"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.days-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.day-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.day-checkbox:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.day-checkbox input {
    display: none;
}

.reminder-status {
    font-size: 0.9rem;
    color: var(--success-color);
    margin-top: 8px;
}

/* Leaderboard */
.leaderboard-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.leaderboard-controls input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.leaderboard-controls input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.leaderboard-table-container {
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.leaderboard-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.leaderboard-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.leaderboard-table .rank-1 {
    font-weight: 700;
    color: #fbbf24;
}

.leaderboard-table .rank-2 {
    font-weight: 600;
    color: #9ca3af;
}

.leaderboard-table .rank-3 {
    font-weight: 600;
    color: #d97706;
}

.leaderboard-table .current-user {
    background: rgba(99, 102, 241, 0.1);
}

.leaderboard-table .empty-state {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    margin-top: auto;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text-primary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--danger-color);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .app-container {
        padding: 12px;
    }

    header {
        padding: 30px 16px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 16px;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .category-btn {
        padding: 12px 8px;
    }

    .category-icon {
        font-size: 1.25rem;
    }

    .category-name {
        font-size: 0.75rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .challenge-display {
        padding: 16px;
        min-height: 100px;
    }

    .challenge-text {
        font-size: 1rem;
    }

    .challenge-meta {
        flex-direction: column;
        gap: 8px;
    }

    .btn {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .btn:last-child {
        margin-bottom: 0;
    }

    .days-selector {
        justify-content: center;
    }

    .day-checkbox {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .leaderboard-controls {
        flex-direction: column;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 8px 6px;
        font-size: 0.85rem;
    }

    .notification {
        left: 20px;
        right: 20px;
        bottom: 10px;
    }
}

/* Animation for challenge generation */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.challenge-display.generating {
    animation: pulse 0.5s ease-in-out;
}

/* Scrollbar styling */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}
