/**
 * Lesson Activity Timer Styles
 */

/* Timer Page Base */
.timer-page {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg-color, #ffffff);
}

/* Modal Overlay */
.timer-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.timer-modal-overlay.hidden {
    display: none;
}

/* Modal Box */
.timer-modal {
    background: white;
    border-radius: 12px;
    max-width: 75%;
    width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

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

.timer-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.timer-modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.timer-modal-close:hover {
    color: #333;
}

.timer-modal-body {
    padding: 15px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    overflow: visible;
}

.timer-modal-body .timer-form-group.full-width {
    grid-column: 1 / -1;
    overflow: visible;
}

.timer-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

/* Form Groups */
.timer-form-group {
    margin-bottom: 0;
}

.timer-form-group > label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #555;
    font-size: 0.9rem;
}

.timer-form-group select,
.timer-form-group input[type="time"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
}

.timer-form-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.timer-form-row .timer-form-group:first-child {
    flex: 1;
}

.timer-toggle-group {
    padding-bottom: 12px;
}

/* Timer Type Toggle */
.timer-type-toggle {
    display: flex;
    background: #f0f0f0;
    border-radius: 6px;
    padding: 3px;
}

.timer-type-btn,
.timer-style-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s;
    color: #666;
}

.timer-type-btn.active,
.timer-style-btn.active {
    background: var(--primary-color, #99CCFF);
    color: white;
}

.timer-type-btn:hover:not(.active),
.timer-style-btn:hover:not(.active) {
    background: #e0e0e0;
}

/* Sound Settings */
.timer-sounds-section {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 6px;
}

.timer-sounds-section > label {
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.timer-sound-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.timer-sound-row:last-child {
    margin-bottom: 0;
}

.timer-sound-row .toggle-wrapper {
    min-width: 140px;
}

.timer-sound-row .toggle-wrapper span {
    font-size: 0.85rem;
}

.timer-sound-row .sound-select,
.timer-sound-row .time-select {
    width: auto;
    min-width: 100px;
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Clock Display Row */
.timer-clock-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.timer-clock-row .clock-select {
    width: auto;
    min-width: 120px;
    padding: 8px 12px;
}

/* Toggle Switch (reuse from main.css) */
.timer-modal .toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-modal .toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.timer-modal .toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.timer-modal .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.timer-modal .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.timer-modal .toggle input:checked + .slider {
    background-color: var(--primary-color, #99CCFF);
}

.timer-modal .toggle input:checked + .slider:before {
    transform: translateX(20px);
}

/* Quill Editor */
.timer-modal .editor-wrapper {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: visible;
}

.timer-modal .ql-container {
    min-height: 60px;
    height: 80px;
    overflow-y: auto;
    font-size: 0.9rem;
    resize: vertical;
}

.timer-modal .ql-editor {
    min-height: 60px;
    padding: 8px 12px;
}

.timer-modal .ql-toolbar {
    border: none;
    border-bottom: 1px solid #ddd;
    padding: 6px 8px;
    position: relative;
    z-index: 10;
}

.timer-modal .ql-toolbar .ql-formats {
    margin-right: 10px;
}

/* Ensure Quill dropdowns appear above modal content */
.timer-modal .ql-picker-options {
    z-index: 1001 !important;
}

.timer-modal .ql-expanded .ql-picker-options {
    display: block;
    margin-top: -1px;
    top: 100%;
}

/* Start Button */
.timer-btn-start {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 60px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.timer-btn-start:hover {
    background: #45a049;
}

/* Timer Container */
.timer-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: 100px; /* Space for logo */
    padding-bottom: 80px; /* Space for controls */
    background: var(--bg-color, #ffffff);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

/* Content wrapper - groups message, countdown, clock together */
.timer-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-height: 100%;
}

/* Timer Logo */
.timer-logo-wrapper {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.timer-logo {
    max-height: 80px;
    max-width: 250px;
    object-fit: contain;
}

/* Timer Message */
.timer-message-wrapper {
    position: relative;
    text-align: center;
    max-width: 800px;
    width: 100%;
    box-sizing: border-box;
}

.timer-message {
    color: var(--dial-color, #333);
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    line-height: 1.4;
    word-wrap: break-word;
}

.timer-message:empty {
    display: none;
}

.timer-message img {
    max-width: 100%;
    max-height: 120px;
    height: auto;
    object-fit: contain;
}

.timer-message p {
    margin: 0 0 5px 0;
}

.timer-message p:last-child {
    margin-bottom: 0;
}

.timer-message ul, .timer-message ol {
    margin: 0 0 5px 0;
    padding-left: 20px;
}

/* Quill font size classes - relative to base size */
.timer-message .ql-size-small {
    font-size: 0.75em;
}

.timer-message .ql-size-large {
    font-size: 1.5em;
}

.timer-message .ql-size-huge {
    font-size: 2.5em;
}

/* Edit message button - subtle, appears next to message */
.timer-edit-message-btn {
    position: absolute;
    top: 0;
    right: -30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #999;
    opacity: 0.5;
    transition: opacity 0.2s, color 0.2s;
}

.timer-edit-message-btn:hover {
    opacity: 1;
    color: #666;
}

.timer-edit-message-btn svg {
    width: 16px;
    height: 16px;
}

/* Countdown Display */
.timer-countdown-wrapper {
    text-align: center;
}

/* Circle Display (TimeCircles) */
.timer-circle-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#timerCircle {
    position: relative;
    /* Size is set dynamically by JavaScript */
}

/* TimeCircles creates a wrapper div - need to position text inside it */
#timerCircle > div {
    position: relative !important;
}

/* TimeCircles text positioning - centered inside the circle */
#timerCircle .textDiv_Minutes {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
}

#timerCircle .textDiv_Minutes h4 {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.15em !important;
    font-size: clamp(0.7rem, 1.5vw, 1rem) !important;
    color: var(--timer-text-color, var(--dial-color, #333)) !important;
    margin: 0 0 5px 0 !important;
    line-height: 1 !important;
}

/* Hide the original TimeCircles span - we use a clone for custom format */
#timerCircle .textDiv_Minutes > span:first-of-type {
    display: none !important;
}

#timerCircle .textDiv_Minutes span {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace !important;
    font-weight: 700 !important;
    font-size: clamp(3.5rem, 8vw, 5.5rem) !important;
    color: var(--timer-text-color, var(--dial-color, #333)) !important;
    line-height: 1 !important;
}

/* Circle display states */
.timer-circle-display.paused {
    opacity: 0.6;
}

.timer-circle-display.ended #timerCircle {
    animation: pulse 1s ease-in-out infinite;
}

/* Digital Display */
.timer-digital-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timer-countdown {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: clamp(8rem, 25vw, 20rem);
    font-weight: 900;
    color: var(--primary-color, #99CCFF);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.02em;
}

.timer-digits {
    display: inline-block;
    min-width: 0.6em;
    text-align: center;
}

.timer-separator {
    margin: 0 0.02em;
    opacity: 1;
    transition: opacity 0.3s;
}

.timer-countdown.running .timer-separator {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 45% { opacity: 1; }
    50%, 95% { opacity: 0.2; }
    100% { opacity: 1; }
}

.timer-countdown.paused {
    opacity: 0.6;
}

.timer-countdown.ended {
    animation: pulse 1s ease-in-out infinite;
}

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

/* Interval countdown between repeats */
.timer-countdown.interval,
.timer-circle-display.interval {
    opacity: 0.7;
}

.timer-countdown.interval {
    animation: intervalPulse 1s ease-in-out infinite;
}

.timer-countdown.interval .timer-digits:first-child {
    /* Hide minutes during interval */
    display: none;
}

.timer-countdown.interval .timer-separator {
    display: none;
}

.timer-countdown.interval .timer-digits:last-child {
    /* Make seconds larger and centered during interval */
    font-size: 1.2em;
}

@keyframes intervalPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.timer-status {
    font-size: 1.2rem;
    color: var(--dial-color, #666);
    margin-top: 5px;
}

.timer-status:empty {
    display: none;
}

/* Optional Clock - fixed top right, level with logo */
.timer-clock-wrapper {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 1000 !important;
    margin: 0 !important;
}

.timer-clock-wrapper #timerAnalogClock {
    width: 120px !important;
    height: 120px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.timer-clock-wrapper #timerAnalogClock > * {
    margin: 0 auto !important;
}

.timer-digital-clock {
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: 1.8rem;
    color: var(--digital-clock-color, var(--dial-color, #333));
    font-weight: 500;
    white-space: nowrap;
}

/* Control Bar */
.timer-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.timer-control-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(128, 128, 128, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.timer-control-btn:hover {
    background: rgba(128, 128, 128, 0.25);
    transform: scale(1.1);
}

.timer-control-btn svg {
    width: 22px;
    height: 22px;
    fill: #666;
}

.timer-control-btn.muted .icon-sound {
    display: none;
}

.timer-control-btn.muted .icon-mute {
    display: block !important;
    fill: #f44336;
}

/* Responsive */
@media (max-width: 768px) {
    .timer-modal {
        max-width: calc(100% - 20px);
        width: auto;
        margin: 10px;
        max-height: calc(100vh - 20px);
    }

    .timer-modal-body {
        padding: 20px;
    }

    .timer-countdown {
        font-size: clamp(5rem, 30vw, 10rem);
    }


    .timer-controls {
        bottom: 15px;
        left: 15px;
        gap: 8px;
    }

    .timer-control-btn {
        width: 44px;
        height: 44px;
    }

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

    .timer-sound-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .timer-sound-row .sound-select,
    .timer-sound-row .time-select {
        width: 100%;
    }

    .timer-form-row {
        flex-direction: column;
        gap: 10px;
    }

    .timer-toggle-group {
        padding-bottom: 0;
    }
}

@media (max-width: 480px) {
    .timer-countdown {
        font-size: clamp(4rem, 35vw, 7rem);
    }

    .timer-logo {
        max-height: 60px;
    }

    .timer-digital-clock {
        font-size: 1.5rem;
    }

    .timer-clock-wrapper #timerAnalogClock {
        width: 100px !important;
        height: 100px !important;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .timer-logo-wrapper {
        top: 10px;
    }

    .timer-logo {
        max-height: 50px;
    }

    .timer-container {
        padding-top: 70px;
    }

    .timer-countdown {
        font-size: clamp(4rem, 20vh, 8rem);
    }

    .timer-message {
        margin-bottom: 10px;
        font-size: 0.95rem;
    }

    .timer-clock-wrapper {
        margin-top: 10px;
    }

    .timer-clock-wrapper #timerAnalogClock {
        width: 100px !important;
        height: 100px !important;
    }

    .timer-digital-clock {
        font-size: 1.5rem;
    }
}

/* Fullscreen adjustments */
.timer-page:fullscreen .timer-container,
.timer-page:-webkit-full-screen .timer-container {
    padding: 40px;
}

.timer-page:fullscreen .timer-countdown,
.timer-page:-webkit-full-screen .timer-countdown {
    font-size: clamp(10rem, 30vw, 25rem);
}


/* Hidden circle/time states */
#timerCircle.hide-circle canvas {
    visibility: hidden !important;
}

#timerCircle.hide-time .textDiv_Minutes {
    display: none !important;
}
