/* Time Display Module Styles */

/* Time Display Area - Independent draggable box */
#time-display-area {
    position: fixed;
    /* Position will be set dynamically above feature-area */
    right: 20px;
    z-index: 998;
    padding: 10px 14px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    display: none;
    cursor: move;
    /* Improved touch device support */
    touch-action: none;
    /* Performance optimization */
    will-change: transform, left, top;
}

#time-display-area.show {
    display: block;
}

#time-display-area.dragging {
    cursor: grabbing;
}

/* Vertical time display area layout (when snapped to left or right) */
#time-display-area.vertical {
    min-width: auto;
    max-width: 250px;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Time display area specific checkbox styling - narrower width */
#time-display-area .checkbox-label {
    max-width: fit-content;
    width: auto;
}

/* Fix config-group in time display area to prevent whitespace */
#time-display-area .config-group {
    width: auto;
    max-width: 100%;
}

#time-display-area .config-group > label {
    margin-right: 0;
}

/* Time display options row - flex layout for checkboxes and settings button */
.time-display-options-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
}

.time-display-checkboxes {
    flex: 0 0 auto;
}

/* Container for settings and fullscreen buttons */
.time-display-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Time display area settings button with text - positioned to the right of checkboxes */
.time-display-settings-btn-with-text {
    position: relative;
    height: auto;
    min-height: 32px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background-color: #f8f8f8;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    color: #666;
    padding: 6px 12px;
    flex-shrink: 0;
    font-size: 12px;
    width: auto;
}

.time-display-settings-btn-with-text:hover {
    background-color: #e8e8e8;
    border-color: var(--theme-color);
    color: #333;
}

/* Time Display Widget */
#time-display {
    position: fixed;
    top: 140px;  /* Below pagination controls with appropriate gap (80px top + 36px height + 24px gap) */
    right: 20px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 900;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    transition: transform 0.2s ease, top 0.3s ease, right 0.3s ease, bottom 0.3s ease, left 0.3s ease;
}

#time-display:hover {
    transform: scale(1.05);
}

/* Time display positions */
#time-display.top-right {
    top: 140px;
    right: 20px;
    bottom: auto;
    left: auto;
}

#time-display.top-left {
    top: 140px;
    left: 20px;
    bottom: auto;
    right: auto;
}

#time-display.bottom-right {
    top: auto;
    right: 20px;
    bottom: 240px; /* Above pagination controls - pagination is at 170px */
    left: auto;
}

#time-display.bottom-left {
    top: auto;
    left: 20px;
    bottom: 240px; /* Above pagination controls - pagination is at 170px */
    right: auto;
}

#time-display.show {
    display: block !important;
}

.time-line {
    line-height: 1.5;
    white-space: nowrap;
}

/* Fullscreen Time Display Modal */
.time-fullscreen-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.time-fullscreen-modal.show {
    display: flex;
}

.time-fullscreen-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10001;
}

.time-fullscreen-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.time-fullscreen-close-btn:active {
    transform: scale(0.95);
}

#time-fullscreen-content {
    text-align: center;
    color: white;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#time-fullscreen-content .time-line {
    line-height: 1.3;
    margin: 10px 0;
}

/* Fullscreen Font Size Slider */
.time-fullscreen-controls {
    position: absolute;
    bottom: max(60px, env(safe-area-inset-bottom)); /* Increased bottom spacing */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 10001;
    width: 80%;
    max-width: 600px;
    padding: 20px; /* Added padding to ensure content isn't cut off */
    background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%); /* Optional: improve visibility against bg */
    border-radius: 12px;
}

.time-fullscreen-slider-label {
    /* color: inherited from parent */
    font-size: 14px;
    margin-bottom: 4px;
    opacity: 0.8;
}

.time-fullscreen-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.time-fullscreen-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.time-fullscreen-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Time Display Settings Modal */
#time-display-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: none;
    justify-content: center;
    align-items: center;
}

#time-display-settings-modal.show {
    display: flex;
}

#time-display-settings-modal .timer-modal-header h2 {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 12px;
}

#time-display-settings-modal .timer-modal-header h2 .help-inline-text {
    min-width: 0;
}

/* Tab Navigation Styles */
.timer-tab-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    padding: 4px;
    background-color: #f5f5f7;
    border-radius: 12px;
}

.timer-tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timer-tab-btn.active {
    background-color: #ffffff;
    color: var(--theme-color, #007AFF);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.timer-tab-btn:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.5);
    color: #333;
}

/* Tab Content Visibility */
.td-tab-content {
    display: none;
}

.td-tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}


/* Time Display Responsive Styles */
@media (max-width: 480px) {
    #time-display-widget {
        min-width: auto;
        width: auto;
        padding: 8px 12px;
    }
    
    .time-display-main {
        font-size: 28px;
    }
    
    .time-display-date {
        font-size: 11px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .time-display-btn,
    .time-display-close-btn {
        min-height: var(--touch-target-size);
        min-width: var(--touch-target-size);
    }
}

/* Fullscreen Bottom Controls - Centered at bottom */
.fullscreen-bottom-controls {
    position: absolute;
    bottom: max(40px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 10001;
    width: 90%;
    max-width: 400px;
}

.fullscreen-settings-panel {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease;
}

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

.fullscreen-slider-group {
    margin-bottom: 16px;
}

.fullscreen-slider-group:last-child {
    margin-bottom: 0;
}

.fullscreen-slider-group label {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    text-align: center;
}

.fullscreen-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.fullscreen-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.fullscreen-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.fullscreen-button-row {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.fullscreen-control-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.fullscreen-control-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.fullscreen-control-btn:active {
    transform: scale(0.95);
}

.fullscreen-control-btn.active {
    background-color: var(--theme-color);
}

.fullscreen-close-btn:hover {
    background-color: rgba(255, 59, 48, 0.5);
}
