/**
 * XClock v3.0 - Complete Feature Set Styles
 * Clock, Alarm, Stopwatch, Timer with dark mode
 */

/* Audio element - hidden */
#xclock-alarm-sound {
    display: none;
}

/* Main container */
#xclock-display {
    font-family: 'Courier New', 'Monaco', monospace;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 2rem auto;
    max-width: 700px;
    padding: 0;
    overflow: hidden;
}

/* Tab navigation */
.xclock-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.xclock-tab {
    flex: 1;
    padding: 1rem;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.xclock-tab:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.xclock-tab.active {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.xclock-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #2563eb;
}

/* Content area */
.xclock-content {
    display: none;
    padding: 2rem;
    text-align: center;
}

.xclock-content.active {
    display: block;
}

/* Time displays */
.xclock-time-12h {
    font-size: 3rem;
    font-weight: 600;
    color: #666;
    letter-spacing: 0.1em;
    margin: 0.5rem 0 0 0;
    user-select: none;
}

.xclock-time {
    font-size: 4rem;
    font-weight: 700;
    color: #333;
    letter-spacing: 0.1em;
    margin: 0.5rem 0 1rem 0;
    user-select: none;
}

#stopwatch-time {
    font-size: 3rem;
}

/* Control buttons */
.xclock-controls {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.xclock-btn {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-width: 100px;
}

.xclock-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.xclock-btn:active {
    transform: translateY(0);
}

/* Button variants */
.xclock-btn-start {
    background: #10b981;
    color: white;
}

.xclock-btn-start:hover {
    background: #059669;
}

.xclock-btn-stop {
    background: #ef4444;
    color: white;
}

.xclock-btn-stop:hover {
    background: #dc2626;
}

.xclock-btn-reset {
    background: #6b7280;
    color: white;
}

.xclock-btn-reset:hover {
    background: #4b5563;
}

.xclock-btn-set {
    background: #2563eb;
    color: white;
}

.xclock-btn-set:hover {
    background: #1d4ed8;
}

/* Timer creation area */
.xclock-timer-create {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    margin-bottom: 2rem;
}

.xclock-timer-create > .xclock-input-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.xclock-timer-create #timer-label {
    width: 100%;
    max-width: 400px;
    text-align: left;
}

.xclock-timer-time-inputs {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Timer list */
.xclock-timer-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.xclock-timer-item {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.xclock-timer-item:hover {
    background: rgba(0, 0, 0, 0.08);
}

.xclock-timer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.xclock-timer-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.xclock-timer-time {
    font-size: 2rem;
    font-weight: 700;
    color: #2563eb;
    font-family: 'Courier New', monospace;
}

.xclock-timer-progress {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.xclock-timer-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #2563eb 100%);
    transition: width 0.5s linear;
    border-radius: 4px;
}

.xclock-timer-controls {
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
}

.xclock-btn-small {
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    min-width: 80px !important;
}

/* Legacy timer inputs (kept for compatibility) */
.xclock-timer-inputs {
    margin: 1.5rem 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.xclock-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.xclock-input-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #666;
}

.xclock-input {
    padding: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    text-align: center;
    width: 80px;
    font-family: 'Courier New', 'Monaco', monospace;
    transition: border-color 0.3s ease;
}

.xclock-input:focus {
    outline: none;
    border-color: #2563eb;
}

/* Pulse animation for timer alarm */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    #xclock-display {
        max-width: 100%;
        margin: 1rem;
    }

    .xclock-time-12h {
        font-size: 2rem;
    }

    .xclock-time {
        font-size: 3rem;
    }

    #stopwatch-time {
        font-size: 2rem;
    }

    .xclock-tab {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    .xclock-content {
        padding: 1.5rem;
    }

    .xclock-btn {
        padding: 0.65rem 1.5rem;
        font-size: 0.875rem;
        min-width: 80px;
    }

    .xclock-timer-inputs {
        flex-direction: column;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .xclock-time-12h {
        font-size: 1.5rem;
    }

    .xclock-time {
        font-size: 2rem;
    }

    #stopwatch-time {
        font-size: 1.5rem;
    }

    .xclock-tab {
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .xclock-content {
        padding: 1rem;
    }

    .xclock-controls {
        gap: 0.5rem;
    }

    .xclock-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        min-width: 70px;
    }

    .xclock-input {
        width: 60px;
        padding: 0.5rem;
        font-size: 1rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #xclock-display {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }

    .xclock-tabs {
        background: rgba(255, 255, 255, 0.05);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .xclock-tab {
        color: #9ca3af;
    }

    .xclock-tab:hover {
        background: rgba(255, 255, 255, 0.05);
        color: #e5e7eb;
    }

    .xclock-tab.active {
        color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
    }

    .xclock-tab.active::after {
        background: #60a5fa;
    }

    .xclock-time-12h {
        color: #9ca3af;
    }

    .xclock-time {
        color: #f5f7fa;
    }

    .xclock-input-group label {
        color: #9ca3af;
    }

    .xclock-input {
        background: rgba(255, 255, 255, 0.1);
        border-color: #4b5563;
        color: #f5f7fa;
    }

    .xclock-input:focus {
        border-color: #60a5fa;
        background: rgba(255, 255, 255, 0.15);
    }

    .xclock-btn-reset {
        background: #4b5563;
    }

    .xclock-btn-reset:hover {
        background: #374151;
    }
}

/* ==========================================
   NEW FEATURES - v3.0
   ========================================== */

/* Clock Date Display */
.xclock-date {
    font-size: 1.2rem;
    color: #666;
    margin-top: 0.5rem;
    font-weight: 400;
}

/* Alarm Tab */
.xclock-alarm-inputs {
    margin-bottom: 1.5rem;
}

.xclock-input-row {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Alarm label input - wider and centered */
.xclock-alarm-inputs > .xclock-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#alarm-label {
    width: 100%;
    max-width: 400px;
    text-align: left;
}

.xclock-alarm-list {
    margin-top: 2rem;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

.xclock-alarm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.xclock-alarm-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.xclock-alarm-info strong {
    font-size: 1.2rem;
    color: #333;
}

.xclock-alarm-status {
    font-size: 0.9rem;
    color: #666;
}

.xclock-alarm-remove {
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    min-width: auto !important;
}

/* Stopwatch Laps */
.xclock-laps-list {
    margin-top: 2rem;
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

.xclock-laps-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    text-align: center;
}

.xclock-lap-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.xclock-lap-item span:first-child {
    font-weight: 600;
    color: #666;
}

.xclock-lap-item span:last-child {
    font-family: 'Courier New', monospace;
    color: #333;
}

/* Modal/Popup */
.xclock-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

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

.xclock-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideDown 0.3s ease;
}

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

.xclock-modal-content h2 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.8rem;
}

.xclock-modal-content p {
    margin: 0 0 2rem 0;
    color: #666;
    font-size: 1.1rem;
}

/* Advanced Snooze Section */
.xclock-snooze-section {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

.xclock-snooze-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.75rem;
    text-align: center;
}

.xclock-snooze-quick-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.xclock-btn-snooze-quick {
    padding: 0.5rem 1rem !important;
    font-size: 0.9rem !important;
    min-width: 60px !important;
    background: #8b5cf6;
    color: white;
}

.xclock-btn-snooze-quick:hover {
    background: #7c3aed;
}

.xclock-snooze-custom {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.xclock-snooze-custom input {
    width: 80px;
    padding: 0.5rem;
    font-size: 1rem;
}

.xclock-snooze-unit {
    font-size: 0.9rem;
    color: #666;
}

.xclock-modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.xclock-modal-buttons .xclock-btn {
    flex: 1;
}

/* Select elements */
select.xclock-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23666" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.5em;
    padding-right: 2.5rem;
    color: #000 !important;
    background-color: #fff;
}

select.xclock-input option {
    color: #000 !important;
    background-color: #fff;
}

/* ==========================================
   DARK MODE ENHANCEMENTS
   ========================================== */

@media (prefers-color-scheme: dark) {
    .xclock-date {
        color: #9ca3af;
    }

    .xclock-alarm-item {
        background: rgba(255, 255, 255, 0.05);
    }

    .xclock-alarm-info strong {
        color: #f5f7fa;
    }

    .xclock-alarm-status {
        color: #9ca3af;
    }

    .xclock-laps-header {
        color: #f5f7fa;
    }

    .xclock-lap-item {
        background: rgba(255, 255, 255, 0.05);
    }

    .xclock-lap-item span:first-child {
        color: #9ca3af;
    }

    .xclock-lap-item span:last-child {
        color: #f5f7fa;
    }

    .xclock-timer-create {
        background: rgba(255, 255, 255, 0.05);
    }

    .xclock-timer-item {
        background: rgba(255, 255, 255, 0.05);
    }

    .xclock-timer-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .xclock-timer-label {
        color: #f5f7fa;
    }

    .xclock-timer-time {
        color: #60a5fa;
    }

    .xclock-timer-progress {
        background: rgba(255, 255, 255, 0.1);
    }

    .xclock-modal-content {
        background: #1a202c;
    }

    .xclock-modal-content h2 {
        color: #f5f7fa;
    }

    .xclock-modal-content p {
        color: #9ca3af;
    }

    .xclock-snooze-section {
        background: rgba(255, 255, 255, 0.05);
    }

    .xclock-snooze-label {
        color: #9ca3af;
    }

    .xclock-snooze-unit {
        color: #9ca3af;
    }

    select.xclock-input {
        background-image: url('data:image/svg+xml;utf8,<svg fill="%239ca3af" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    }
}

/* ==========================================
   RESPONSIVE TWEAKS FOR 4 TABS
   ========================================== */

@media (max-width: 768px) {
    .xclock-tab {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .xclock-alarm-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .xclock-alarm-remove {
        width: 100%;
    }

    .xclock-input-row {
        flex-direction: column;
        align-items: stretch;
    }

    .xclock-modal-buttons {
        flex-direction: column;
    }

    .xclock-laps-list,
    .xclock-alarm-list {
        max-height: 200px;
    }

    .xclock-timer-item {
        flex-direction: column;
        align-items: stretch;
    }

    .xclock-timer-time {
        font-size: 1.5rem;
    }

    .xclock-timer-controls {
        flex-direction: row;
        width: 100%;
    }

    .xclock-timer-controls .xclock-btn-small {
        flex: 1;
    }

    .xclock-timer-time-inputs {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .xclock-tab {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }

    .xclock-date {
        font-size: 1rem;
    }

    .xclock-alarm-info strong {
        font-size: 1rem;
    }

    .xclock-timer-time {
        font-size: 1.25rem;
    }

    .xclock-timer-label {
        font-size: 1rem;
    }
}

/* ==========================================
   SOUND SELECTOR COMPONENT
   ========================================== */

.xclock-sound-selector {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

.xclock-sound-selector select {
    flex: 1;
}

.xclock-btn-preview {
    padding: 0.75rem 1rem !important;
    font-size: 1.25rem !important;
    min-width: 50px !important;
    background: #8b5cf6;
    color: white;
    font-family: Arial, sans-serif;
    line-height: 1;
}

.xclock-btn-preview:hover {
    background: #7c3aed;
}

.xclock-btn-preview:active {
    background: #6d28d9;
}

/* Make sound selector inputs full width on alarm tab */
.xclock-alarm-inputs .xclock-sound-selector {
    width: 100%;
    max-width: 400px;
}

/* Ensure proper layout in timer tab */
.xclock-timer-create .xclock-sound-selector {
    width: 100%;
    max-width: 400px;
}

@media (max-width: 768px) {
    .xclock-sound-selector {
        flex-direction: row;
    }

    .xclock-btn-preview {
        min-width: 45px !important;
        padding: 0.65rem 0.85rem !important;
    }
}

@media (max-width: 480px) {
    .xclock-sound-selector {
        gap: 0.35rem;
    }

    .xclock-btn-preview {
        min-width: 40px !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 1rem !important;
    }
}

/* Dark mode for sound selector */
@media (prefers-color-scheme: dark) {
    .xclock-btn-preview {
        background: #8b5cf6;
    }

    .xclock-btn-preview:hover {
        background: #7c3aed;
    }

    .xclock-btn-preview:active {
        background: #6d28d9;
    }
}
