/**
 * Conversation Timer - Frontend Styles
 * 
 * Mechanical split-flap style countdown timer with responsive design
 * and accessibility features.
 */

/* CSS Custom Properties */
:root {
    /* Default colors (dark mechanical) */
    --cm-card-bg: #0f1115;
    --cm-card-fg: #ffffff;
    
    /* Warning colors (yellow) */
    --cm-warn-bg: #ffd400;
    --cm-warn-fg: #000000;
    
    /* Danger colors (red) */
    --cm-danger-bg: #e02424;
    --cm-danger-fg: #ffffff;
    
    /* Transition timing */
    --cm-transition: all 200ms ease-in-out;
    
    /* Typography */
    --cm-font-family: 'Impact', 'Arial Black', 'Helvetica Neue', 'Helvetica', sans-serif;
}

/* Timer Display */
.cm-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    font-family: var(--cm-font-family);
    font-weight: bold;
    line-height: 1;
}

/* Cards container */
.cm-timer .cm-cards {
    display: flex;
    align-items: center;
    gap: 0.25em;
}

/* Individual digit cards */
.cm-timer .cm-card {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 160px;
    padding: 40px 20px;
    background-color: var(--cm-card-bg);
    color: var(--cm-card-fg);
    border-radius: 0.5em;
    font-size: 80px;
    font-weight: 900;
    font-stretch: condensed;
    letter-spacing: -0.02em;
    position: relative;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.1),
        inset 0 -2px 0 rgba(0, 0, 0, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
    transition: var(--cm-transition);
}

/* Split line effect (mechanical flip card look) */
.cm-timer .cm-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%);
    z-index: 1;
}

/* Colon separator */
.cm-timer .cm-card.cm-colon {
    background: transparent !important;
    box-shadow: none !important;
    color: white !important;
    width: 40px;
    height: 160px;
    padding: 40px 0;
    font-size: 60px;
    font-weight: 900;
}

.cm-timer .cm-card.cm-colon::after {
    display: none;
}

/* Live region for screen readers */
.cm-timer .cm-live {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Warning state (≤ 30 seconds) */
.cm-timer.cm-warning .cm-card {
    background-color: var(--cm-warn-bg);
    color: var(--cm-warn-fg);
}

.cm-timer.cm-warning .cm-card::after {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Danger state (≤ 10 seconds) */
.cm-timer.cm-danger .cm-card {
    background-color: var(--cm-danger-bg);
    color: var(--cm-danger-fg);
}

.cm-timer.cm-danger .cm-card::after {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Timer Control */
.cm-timer-control {
    display: inline-block;
    padding: 2rem;
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    border: none;
    border-radius: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.cm-timer-control::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
}

/* Duration selector */
.cm-timer-control .cm-duration-selector {
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

/* Time inputs container */
.cm-timer-control .cm-time-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

/* Individual time field */
.cm-timer-control .cm-time-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    position: relative;
}

/* Time labels */
.cm-timer-control .cm-time-label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 700;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Time input fields */
.cm-timer-control .cm-time-input {
    width: 100%;
    padding: 1.25rem 0.75rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.75rem;
    font-size: 2.5rem;
    font-weight: 700;
    font-family: var(--cm-font-family);
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 80px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    color: #2d3748;
}

.cm-timer-control .cm-time-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3), 0 12px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px) scale(1.05);
    background: rgba(255, 255, 255, 1);
}

.cm-timer-control .cm-time-input:hover {
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.12);
}

/* Time separator */
.cm-timer-control .cm-time-separator {
    font-size: 3rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1;
    margin-top: 2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

/* Number inputs (advanced) */
.cm-timer-control .cm-number-inputs {
    margin-top: 1rem;
}

.cm-timer-control .cm-number-inputs summary {
    cursor: pointer;
    padding: 0.5rem;
    background-color: #e9ecef;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: #495057;
    list-style: none;
}

.cm-timer-control .cm-number-inputs summary::-webkit-details-marker {
    display: none;
}

.cm-timer-control .cm-number-inputs summary::before {
    content: '▶ ';
    margin-right: 0.5rem;
}

.cm-timer-control .cm-number-inputs[open] summary::before {
    content: '▼ ';
}

.cm-timer-control .cm-number-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
}

.cm-timer-control .cm-number-controls label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.cm-timer-control .cm-number-controls input[type="number"] {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.cm-timer-control .cm-number-controls input[type="number"]:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

/* Control buttons */
.cm-timer-control .cm-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.cm-timer-control .cm-btn {
    flex: 1;
    min-width: 100px;
    padding: 1rem 1.5rem;
    border: 2px solid transparent;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.cm-timer-control .cm-btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.cm-timer-control .cm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.cm-timer-control .cm-btn:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.cm-timer-control .cm-btn:not(:disabled):active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Button variants */
.cm-timer-control .cm-btn-start {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.cm-timer-control .cm-btn-start:hover:not(:disabled) {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 8px 24px rgba(34, 197, 94, 0.3);
}

.cm-timer-control .cm-btn-resume {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.cm-timer-control .cm-btn-resume:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.cm-timer-control .cm-btn-pause {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.cm-timer-control .cm-btn-pause:hover:not(:disabled) {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.cm-timer-control .cm-btn-reset {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

.cm-timer-control .cm-btn-reset:hover:not(:disabled) {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
}

/* Responsive design */
@media (max-width: 768px) {
    .cm-timer .cm-card {
        width: 100px;
        height: 140px;
        padding: 30px 15px;
        font-size: 70px;
    }

    .cm-timer .cm-card.cm-colon {
        width: 35px;
        height: 140px;
        padding: 30px 0;
        font-size: 50px;
        background: transparent !important;
        box-shadow: none !important;
        color: white !important;
    }
    
    .cm-timer-control {
        padding: 1.5rem;
        max-width: 100%;
        margin: 0.5rem;
    }
    
    .cm-timer-control .cm-time-inputs {
        gap: 1.5rem;
    }
    
    .cm-timer-control .cm-time-field {
        min-width: 120px;
    }
    
    .cm-timer-control .cm-time-input {
        font-size: 2.5rem;
        padding: 1.5rem 1rem;
        min-height: 90px;
    }
    
    .cm-timer-control .cm-time-separator {
        font-size: 3.5rem;
    }
    
    .cm-timer-control .cm-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .cm-timer-control .cm-btn {
        min-width: auto;
        padding: 1.25rem;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .cm-timer .cm-card {
        width: 80px;
        height: 120px;
        padding: 20px 10px;
        font-size: 60px;
    }

    .cm-timer .cm-card.cm-colon {
        width: 30px;
        height: 120px;
        padding: 20px 0;
        font-size: 40px;
        background: transparent !important;
        box-shadow: none !important;
        color: white !important;
    }
    
    .cm-timer-control {
        padding: 1.25rem;
        margin: 0.25rem;
        border-radius: 0.75rem;
    }
    
    .cm-timer-control .cm-time-inputs {
        gap: 2rem;
    }
    
    .cm-timer-control .cm-time-field {
        min-width: 140px;
    }
    
    .cm-timer-control .cm-time-input {
        font-size: 3rem;
        padding: 1.75rem 1.25rem;
        min-height: 110px;
        border-width: 3px;
    }
    
    .cm-timer-control .cm-time-separator {
        font-size: 4rem;
    }
    
    .cm-timer-control .cm-time-label {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .cm-timer-control .cm-btn {
        padding: 1.5rem;
        font-size: 1.2rem;
        min-height: 70px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cm-timer .cm-card {
        border: 2px solid currentColor;
    }
    
    .cm-timer-control {
        border: 3px solid currentColor;
        background: #000;
    }
    
    .cm-timer-control .cm-time-label {
        color: #fff;
    }
    
    .cm-timer-control .cm-time-input {
        border: 3px solid currentColor;
        background: #fff;
        color: #000;
    }
    
    .cm-timer-control .cm-btn {
        border-width: 3px;
        border-color: currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cm-timer .cm-card,
    .cm-timer-control .cm-btn {
        transition: none;
    }
}

/* Print styles */
@media print {
    .cm-timer-control {
        display: none;
    }
    
    .cm-timer .cm-card {
        background-color: white !important;
        color: black !important;
        border: 1px solid black;
        box-shadow: none;
    }
    
    .cm-timer .cm-card::after {
        display: none;
    }
}
