/* CSS Reset and Base Styles */
:root {
    /* Light theme variables */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-solid: #4a90e2;
    --accent-color: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    --border-color: #e0e0e0;
    --success-color: #4caf50;
    --error-color: #f44336;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Dark theme variables */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent-solid: #64b5f6;
    --accent-color: linear-gradient(135deg, #64b5f6 0%, #4a90e2 100%);
    --border-color: #404040;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-solid);
    background: var(--accent-color);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls button {
    background: none;
    border: none;
    font-size: 1.5rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.controls button:hover {
    color: var(--accent-solid);
}

/* Timer Display */
.timer-container {
    background-color: var(--bg-secondary);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 4px 6px var(--shadow-color);
    margin-bottom: 2rem;
}

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

.time-input {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0;
}

.time-input input {
    width: 5.5rem;
    height: 4rem;
    text-align: center;
    font-size: 2.2rem;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    -moz-appearance: textfield; /* Remove arrows in Firefox */
    padding: 0.5rem;
    transition: transform 0.2s, border-color 0.3s;
}

/* Swipe indicators */
.swipe-indicator {
    font-size: 0.8rem;
    color: var(--accent-solid);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    user-select: none;
}

.swipe-indicator.up {
    margin-bottom: 0.2rem;
}

.swipe-indicator.down {
    margin-top: 0.2rem;
}

/* Show indicators on touch devices */
@media (hover: none) {
    .input-wrapper:active .swipe-indicator {
        opacity: 0.6;
    }
    
    .input-wrapper:active .swipe-indicator.up {
        transform: translateY(-2px);
    }
    
    .input-wrapper:active .swipe-indicator.down {
        transform: translateY(2px);
    }
}

/* Mobile touch feedback */
.time-input input:active {
    transform: scale(1.05);
    border-color: var(--accent-solid);
}

.time-input input::-webkit-outer-spin-button,
.time-input input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.time-input span {
    font-size: 2.5rem;
    color: var(--accent-solid);
    font-weight: 300;
}

.time-input input:focus {
    outline: none;
    border-bottom-color: var(--accent-solid);
}

.timer-circle {
    position: relative;
    width: 520px;
    height: 520px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.progress-ring-circle-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 12;
}

.progress-ring-circle {
    fill: none;
    stroke: var(--accent-solid);
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s;
    stroke-dasharray: 1508.0; /* 2 * π * 240 (new circle radius) */
    stroke-dashoffset: 1508.0;
    filter: drop-shadow(0 0 2px rgba(74, 144, 226, 0.3));
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 7rem;
    font-weight: 900;
    color: var(--text-primary);
    text-shadow: 0 2px 8px var(--shadow-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    letter-spacing: -2px;
    background: var(--accent-color);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 2rem;
}

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

.timer-controls button {
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    border: none;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

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

.primary-btn:hover {
    filter: brightness(1.1);
}

.secondary-btn {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Preset Buttons */
.preset-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.preset-buttons button {
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    border: 2px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    min-width: 100px;
}

.preset-buttons button:hover,
.preset-buttons button.active-preset {
    background: var(--accent-color);
    color: white;
    border-color: transparent;
}

.preset-buttons button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--accent-solid) 10%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.5s, opacity 0.3s;
    pointer-events: none;
}

.preset-buttons button:active::after {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0.3;
}

/* Ad Container */
.ad-container {
    margin: 2rem 0;
    text-align: center;
    min-height: 90px;
}

/* Footer */
footer {
    margin-top: auto;
    text-align: center;
    padding: 1rem 0;
    color: var(--text-secondary);
}

/* Fullscreen Mode */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    background-color: var(--bg-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    main {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }

    .timer-container {
        width: 100%;
        margin: 0;
        flex-shrink: 0;
    }

    .preset-buttons button {
        touch-action: pan-y;
    }

    h1 {
        font-size: 2rem;
    }

    .timer-circle {
        width: 280px;
        height: 280px;
        margin: 0 auto;
    }

    .timer-text {
        font-size: 3.5rem;
        padding: 0 1rem;
    }

    .timer-controls {
        flex-wrap: wrap;
    }

    .timer-controls button {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: unset;
        padding: 0.75rem 1rem;
    }

    .time-input {
        gap: 0.5rem;
    }

    .time-input input {
        width: 4rem;
        height: 3rem;
        font-size: 1.8rem;
    }

    .time-input span {
        font-size: 2rem;
    }
}

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

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

    .time-input {
        margin-bottom: 1rem;
    }

    .time-input input {
        width: 3.5rem;
        height: 3rem;
        font-size: 1.6rem;
    }

    .time-input span {
        font-size: 1.8rem;
    }

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

    .timer-text {
        font-size: 3rem;
        letter-spacing: -1px;
        padding: 0 0.5rem;
    }

    .progress-ring-circle-bg,
    .progress-ring-circle {
        stroke-width: 8;
    }

    .timer-controls {
        gap: 0.5rem;
    }

    .timer-controls button {
        flex: 1 1 100%;
        padding: 0.75rem 1rem;
        font-size: 1.1rem;
    }

    .preset-buttons {
        gap: 0.5rem;
        margin-top: 0.5rem;
    }

    .preset-buttons button {
        flex: 1 1 calc(50% - 0.25rem);
        padding: 1rem;
        font-size: 1.2rem;
        min-height: 3.5rem;
        min-width: unset;
    }

    /* Add swipe hint text */
    .timer-container::after {
        content: 'Swipe up/down to change preset';
        display: block;
        text-align: center;
        color: var(--text-secondary);
        font-size: 0.9rem;
        margin-top: 1rem;
        opacity: 0.8;
    }
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.timer-ending {
    animation: pulse 1s infinite;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High Contrast Mode */
@media (forced-colors: active) {
    .timer-circle svg circle {
        stroke: CanvasText;
    }
    
    button {
        border: 2px solid CanvasText;
    }
}

