/* ========================================
   Apple-Style Timer - CSS Design System
   ======================================== */

:root {
    /* Light Theme Colors */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: rgba(255, 255, 255, 0.8);
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --accent-primary: #007aff;
    --accent-secondary: #34c759;
    --accent-warning: #ff9500;
    --accent-danger: #ff3b30;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 2px 20px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 30px rgba(0, 0, 0, 0.12);
    --shadow-strong: 0 8px 40px rgba(0, 0, 0, 0.16);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.5);
    --progress-bg: rgba(0, 122, 255, 0.1);
    --progress-fill: #007aff;
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: rgba(28, 28, 30, 0.8);
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-soft: 0 2px 20px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 30px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 8px 40px rgba(0, 0, 0, 0.5);
    --glass-bg: rgba(28, 28, 30, 0.72);
    --glass-border: rgba(255, 255, 255, 0.08);
    --progress-bg: rgba(0, 122, 255, 0.2);
}

/* ========================================
   Base Styles
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   App Container
   ======================================== */

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

/* ========================================
   Header
   ======================================== */

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

.app-header h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent-primary), #5856d6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    border: none;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-medium);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.sun-icon,
.moon-icon {
    position: absolute;
    font-size: 20px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.moon-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* ========================================
   Timer Display
   ======================================== */

.timer-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.timer-display-container {
    display: flex;
    justify-content: center;
    padding: 20px 0;
}

.timer-ring {
    position: relative;
    width: 240px;
    height: 240px;
}

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

.progress-ring-bg {
    fill: none;
    stroke: var(--progress-bg);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--progress-fill);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.5s ease;
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.time-value {
    font-size: 56px;
    font-weight: 200;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    display: block;
    line-height: 1;
}

.time-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Timer States */
.timer-ring.running .progress-ring-fill {
    stroke: var(--accent-secondary);
}

.timer-ring.paused .progress-ring-fill {
    stroke: var(--accent-warning);
}

.timer-ring.finished .progress-ring-fill {
    stroke: var(--accent-danger);
    animation: pulse 1s ease infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ========================================
   Section Titles
   ======================================== */

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* ========================================
   Duration Slider
   ======================================== */

.duration-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

.duration-slider-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.duration-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--progress-bg);
    border-radius: 3px;
    outline: none;
}

.duration-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    background: var(--bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.duration-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--border-color);
}

.duration-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    background: var(--bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--border-color);
}

.duration-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 80px;
    text-align: right;
}

#durationValue {
    font-size: 24px;
}

/* ========================================
   Preset Buttons
   ======================================== */

.presets-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.preset-btn {
    padding: 14px 8px;
    border: none;
    border-radius: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.preset-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-btn.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

/* ========================================
   Task Section
   ======================================== */

.task-section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

.task-input-container {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.task-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.task-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.task-input::placeholder {
    color: var(--text-tertiary);
}

.task-add-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-primary), #5856d6);
    color: white;
    font-size: 24px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.task-add-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
}

.task-add-btn:active {
    transform: scale(0.95);
}

.current-task {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.1), rgba(88, 86, 214, 0.1));
    border-radius: 12px;
    border: 1px solid rgba(0, 122, 255, 0.2);
}

.current-task.hidden {
    display: none;
}

.task-icon {
    font-size: 20px;
}

.task-name {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.task-clear-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 59, 48, 0.1);
    color: var(--accent-danger);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.task-clear-btn:hover {
    background: var(--accent-danger);
    color: white;
    transform: scale(1.1);
}

/* ========================================
   Control Buttons
   ======================================== */

.controls-section {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 20px 0;
    margin-top: auto;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100px;
    height: 100px;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.control-btn .btn-icon {
    font-size: 28px;
    line-height: 1;
}

.control-btn .btn-text {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Primary Button (Start) */
.control-btn.primary {
    background: linear-gradient(135deg, var(--accent-secondary), #30d158);
    color: white;
    box-shadow: 0 4px 20px rgba(52, 199, 89, 0.4);
}

.control-btn.primary:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(52, 199, 89, 0.5);
}

.control-btn.primary:active:not(:disabled) {
    transform: translateY(-2px);
}

/* Secondary Button (Stop) */
.control-btn.secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
}

.control-btn.secondary:hover:not(:disabled) {
    background: var(--accent-danger);
    color: white;
    border-color: transparent;
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(255, 59, 48, 0.4);
}

/* Accent Button (Pause/Resume) */
.control-btn.accent {
    background: linear-gradient(135deg, var(--accent-warning), #ff9f0a);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 149, 0, 0.4);
}

.control-btn.accent:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(255, 149, 0, 0.5);
}

/* ========================================
   Tasks History
   ======================================== */

.tasks-history {
    margin-top: 32px;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
}

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

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    animation: slideIn 0.3s ease;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-item .task-status {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-secondary), #30d158);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.task-item .task-info {
    flex: 1;
}

.task-item .task-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.task-item .task-duration {
    font-size: 13px;
    color: var(--text-tertiary);
}

.task-item .task-delete {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.task-item .task-delete:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--accent-danger);
}

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
    padding: 20px;
}

.empty-state.hidden {
    display: none;
}

/* ========================================
   Animations
   ======================================== */

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.timer-ring.finished {
    animation: shake 0.5s ease infinite;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 480px) {
    .app-container {
        padding: 16px;
    }

    .app-header h1 {
        font-size: 28px;
    }

    .timer-ring {
        width: 200px;
        height: 200px;
    }

    .time-value {
        font-size: 44px;
    }

    .preset-buttons {
        grid-template-columns: repeat(3, 1fr);
    }

    .control-btn {
        width: 90px;
        height: 90px;
    }
}

/* ========================================
   Accessibility
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus States */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ========================================
   Toast Notification
   ======================================== */

.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

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

.toast-icon {
    font-size: 24px;
}

.toast-message {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ========================================
   Pomodoro Mode Styles
   ======================================== */

/* Header Controls Container */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Pomodoro Toggle Button */
.pomodoro-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.pomodoro-toggle:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-medium);
}

.pomodoro-toggle.active {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(238, 90, 36, 0.4);
}

.pomodoro-icon {
    font-size: 18px;
}

.pomodoro-label {
    font-size: 14px;
    font-weight: 600;
}

/* Pomodoro Counter */
.pomodoro-counter {
    display: none;
    margin-top: 4px;
    margin-bottom: 4px;
}

.pomodoro-counter.visible {
    display: block;
}

.pomodoro-count {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--glass-bg);
    padding: 4px 12px;
    border-radius: 12px;
}

/* Pomodoro Presets Section */
.pomodoro-presets {
    transition: all 0.3s ease;
}

.pomodoro-presets.hidden {
    display: none;
}

.pomodoro-buttons {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
}

.pomodoro-buttons .preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    min-height: 90px;
}

.preset-icon {
    font-size: 24px;
}

.preset-text {
    font-size: 13px;
    font-weight: 600;
}

.preset-time {
    font-size: 12px;
    opacity: 0.8;
}

/* Pomodoro Work Button */
.preset-btn.pomodoro-work {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(238, 90, 36, 0.15));
    border-color: rgba(238, 90, 36, 0.3);
}

.preset-btn.pomodoro-work:hover,
.preset-btn.pomodoro-work.active {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(238, 90, 36, 0.4);
}

/* Pomodoro Break Button */
.preset-btn.pomodoro-break {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.15), rgba(48, 209, 88, 0.15));
    border-color: rgba(52, 199, 89, 0.3);
}

.preset-btn.pomodoro-break:hover,
.preset-btn.pomodoro-break.active {
    background: linear-gradient(135deg, #34c759, #30d158);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(52, 199, 89, 0.4);
}

/* Pomodoro Long Break Button */
.preset-btn.pomodoro-long-break {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.15), rgba(88, 86, 214, 0.15));
    border-color: rgba(0, 122, 255, 0.3);
}

.preset-btn.pomodoro-long-break:hover,
.preset-btn.pomodoro-long-break.active {
    background: linear-gradient(135deg, #007aff, #5856d6);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4);
}

/* Timer Ring Pomodoro States */
.timer-ring.pomodoro-work .progress-ring-fill {
    stroke: #ee5a24;
}

.timer-ring.pomodoro-break .progress-ring-fill {
    stroke: #34c759;
}

.timer-ring.pomodoro-long-break .progress-ring-fill {
    stroke: #5856d6;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* Responsive adjustments for Pomodoro */
@media (max-width: 480px) {
    .pomodoro-toggle {
        padding: 8px 12px;
    }

    .pomodoro-label {
        display: none;
    }

    .pomodoro-buttons .preset-btn {
        min-height: 80px;
        padding: 12px 8px;
    }

    .preset-icon {
        font-size: 20px;
    }

    .preset-text {
        font-size: 11px;
    }
}