:root {
    --primary-color: #1976d2;
    --primary-dark: #1565c0;
    --secondary-color: #ff9800;
    --success-color: #4caf50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    --bg-color: #ffffff;
    --surface-color: #f5f5f5;
    --text-color: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #333333;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Skip Links for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    z-index: 100;
    font-weight: 500;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid white;
    outline-offset: -2px;
}

/* Focus Indicators for Accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0d47a1;
        --text-color: #000000;
        --text-secondary: #424242;
    }

    [data-theme="dark"] {
        --primary-color: #64b5f6;
        --text-color: #ffffff;
        --text-secondary: #e0e0e0;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 10px;
}

.header-left {
    /* Empty for centering */
}

.header-center {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 600;
}

.clock-icon {
    font-size: 28px;
}

.current-time {
    color: var(--primary-color);
    font-variant-numeric: tabular-nums;
}

.header-right {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.icon-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.icon-button:hover {
    background-color: var(--surface-color);
}

/* Title Section */
.title-section {
    text-align: center;
    margin-bottom: 30px;
}

.title-section h1 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Live Calculation Box - Main Feature */
.live-calculation-box {
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--bg-color) 100%);
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-hover);
}

.live-calculation-box h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.main-time-display {
    text-align: center;
    padding: 20px;
    background-color: var(--bg-color);
    border-radius: 12px;
    margin-bottom: 20px;
}

.time-label {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.main-time {
    font-size: 72px;
    font-weight: bold;
    color: var(--success-color);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin: 20px 0;
}

.main-time.overtime {
    color: var(--warning-color);
}

.main-time.critical {
    color: var(--error-color);
}

.status-text {
    font-size: 20px;
    color: var(--text-color);
    margin-top: 10px;
}

.status-text.pause-active {
    color: var(--warning-color);
    font-weight: 600;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.pause-info {
    margin-top: 10px;
    font-size: 16px;
    color: var(--text-secondary);
}

/* Pause Controls */
.pause-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.pause-button {
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 500;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: var(--primary-color);
    color: white;
}

.pause-button:hover:not(:disabled) {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

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

.pause-button.pause-active {
    background-color: var(--warning-color);
}

.pause-reset-button {
    padding: 16px;
    font-size: 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background-color: var(--surface-color);
    transition: all 0.3s ease;
}

.pause-reset-button:hover {
    background-color: var(--border-color);
}

/* Compact Details Grid */
.compact-details {
    background-color: var(--bg-color);
    padding: 16px;
    border-radius: 12px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-cell {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background-color: var(--surface-color);
    border-radius: 8px;
}

.detail-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.detail-value.success {
    color: var(--success-color);
}

/* Overtime Warning */
.overtime-warning {
    background-color: rgba(255, 152, 0, 0.1);
    border: 2px solid var(--warning-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.overtime-warning.critical {
    background-color: rgba(244, 67, 54, 0.1);
    border-color: var(--error-color);
}

.warning-icon {
    font-size: 24px;
}

.warning-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--warning-color);
}

.overtime-warning.critical .warning-text {
    color: var(--error-color);
}

/* Input Section */
.input-section {
    background-color: var(--surface-color);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.input-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
    background-color: var(--bg-color);
    border-radius: 12px;
    padding: 4px;
}

.mode-button {
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.mode-button.active {
    background-color: var(--primary-color);
    color: white;
}

.input-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 14px;
}

.time-input-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.time-input-container input[type="time"] {
    flex: 1;
}

.current-time-button {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 80px;
}

.current-time-button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.current-time-button:active {
    transform: translateY(0);
}

input[type="time"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.3s ease;
}

input[type="time"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-hint {
    position: absolute;
    right: 12px;
    bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Legal Notice */
.legal-notice {
    background-color: rgba(255, 193, 7, 0.1);
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.legal-notice h3 {
    font-size: 18px;
    color: #f57c00;
    margin-bottom: 12px;
}

.legal-notice ul {
    list-style: none;
    padding: 0;
}

.legal-notice li {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Audio Status */
.audio-status {
    background-color: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--success-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-icon {
    font-size: 24px;
}

.audio-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--success-color);
}

.audio-details {
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Settings Link */
.settings-link {
    text-align: center;
    margin-top: 30px;
}

.settings-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--surface-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.settings-button:hover {
    background-color: var(--border-color);
    box-shadow: var(--shadow);
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    .title-section h1 {
        font-size: 28px;
    }
    
    .main-time {
        font-size: 56px;
    }
    
    .live-calculation-box {
        padding: 20px;
    }
    
    .mode-toggle {
        grid-template-columns: 1fr;
    }
    
    .header-center {
        font-size: 20px;
    }
    
    .clock-icon {
        font-size: 24px;
    }
}

/* ===============================================
   VALIDATION STYLES
   =============================================== */

/* Input validation error state */
input.validation-error,
select.validation-error,
textarea.validation-error {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.1);
}

input.validation-error:focus,
select.validation-error:focus,
textarea.validation-error:focus {
    outline: none;
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.2);
}

/* Validation error message */
.validation-error-message {
    color: var(--error-color);
    font-size: 13px;
    margin-top: 4px;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.validation-error-message::before {
    content: '⚠ ';
    font-weight: bold;
}

/* Success state (optional) */
input.validation-success,
select.validation-success {
    border-color: var(--success-color) !important;
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

input.validation-error.shake,
select.validation-error.shake {
    animation: shake 0.5s;
}

/* Slide down animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form validation summary */
.validation-summary {
    background-color: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--error-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: none;
}

.validation-summary.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.validation-summary-title {
    color: var(--error-color);
    font-weight: 600;
    margin-bottom: 8px;
}

.validation-summary-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.validation-summary-list li {
    color: var(--error-color);
    padding: 4px 0;
    font-size: 14px;
}

.validation-summary-list li::before {
    content: '• ';
    font-weight: bold;
}

/* Dark mode adjustments */
[data-theme="dark"] .validation-error-message {
    color: #ff5252;
}

[data-theme="dark"] .validation-summary {
    background-color: rgba(255, 82, 82, 0.1);
    border-color: #ff5252;
}

[data-theme="dark"] input.validation-error,
[data-theme="dark"] select.validation-error {
    box-shadow: 0 0 0 2px rgba(255, 82, 82, 0.2);
}

/* ================================
   Custom Work Hours Modal
   ================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: fadeIn 0.2s ease-out;
}

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

.modal-container {
    background-color: var(--bg-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 100%;
    animation: slideUp 0.3s ease-out;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.modal-close-button {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.modal-close-button:hover {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
}

.modal-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.custom-time-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.custom-time-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-time-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.custom-time-group input {
    width: 100%;
    padding: 12px;
    font-size: 24px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-time-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    outline: none;
}

.custom-time-separator {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-secondary);
    padding-top: 24px;
}

.modal-hint {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background-color: var(--surface-color);
    border-radius: 6px;
    border-left: 3px solid var(--warning-color);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.modal-button:active {
    transform: scale(0.98);
}

.modal-button-secondary {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.modal-button-secondary:hover {
    background-color: var(--border-color);
}

.modal-button-primary {
    background-color: var(--primary-color);
    color: white;
}

.modal-button-primary:hover {
    background-color: var(--primary-dark);
}

/* Dark mode modal adjustments */
[data-theme="dark"] .modal-overlay {
    background-color: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .modal-container {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Responsive modal */
@media (max-width: 480px) {
    .modal-container {
        max-width: 100%;
        margin: 0;
        border-radius: 12px 12px 0 0;
        align-self: flex-end;
    }

    .custom-time-group input {
        font-size: 20px;
        padding: 10px;
    }

    .custom-time-separator {
        font-size: 28px;
    }
}