/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    min-height: 100vh;
    color: white;
    transition: background 0.3s ease;
}

body.short-break {
    background: linear-gradient(135deg, #38858a 0%, #4a9fa4 100%);
}

body.long-break {
    background: linear-gradient(135deg, #357abd 0%, #2c5aa0 100%);
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    padding: 20px 0;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    color: white;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main {
    padding: 40px 0;
}

/* Timer Section */
.timer-section {
    text-align: center;
    margin-bottom: 60px;
}

/* Dynamic timer sizing based on viewport */
.time {
    font-size: clamp(48px, 15vw, 120px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Responsive timer controls */
.start-btn {
    background: white;
    border: none;
    border-radius: 4px;
    color: #4a90e2;
    padding: clamp(12px, 4vw, 18px) clamp(24px, 8vw, 48px);
    font-size: clamp(14px, 4vw, 18px);
    font-weight: 700;
    letter-spacing: clamp(1px, 0.5vw, 2px);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    min-width: 120px;
}

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: clamp(20px, 6vw, 40px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 4px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    padding: clamp(8px, 3vw, 12px) clamp(12px, 4vw, 16px);
    cursor: pointer;
    font-size: clamp(12px, 3.5vw, 14px);
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex: 1;
    min-width: clamp(70px, 20vw, 120px);
}

.mode-btn.active,
.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.timer-display {
    margin-bottom: clamp(20px, 6vw, 40px);
}

.timer-controls {
    margin-bottom: clamp(15px, 5vw, 30px);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

body.short-break .start-btn {
    color: #38858a;
}

body.long-break .start-btn {
    color: #357abd;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.start-btn.pause {
    background: transparent;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.skip-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.skip-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    color: #333;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* Settings Modal Specific */
.setting-group {
    margin-bottom: 24px;
}

.setting-group h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #333;
}

.time-settings {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.time-input {
    flex: 1;
    min-width: 120px;
}

.time-input label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #555;
}

.time-input input {
    width: 100%;
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.time-input input:focus {
    border-color: #4a90e2;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #4a90e2;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.cancel-btn, .save-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn {
    background: #f5f5f5;
    color: #666;
}

.cancel-btn:hover {
    background: #e9e9e9;
}

.save-btn {
    background: #4a90e2;
    color: white;
}

.save-btn:hover {
    background: #357abd;
}

/* Report Modal Specific */
.report-content {
    text-align: center;
}

.report-summary h4 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: #4a90e2;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 0 16px;
    }
    
    .time {
        font-size: 80px;
    }
    
    .mode-btn {
        min-width: 90px;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .start-btn {
        padding: 16px 40px;
        font-size: 16px;
    }
    
    .time-settings {
        flex-direction: column;
    }
    
    .stats {
        gap: 24px;
    }
    
    .stat-value {
        font-size: 24px;
    }
}

/* Very small screens - focus on essentials */
@media (max-width: 400px) {
    .header {
        padding: 10px 0;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    
    .nav {
        gap: 5px;
    }
    
    .nav-btn {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .main {
        padding: 20px 0;
    }
    
    .timer-section {
        margin-bottom: 30px;
    }
    
    .mode-selector {
        margin-bottom: 20px;
        padding: 2px;
    }
    
    .mode-btn {
        min-width: 70px;
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .time {
        font-size: 60px;
        line-height: 1;
    }
    
    .timer-display {
        margin-bottom: 20px;
    }
    
    .start-btn {
        padding: 14px 32px;
        font-size: 14px;
        letter-spacing: 1px;
    }
    
    .skip-btn {
        width: 36px;
        height: 36px;
        padding: 8px;
    }
    
    .skip-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .timer-controls {
        margin-bottom: 15px;
    }
}

/* Extra small screens - minimal interface */
@media (max-width: 300px) {
    .container {
        padding: 0 8px;
    }
    
    .header {
        padding: 8px 0;
    }
    
    .logo h1 {
        font-size: 16px;
    }
    
    .nav-btn {
        padding: 4px 6px;
        font-size: 11px;
    }
    
    .main {
        padding: 15px 0;
    }
    
    .timer-section {
        margin-bottom: 20px;
    }
    
    .mode-selector {
        margin-bottom: 15px;
        flex-direction: column;
        gap: 2px;
    }
    
    .mode-btn {
        min-width: unset;
        width: 100%;
        padding: 10px;
        font-size: 14px;
    }
    
    .time {
        font-size: 48px;
    }
    
    .timer-display {
        margin-bottom: 15px;
    }
    
    .start-btn {
        padding: 12px 24px;
        font-size: 14px;
        width: 80%;
        max-width: 200px;
    }
    
    .skip-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    .skip-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .timer-controls {
        margin-bottom: 10px;
    }
    
    /* Hide navigation on very small screens to save space */
    .nav {
        display: none;
    }
}

/* PWA Splash Screen */
@media (display-mode: standalone) {
    .header {
        padding-top: 30px;
    }
    
    /* Suggest optimal PWA window size */
    body {
        min-width: 280px;
        max-width: 600px;
        margin: 0 auto;
    }
}

/* Compact mode for very small windows */
.compact-mode {
    overflow: hidden;
}

.compact-mode .timer-section {
    margin-bottom: 20px;
}

.compact-mode .main {
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

.compact-mode .mode-selector {
    margin-bottom: 15px;
    flex-direction: column;
    gap: 4px;
}

.compact-mode .mode-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 12px;
    min-width: unset;
}

.compact-mode .time {
    font-size: clamp(32px, 12vw, 48px);
    margin-bottom: 10px;
}

.compact-mode .timer-display {
    margin-bottom: 15px;
}

.compact-mode .start-btn {
    padding: 10px 20px;
    font-size: 14px;
    min-width: 100px;
    width: 70%;
    max-width: 150px;
}

.compact-mode .timer-controls {
    margin-bottom: 10px;
}

/* Very small mode - focus only on timer and controls */
.very-small:not(.compact-mode) .nav {
    display: none;
}

.very-small:not(.compact-mode) .logo h1 {
    font-size: 14px;
}

/* Animation Classes */
.pulse {
    animation: pulse 1s infinite;
}

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

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Dark theme support for devices */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #2a2a2a;
        color: white;
    }
    
    .modal-header {
        border-bottom-color: #444;
    }
    
    #taskInput,
    #pomodoroCount,
    .time-input input {
        background: #333;
        border-color: #555;
        color: white;
    }
    
    .counter-btn {
        background: #333;
        border-color: #555;
        color: white;
    }
    
    .cancel-btn {
        background: #444;
        color: white;
    }
    
    .close-btn {
        color: #ccc;
    }
}