/* Timer and Stopwatch Specific Styles */

.timer-container {
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-md) var(--spacing-sm);
    /* Removed border-top to eliminate grey line */
    min-height: auto;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

/* Remove outer blue focus outline for the whole Timer & Stopwatch area */
.timer-subsection:focus {
    outline: none !important;
    box-shadow: none !important;
}

.timer-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-color);
}

.timer-mode-toggle {
    display: flex;
    margin-bottom: 0;
    border-radius: 6px;
    overflow: hidden;
    border: none; /* Remove border to eliminate grey line */
    box-shadow: 0 0 0 1px var(--border-color); /* Use box-shadow instead for cleaner look */
}

.mode-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background-color: var(--button-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-height: 48px;
}

.mode-btn.active {
    background-color: #007AFF;
    color: white;
}

.mode-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.mode-btn.disabled:hover {
    background-color: var(--button-bg);
    transform: none;
}

.timer-display {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    padding: var(--spacing-sm);
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0;
    cursor: text;
    /* Limit transitions to non-layout properties to prevent jumps */
    transition: color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    outline: none;
    /* Stabilize height regardless of state */
    line-height: 1.2;
    min-height: 30px; /* matches 24px font with 1.2 line-height */
}

.timer-display:hover:not([contenteditable="false"]) {
    border-color: #007AFF;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.timer-display:focus {
    /* Remove focus border highlight for timer display while retaining global outline */
    border-color: var(--border-color);
    box-shadow: none;
}

.timer-display[contenteditable="false"] {
    cursor: default;
}

.timer-display.placeholder {
    color: #999;
    font-style: italic;
    /* Inherit base font size to avoid height change */
    transition: opacity 0.3s ease, color 0.3s ease;
    /* Smoother, longer breathing effect when resting */
    animation: placeholderPulse 4s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

[data-theme="dark"] .timer-display.placeholder {
    color: #666;
}

/* Enhanced placeholder animation */
@keyframes placeholderPulse {
    0%, 100% {
        opacity: 0.85;
        filter: brightness(1);
    }
    50% {
        opacity: 1;
        filter: brightness(1.06);
    }
}

/* Active timer visual state */
.timer-container.active {
    background-color: #7a9cc6;
    border-radius: 8px;
}

.timer-container.active .timer-display {
    background-color: rgba(255, 255, 255, 0.9);
}

.timer-container.active .timer-title {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

/* Dark theme active timer display override */
[data-theme="dark"] .timer-container.active .timer-display {
    background-color: rgba(0, 0, 0, 0.8) !important;
    color: #ffffff !important;
}

/* Override base focus highlight for timer display ID specifically (keeps outline via base.css) */
#timerDisplay:focus {
    box-shadow: none !important;
}

/* Timer completion flash effect */
.timer-container.complete-flash {
    position: relative;
    border-radius: 8px;
}

.timer-container.complete-flash::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    z-index: -1;
    animation: completePulse 5s ease-in-out;
}

@keyframes completePulse {
    0% { background-color: #28a745; opacity: 1; }
    50% { background-color: #34ce57; opacity: 1; }
    80% { background-color: #28a745; opacity: 1; }
    100% { background-color: #28a745; opacity: 0; }
}

.timer-controls {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    margin-top: 8px;
}

.timer-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background-color: var(--button-bg);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.timer-btn:hover {
    background-color: var(--button-hover);
    transform: translateY(-1px);
}

.timer-btn.hidden {
    display: none;
}

/* CSS Icons for Timer Buttons */
.icon-play::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 10px solid currentColor;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    margin-left: 2px;
}

.icon-pause::before {
    content: '';
    display: block;
    width: 8px;
    height: 12px;
    background: linear-gradient(to right, currentColor 0px, currentColor 3px, transparent 3px, transparent 5px, currentColor 5px, currentColor 8px);
}

.icon-reset::before {
    content: '↻';
}

.icon-note {
    position: relative;
}

.icon-note::before {
    content: '';
    display: block;
    width: 10px;
    height: 12px;
    border: 1.5px solid currentColor;
    border-radius: 1px;
    background-color: transparent;
}

.icon-note::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 1px;
    background-color: currentColor;
    box-shadow: 0 2px 0 currentColor, 0 4px 0 currentColor;
}

.theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
}

.theme-toggle input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    background-color: var(--border-color);
    border-radius: 34px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
}

.toggle-slider:hover {
    background-color: var(--button-hover);
}

.toggle-button {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    top: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.theme-toggle input:checked + .toggle-slider {
    background-color: #007AFF;
}

.theme-toggle input:checked + .toggle-slider .toggle-button {
    transform: translateX(24px);
}

.theme-toggle input:focus + .toggle-slider {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Dark theme adjustments */
[data-theme="dark"] .toggle-button {
    background-color: var(--bg-color);
}

[data-theme="dark"] .theme-toggle input:checked + .toggle-slider {
    background-color: #0A84FF;
}

/* Loading States and Feedback */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid #007AFF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    margin-top: 20px;
    font-size: 16px;
    text-align: center;
}

/* Toast notifications are defined globally in components.css to avoid duplication */

/* Operation feedback states */
.calc-btn.pressed {
    transform: scale(0.95);
    background-color: var(--button-hover);
}

.operation-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 122, 255, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.operation-feedback.show {
    opacity: 1;
}

/* Save indicator is defined globally in components.css */
