/* CSS Variables */
:root {
    --success-color: #28a745;
    --danger-color: #dc3545;
    --primary-color: #4285f4;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --card-bg: #fff;
    --progress-bg: #e9ecef;
    
    /* Granular progress colors */
    --progress-10: #28a745;    /* Deep Green (0%) */
    --progress-20: #4cb342;    /* Transition to lighter green */
    --progress-30: #6abf3b;    /* Yellow-green blend */
    --progress-40: #88d227;    /* Balanced yellow-green */
    --progress-50: #a5e132;    /* Light green-yellow */
    --progress-60: #ffd633;    /* Soft yellow-orange */
    --progress-70: #ffbf33;    /* Yellow-orange */
    --progress-80: #ff9933;    /* Bright orange */
    --progress-90: #e36454;    /* Light red-orange */
    --progress-100: #dc3545;   /* Deep Red (100%) */
    
    --shadow-color: rgba(0, 0, 0, 0.1);
    --border-hover: #dee2e6;
    --icon-color: #6c757d;
    
    /* Dark Mode Variables */
    --bg-color-light: #f8f9fa;
    --bg-color-dark: #121212;
    --text-color-light: #333;
    --text-color-dark: #e0e0e0;
    --card-bg-light: #fff;
    --card-bg-dark: #1e1e1e;
    --shadow-color-light: rgba(0, 0, 0, 0.1);
    --shadow-color-dark: rgba(255, 255, 255, 0.1);
}

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

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    overflow-x: hidden;
}

body.dark-mode {
    background-color: var(--bg-color-dark);
    color: var(--text-color-dark);
}

/* Timer Card */
.timer-card {
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 0.25rem 0.5rem var(--shadow-color);
    padding: 1.5rem;
    width: 100%;
    max-width: 31.25rem;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.timer-card.expanded {
    max-width: 90%;
    transform: scale(1.1);
    padding: 2rem;
}

body.dark-mode .timer-card {
    background: var(--card-bg-dark);
    box-shadow: 0 0.25rem 0.5rem var(--shadow-color-dark);
    color: var(--text-color-dark);
    border-color: #333;
}

.expand-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--icon-color);
    color: white;
}

.timer-card:hover .expand-icon {
    opacity: 1;
    visibility: visible;
}

.expand-icon:hover {
    background-color: var(--text-color);
    transform: scale(1.1);
}

.timer-card.expanded .expand-icon i {
    transform: rotate(180deg);
}

.timer-card:hover {
    border-color: var(--border-hover);
}

.timer-title {
    margin: 0.5rem 0;
    font-size: 1.5rem;
    color: var(--text-color);
    text-align: center;
    padding: 0.2rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    cursor: text;
    outline: none;
}

body.dark-mode .timer-title {
    color: var(--text-color-dark);
}

.timer-title:hover:not(.disabled) {
    background-color: rgba(0, 0, 0, 0.1);
}

.timer-title:focus {
    background-color: rgba(0, 0, 0, 0.1);
}

.timer-title.disabled {
    cursor: not-allowed;
    pointer-events: none;
}

.timer-card.expanded .timer-title {
    font-size: 3.5rem;
    margin-bottom: 2rem;
}

.timer-times {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.start-time,
.end-time {
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.3s ease;
    cursor: default;
    position: relative;
}

.start-time.disabled,
.end-time.disabled {
    cursor: not-allowed;
}

.start-time.disabled .time-part,
.end-time.disabled .time-part {
    cursor: not-allowed;
    pointer-events: none;
}

.time-part {
    display: inline-block;
    padding: 0.2rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.time-part:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.time-part:not(.period) {
    min-width: 2ch;
}

.time-part.period {
    cursor: pointer;
    margin-left: 0.2rem;
}

.time-part[contenteditable="true"]:hover,
.time-part.period:hover {
    background-color: rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.time-part[contenteditable="true"]:focus {
    background-color: rgba(0, 0, 0, 0.1);
    outline: none;
}

.timer-card.expanded .start-time,
.timer-card.expanded .end-time {
    font-size: 4.5rem;
}

.start-time {
    color: var(--success-color);
}

.end-time {
    color: var(--danger-color);
}

body.dark-mode .start-time,
body.dark-mode .end-time,
body.dark-mode .time-remaining {
    color: var(--text-color-dark);
}

.time-dropdown {
    display: none;
    position: absolute;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

.time-dropdown.show {
    display: block;
}

.hour-dropdown {
    left: 0;
    top: 100%;
    margin-top: 0.5rem;
}

.minute-dropdown {
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 0.5rem;
}

.period-dropdown {
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
}

.dropdown-content {
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: center;
}

.dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.dropdown-item.selected {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: bold;
}

/* Dark Mode Time Dropdown Styles */
body.dark-mode .time-dropdown {
    background: var(--card-bg-dark);
    color: var(--text-color-dark);
    box-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

body.dark-mode .dropdown-item:hover {
    background-color: rgba(40, 167, 69, 0.2); /* --success-color with opacity */
    color: var(--success-color);
}

body.dark-mode .dropdown-item.selected {
    background-color: rgba(40, 167, 69, 0.2); /* --success-color with opacity */
    color: var(--success-color);
    font-weight: bold;
}

body.dark-mode .time-dropdown::-webkit-scrollbar-track {
    background: #333;
    border-radius: 3px;
}

body.dark-mode .time-dropdown::-webkit-scrollbar-thumb {
    background: #555;
}

/* Scrollbar styles for dropdowns */
.time-dropdown::-webkit-scrollbar {
    width: 6px;
}

.time-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.time-dropdown::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.time-dropdown::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.progress-container {
    background: var(--progress-bg);
    border-radius: 0.5rem;
    height: 5rem;
    overflow: hidden;
    margin: 1rem 0;
    transition: all 0.3s ease;
}

.timer-card.expanded .progress-container {
    height: 8rem;
    margin: 2rem 0;
    border-radius: 0.75rem;
}

.progress-bar {
    background: var(--progress-50);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.timer-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    position: relative;
}

.timer-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 7rem;
    opacity: 0;
    visibility: hidden;
}

.timer-card:hover .timer-button {
    opacity: 1;
    visibility: visible;
}

.timer-card.expanded .timer-button {
    padding: 1rem 2rem;
    font-size: 1.25rem;
    width: 9rem;
}

.timer-button.start,
.timer-button.pause,
.timer-button.resume {
    background-color: var(--progress-green);
    color: white;
}

.timer-button.resume {
    background-color: var(--progress-yellow-green);
}

.timer-button.reset {
    background-color: var(--text-color);
    color: white;
}

.timer-button:hover {
    opacity: 0.9;
}

.timer-button:active {
    transform: scale(0.98);
}

.timer-button.disabled {
    background-color: #d3d3d3;
    cursor: not-allowed;
    pointer-events: none;
}

.timer-info {
    font-weight: bold;
    text-align: center;
    flex: 1;
    margin: 0 1rem;
}

.time-remaining {
    font-size: 1.125rem;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.timer-card.expanded .time-remaining {
    font-size: 3.5rem;
}

.sound-toggle-icon {
    position: absolute;
    top: 1rem;
    left: 1rem;
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--icon-color);
    color: white;
}

.timer-card:hover .sound-toggle-icon {
    opacity: 1;
    visibility: visible;
}

.sound-toggle-icon:hover {
    background-color: var(--text-color);
    transform: scale(1.1);
}

/* Tooltip styles */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

.start-time.disabled:hover::after,
.end-time.disabled:hover::after {
    display: block;
}

.start-time:not(.disabled):hover::after,
.end-time:not(.disabled):hover::after {
    display: none;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    body {
        padding: 0.5rem;
    }

    .timer-card {
        max-width: 100%;
        padding: 1rem;
    }

    .timer-card.expanded {
        max-width: 100%;
        transform: none;
        padding: 1rem;
    }

    .timer-title {
        font-size: 1.2rem;
    }

    .timer-card.expanded .timer-title {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }

    .start-time,
    .end-time {
        font-size: 1.5rem;
    }

    .timer-card.expanded .start-time,
    .timer-card.expanded .end-time {
        font-size: 2.5rem;
    }

    .expand-icon {
        width: 1.5rem;
        height: 1.5rem;
        top: 0.5rem;
        right: 0.5rem;
    }

    .timer-times {
        justify-content: space-between;
        align-items: center;
    }

    .start-time,
    .end-time {
        text-align: left;
    }
}

@media screen and (max-width: 480px) {
    .timer-title {
        font-size: 1.1rem;
    }

    .timer-card.expanded .timer-title {
        font-size: 1.6rem;
    }

    .start-time,
    .end-time {
        font-size: 1.3rem;
    }

    .timer-card.expanded .start-time,
    .timer-card.expanded .end-time {
        font-size: 2.2rem;
    }

    .timer-card {
        padding: 0.75rem;
    }
    
    .timer-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
}

/* Disable expand icon on small mobile devices (multiple device sizes) */
@media screen and (max-width: 932px) and (max-height: 600px),
       screen and (max-width: 768px),
       screen and (max-width: 480px),
       screen and (device-width: 430px) and (device-height: 932px) {
    .expand-icon {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .timer-card {
        max-width: 100%;
    }

    .timer-card:hover .expand-icon {
        display: none !important;
    }
}

/* Ensure touch targets are large enough */
@media (pointer: coarse) {
    .time-part,
    .expand-icon,
    .timer-button {
        min-height: 44px;
        min-width: 44px;
    }
}

footer a.disabled-link {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

/* Footer and Copyright Notice Styles */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: transparent;
    padding: 0.5rem 0;
    text-align: center;
    z-index: 1000;
}

.copyright-notice {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    background-color: transparent;
    color: var(--text-color);
}

body.dark-mode .copyright-notice {
    color: var(--text-color-dark);
}

body.dark-mode .copyright-notice a {
    color: var(--icon-color);
    transition: color 0.3s ease;
}

body.dark-mode .copyright-notice a:hover {
    color: white;
}

.theme-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Theme Mode Text Styles */
.theme-mode-text {
    cursor: pointer;
    user-select: none;
    transition: color 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-left: 0.5rem;
}

.theme-mode-text:hover {
    color: var(--success-color);
}

body.dark-mode .theme-mode-text {
    color: var(--text-color-dark);
}

body.dark-mode .theme-mode-text:hover {
    color: var(--success-color);
}

.copyright-notice p {
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
}

.theme-switch-input,
.theme-switch-label,
.theme-switch-inner,
.theme-switch-switch {
    display: none;
}

/* Hide footer when timer card is expanded */
.timer-card.expanded ~ footer {
    display: none;
}
