/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #FFD700;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --border-color: #bdc3c7;
    --transition: all 0.3s ease;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f7fa;
    color: var(--dark-text);
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: white;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.header .subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Selection Section (Role & Speaker) */
.selection-section {
    display: flex;
    gap: 2rem;
    width: 100%;
}

.role-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.role-section label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--dark-text);
}

.role-section select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: var(--dark-text);
    cursor: pointer;
    transition: var(--transition);
}

.role-section select:hover,
.role-section select:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.role-section select.invalid {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.role-section select.shake {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Timer Section */
.timer-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    padding: 2rem;
    background: linear-gradient(to bottom, #f9fafb, #ffffff);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    position: relative;
}

/* Inputs Section */
.inputs-section {
    display: flex;
    gap: 2rem;
    width: 100%;
    justify-content: center;
}

.speaker-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.speaker-input-group label {
    font-weight: 600;
    font-size: 0.95rem;
}

.speaker-input-group input {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.speaker-input-group input:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Timer Display */
.timer-display-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    position: relative;
}

.btn-fullscreen {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-fullscreen:hover {
    background: #2980b9;
    transform: scale(1.1);
}

/* Fullscreen mode */
.timer-section.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2rem;
    margin: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a1a1a 100%);
    border: none;
    border-radius: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

.timer-section.fullscreen .inputs-section {
    order: -1;
    gap: 1.5rem;
    width: 100%;
    max-width: 600px;
}

.timer-section.fullscreen .inputs-section .role-section,
.timer-section.fullscreen .inputs-section .speaker-input-group {
    flex: 1;
}

.timer-section.fullscreen .inputs-section label {
    color: white;
    font-size: 1rem;
}

.timer-section.fullscreen .inputs-section select,
.timer-section.fullscreen .inputs-section input {
    font-size: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.timer-section.fullscreen .inputs-section select::placeholder,
.timer-section.fullscreen .inputs-section input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.timer-section.fullscreen .inputs-section select:focus,
.timer-section.fullscreen .inputs-section input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.6);
    outline: none;
}

.timer-section.fullscreen .timer-display-container {
    gap: 2rem;
}

.timer-section.fullscreen .timer-display {
    font-size: 15rem;
    min-width: auto;
    padding: 2rem;
}

.timer-section.fullscreen .zone-indicator {
    gap: 1rem;
}

.timer-section.fullscreen .zone {
    width: 50px;
    height: 50px;
}

.timer-section.fullscreen .zone-text {
    font-size: 2rem;
}

.timer-section.fullscreen .controls {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.timer-section.fullscreen .btn {
    padding: 1rem 3rem;
    font-size: 1.5rem;
}

.timer-section.fullscreen .btn-fullscreen {
    position: fixed;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    padding: 0.75rem 1.25rem;
}

/* Hide other elements in fullscreen */
.timer-section.fullscreen ~ .history-section,
.timer-section.fullscreen ~ .footer,
body > .header:has(~ .timer-section.fullscreen) {
    display: none !important;
}

.timer-display {
    font-size: 5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 250px;
    text-align: center;
    padding: 2rem;
    border-radius: 12px;
    transition: var(--transition);
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.timer-display.white {
    background: #f5f5f5;
    color: #7f8c8d;
}

.timer-display.green {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.timer-display.yellow {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
}

.timer-display.red {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

/* Zone Indicator */
.zone-indicator {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.zone {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    opacity: 0.3;
    transition: var(--transition);
}

.zone.white {
    background-color: #bdc3c7;
}

.zone.green {
    background-color: var(--success-color);
}

.zone.yellow {
    background-color: var(--warning-color);
}

.zone.red {
    background-color: var(--danger-color);
}

.zone.active {
    opacity: 1;
    box-shadow: 0 0 15px currentColor;
}

.zone-text {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    min-height: 1.5rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.btn {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--success-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #229954;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Time Limits */
.time-limits {
    width: 100%;
    max-width: 500px;
}

.time-limits h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.limits-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.limit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 8px;
    gap: 0.5rem;
    font-weight: 600;
}

.green-bg {
    background-color: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
}

.yellow-bg {
    background-color: rgba(243, 156, 18, 0.15);
    color: var(--warning-color);
}

.red-bg {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--danger-color);
}

.limit-label {
    font-size: 0.85rem;
    opacity: 0.8;
}

.limit-time {
    font-size: 1.25rem;
}

/* History Section */
.history-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-header h2 {
    font-size: 1.5rem;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.current-session,
.past-sessions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.current-session h3,
.past-sessions h3 {
    font-size: 1.1rem;
    color: var(--dark-text);
}

.session-list,
.sessions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
    gap: 1rem;
}

.past-session {
    background: var(--light-bg);
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
    overflow: hidden;
}

.past-session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    gap: 1rem;
    transition: background 0.2s ease;
}

.past-session-header:hover {
    background: rgba(52, 152, 219, 0.05);
}

.past-session-toggle {
    font-size: 0.8rem;
    color: var(--secondary-color);
    transition: transform 0.3s ease;
    min-width: 20px;
    text-align: center;
}

.past-session-details-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.past-session-details-content.expanded {
    max-height: 1000px;
}

.past-session-speakers {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 1rem 1rem 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 1rem;
}

.session-speaker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    gap: 0.75rem;
}

.session-speaker-info {
    flex: 1;
}

.session-speaker-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.session-speaker-details {
    font-size: 0.8rem;
    color: #7f8c8d;
}

.session-speaker-card {
    font-size: 1.2rem;
    text-align: center;
    min-width: 25px;
}

.session-speaker-status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    min-width: 50px;
    text-align: center;
}

.session-speaker-status.good {
    background-color: rgba(39, 174, 96, 0.2);
    color: var(--success-color);
}

.session-speaker-status.over {
    background-color: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
}

.session-speaker-status.under {
    background-color: rgba(243, 156, 18, 0.2);
    color: var(--warning-color);
}

.session-speaker-time {
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}

.session-item-info,
.past-session-info {
    flex: 1;
}

.session-item-name,
.past-session-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.session-item-details,
.past-session-details {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.session-item-card {
    font-size: 1.5rem;
    text-align: center;
    min-width: 30px;
}

.session-item-status {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 55px;
    text-align: center;
}

.session-item-status.good {
    background-color: rgba(39, 174, 96, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.session-item-status.over {
    background-color: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.session-item-status.under {
    background-color: rgba(243, 156, 18, 0.2);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.indicator-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

.indicator-badge.good {
    background-color: rgba(39, 174, 96, 0.15);
    color: var(--success-color);
}

.indicator-badge.over {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--danger-color);
}

.indicator-badge.under {
    background-color: rgba(243, 156, 18, 0.15);
    color: var(--warning-color);
}

.session-item-time,
.past-session-time {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-color);
    min-width: 80px;
    text-align: right;
}

.empty-message {
    text-align: center;
    color: #95a5a6;
    padding: 1rem;
    font-style: italic;
}

/* Footer */
.footer {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: #7f8c8d;
    background: var(--light-bg);
}

.footer-link {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    transition: color 0.2s ease;
}

.footer-link:hover,
.footer-link:focus-visible {
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .main-content {
        padding: 1rem;
        gap: 1.5rem;
    }

    .inputs-section {
        flex-direction: column;
        gap: 1rem;
    }

    .timer-section {
        padding: 1.5rem;
    }

    .timer-display {
        font-size: 3.5rem;
        min-width: 200px;
        padding: 1.5rem;
    }

    .controls {
        gap: 0.75rem;
    }

    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-actions {
        width: 100%;
    }

    .history-actions .btn {
        flex: 1;
        min-width: 120px;
    }

    .session-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .session-item-status {
        width: 100%;
        text-align: center;
    }

    .session-item-time {
        width: 100%;
        text-align: left;
    }

    .past-session-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .past-session-time {
        width: 100%;
        text-align: left;
    }

    .session-speaker-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .session-speaker-time {
        width: 100%;
        text-align: left;
    }

    .limits-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header .subtitle {
        font-size: 0.9rem;
    }

    .timer-display {
        font-size: 2.5rem;
        min-width: 150px;
        padding: 1rem;
    }

    .controls {
        gap: 0.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .zone-indicator .zone {
        width: 25px;
        height: 25px;
    }

    .time-limits {
        width: 100%;
    }

    .limit-time {
        font-size: 1rem;
    }
}

/* Print Styles */
@media print {
    .controls,
    .footer {
        display: none;
    }

    .timer-section {
        page-break-inside: avoid;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ecf0f1;
        --dark-text: #ecf0f1;
        --light-bg: #34495e;
        --border-color: #555;
    }

    html, body {
        background-color: #1a1a1a;
        color: var(--dark-text);
    }

    .container {
        background: #2c3e50;
    }

    .role-section select,
    .speaker-input-group input {
        background: #34495e;
        color: #ecf0f1;
        border-color: #555;
    }

    .timer-section {
        background: linear-gradient(to bottom, #34495e, #2c3e50);
    }

    .timer-display.white {
        background: #555;
        color: #bdc3c7;
    }

    .session-item {
        background: #34495e;
        border-left-color: #3498db;
    }

    .past-session {
        background: #34495e;
        border-left-color: #3498db;
    }

    .session-speaker-item {
        background: #2c3e50;
        border-color: #555;
    }

    .footer {
        background: #34495e;
        border-top-color: #555;
    }
}

/* Zone Display Mode */
/* Self-contained overlay so it works both in normal flow and inside the
   fullscreen element's top layer (where siblings of the fullscreen
   element are not rendered). */
.zone-display-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8vh;
}

.btn-zone-display {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid white;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.btn-zone-display:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.btn-zone-display:active {
    transform: scale(0.95);
}
