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

:root {
    --primary-color: #6366f1;
    --primary-hover: #5855eb;
    --primary-active: #4f46e5;
    --success-color: #10b981;
    --success-hover: #059669;
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
        --bg-primary: #111827;
        --bg-secondary: #1f2937;
        --bg-tertiary: #374151;
        --border-color: #374151;
        --border-hover: #4b5563;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 480px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 2rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

/* Timer Display */
.timer-display {
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.time-text {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    transition: all 0.3s ease;
}

.time-text.running {
    color: var(--primary-color);
    transform: scale(1.02);
}

.time-text.paused {
    color: var(--warning-color);
}

.time-text.finished {
    color: var(--danger-color);
    animation: pulse 1s infinite;
}

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

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

/* Control Buttons */
.control-section {
    margin-bottom: 3rem;
}

.control-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    padding: 1rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    min-height: 80px;
    touch-action: manipulation;
}

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

.control-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.control-btn:not(:disabled):active {
    transform: translateY(0);
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

.start-btn:not(:disabled) {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

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

.pause-btn:not(:disabled) {
    background: var(--warning-color);
    border-color: var(--warning-color);
    color: white;
}

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

.reset-btn:not(:disabled) {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

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

/* Section Headers */
h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* Preset Buttons */
.preset-section {
    margin-bottom: 2.5rem;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 0.75rem;
}

.preset-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
    touch-action: manipulation;
}

.preset-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

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

/* Editable timer display */
.time-text[contenteditable="true"] {
    cursor: text;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.5rem;
    transition: all 0.2s ease;
}

.time-text[contenteditable="true"]:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.time-text[contenteditable="true"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

/* AdSense styling */
.ad-unit {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 90px;
}

.top-ad {
    margin-bottom: 2rem;
}

.bottom-ad {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

/* Responsive ad adjustments */
@media (max-width: 640px) {
    .ad-unit {
        margin: 1rem 0;
        min-height: 50px;
    }
    
    .top-ad {
        margin-bottom: 1.5rem;
    }
    
    .bottom-ad {
        margin-top: 1.5rem;
        margin-bottom: 0.5rem;
    }
}

/* Policy pages styling */
.policy-page {
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
}

.policy-page h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    text-align: center;
}

.last-updated {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 2rem;
    font-style: italic;
}

.policy-content section {
    margin-bottom: 2rem;
}

.policy-page h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.policy-page h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.policy-page p {
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.policy-page ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.policy-page li {
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.policy-page a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.contact-methods {
    display: grid;
    gap: 1.5rem;
    margin: 2rem 0;
}

.contact-method {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.contact-content section {
    margin-bottom: 2rem;
}

.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.nav-link {
    background: var(--primary-color);
    color: white !important;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--primary-hover);
    color: white !important;
    transform: translateY(-1px);
}

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

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    margin: 0 1rem;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Responsive policy pages */
@media (max-width: 640px) {
    .policy-page {
        padding: 1rem 0;
    }
    
    .policy-page h1 {
        font-size: 2rem;
    }
    
    .navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-link {
        width: 100%;
        text-align: center;
    }
    
    .contact-methods {
        gap: 1rem;
    }
    
    .contact-method {
        padding: 1rem;
    }
    
    .footer-links {
        margin-top: 1.5rem;
    }
    
    .footer-links a {
        display: block;
        margin: 0.5rem 0;
    }
}

/* Notification Modal */
.notification-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.notification-modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.modal-content h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

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

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

.modal-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    touch-action: manipulation;
}

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

.modal-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.modal-btn.primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Responsive Design */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem;
        margin: 0.5rem;
        border-radius: var(--radius-lg);
    }
    
    .control-buttons {
        gap: 0.75rem;
    }
    
    .control-btn {
        padding: 0.875rem 0.5rem;
        min-height: 70px;
        font-size: 0.8rem;
    }
    
    .control-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .preset-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .preset-btn {
        padding: 0.625rem 0.25rem;
        font-size: 0.8rem;
    }
    
    .input-group input {
        width: 70px;
        padding: 0.625rem;
        font-size: 1rem;
    }
    
    .input-row {
        gap: 0.75rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .time-text {
        font-size: 2.5rem;
    }
    
    .preset-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .control-buttons {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .control-btn {
        flex-direction: row;
        justify-content: center;
        min-height: 60px;
        gap: 0.75rem;
    }
}

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

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: var(--text-primary);
    }
}
