/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

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

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

/* Header */
.app-header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-light) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: grid;
    gap: 2rem;
}

@media (min-width: 768px) {
    .main-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Section Styles */
section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Timer Section */
.timer-section {
    grid-column: 1 / -1;
    text-align: center;
}

@media (min-width: 768px) {
    .timer-section {
        grid-column: 1 / -1;
    }
}

.timer-display {
    margin-bottom: 2rem;
}

.timer-circle {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 1rem;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: var(--surface-light);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-progress.break {
    stroke: var(--secondary-color);
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.timer-label {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Timer Controls */
.timer-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--surface-light);
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

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

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

.btn-icon {
    font-size: 0.875rem;
}

/* Timer Modes */
.timer-modes {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

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

/* Session Stats */
.session-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
}

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

/* Tasks Section */
.tasks-section {
    display: flex;
    flex-direction: column;
}

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

.filter-btn {
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.filter-btn:hover {
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--surface-light);
    color: var(--text-primary);
}

/* Task Form */
.task-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.task-form input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 1rem;
}

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

.task-form select,
.task-form input[type="number"] {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.task-form input[type="number"] {
    width: 60px;
}

/* Task List */
.task-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
    margin-bottom: 1rem;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--surface-light);
    transition: var(--transition);
}

.task-item:hover {
    background: var(--border-color);
}

.task-item.completed .task-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.task-checkbox:hover {
    border-color: var(--primary-color);
}

.task-checkbox.checked {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

.task-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-text {
    display: block;
    word-break: break-word;
}

.task-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.task-priority {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    text-transform: capitalize;
}

.task-priority.high {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.task-priority.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.task-priority.low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary-color);
}

.task-pomodoros {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
}

.task-delete:hover {
    color: var(--danger-color);
}

/* Task Summary */
.task-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Break Section */
.break-settings {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 480px) {
    .break-settings {
        grid-template-columns: repeat(4, 1fr);
    }
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.setting-group input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 1rem;
    width: 100%;
}

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Break Schedule */
.break-schedule {
    margin-bottom: 1.5rem;
}

.break-schedule h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.schedule-timeline {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.schedule-item {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-align: center;
}

.schedule-item.focus {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.schedule-item.short-break {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary-color);
}

.schedule-item.long-break {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.schedule-item.current {
    border: 2px solid currentColor;
}

/* Auto Break Toggle */
.auto-break-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--surface-light);
    border-radius: 12px;
    position: relative;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(20px);
    background: white;
}

/* Progress Section */
.period-selector {
    display: flex;
    gap: 0.25rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.period-btn {
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Progress Overview */
.progress-overview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.progress-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
}

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

.progress-info {
    display: flex;
    flex-direction: column;
}

.progress-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Progress Chart */
.progress-chart {
    margin-bottom: 1.5rem;
}

.progress-chart h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.chart-container {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 100px;
    padding: 0.5rem 0;
}

.chart-bar {
    flex: 1;
    background: var(--primary-color);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    position: relative;
    transition: var(--transition);
}

.chart-bar:hover {
    background: var(--primary-light);
}

.chart-bar::after {
    content: attr(data-value);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.625rem;
    color: var(--text-muted);
    padding-bottom: 0.25rem;
    opacity: 0;
    transition: var(--transition);
}

.chart-bar:hover::after {
    opacity: 1;
}

.chart-label {
    text-align: center;
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Daily Goal */
.daily-goal h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.goal-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.goal-bar {
    flex: 1;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
}

.goal-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.goal-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.daily-goal input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 4px;
    background: var(--surface-light);
    border-radius: 2px;
    outline: none;
}

.daily-goal input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* History Section */
.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--surface-light);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.history-info {
    display: flex;
    flex-direction: column;
}

.history-type {
    font-weight: 500;
    text-transform: capitalize;
}

.history-type.focus {
    color: var(--primary-light);
}

.history-type.short-break,
.history-type.long-break {
    color: var(--secondary-color);
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

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

.history-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
}

.app-footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.app-footer a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}

.app-footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 640px) {
    .app-header h1 {
        font-size: 1.5rem;
    }

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

    .timer-circle {
        width: 160px;
        height: 160px;
    }

    .session-stats {
        gap: 1.5rem;
    }

    .progress-overview {
        grid-template-columns: 1fr;
    }

    .break-settings {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.timer-text.running {
    animation: pulse 2s ease-in-out infinite;
}

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