/* Display Fixer - Styles */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b0;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --border: #2a2a3a;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    display: grid;
    gap: 2rem;
}

section {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Mode Grid */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    color: var(--text-primary);
    font-family: inherit;
}

.mode-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow);
}

.mode-card.active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

.mode-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.9;
}

.mode-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.mode-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Controls Panel */
.controls-panel {
    display: none;
}

.controls-panel.visible {
    display: block;
}

.control-group {
    margin-bottom: 1.25rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.control-group select,
.control-group input[type="range"] {
    width: 100%;
}

select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

input[type="range"]::-moz-range-track {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 0.5rem;
}

.btn-secondary:hover {
    border-color: var(--accent);
}

.btn-stop {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-stop:hover {
    opacity: 0.9;
}

.action-buttons {
    margin-top: 1.5rem;
}

/* Info Panel */
.info-panel p {
    margin-bottom: 0.5rem;
}

.info-panel span {
    color: var(--text-secondary);
}

/* Footer */
.footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer kbd {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    font-family: monospace;
}

.warning {
    color: var(--warning);
    margin-top: 1rem;
    font-size: 0.85rem;
}

/* Canvas */
#repair-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1000;
}

#repair-canvas.active {
    display: block;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1001;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 2rem;
    pointer-events: none;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    text-align: center;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.timer {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: monospace;
    margin-bottom: 0.5rem;
}

.mode-indicator {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.exit-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Region Selection Overlay */
.region-selection {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    cursor: crosshair;
    background: rgba(0, 0, 0, 0.5);
}

.region-box {
    position: absolute;
    border: 2px dashed var(--accent);
    background: rgba(99, 102, 241, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    #app {
        padding: 1rem;
    }

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

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

    .mode-card {
        padding: 1rem;
    }
}

/* Animation for mode cards */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.mode-card.active .mode-icon {
    animation: pulse 2s infinite;
}

/* HDR indicator */
.hdr-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

/* Status indicators */
.status-active {
    color: var(--success);
}

.status-inactive {
    color: var(--text-secondary);
}

/* Custom Pattern Controls */
#custom-controls {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
}

#custom-controls > label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--accent);
}

.custom-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.custom-row label {
    min-width: 120px;
    font-size: 0.9rem;
}

.custom-row select,
.custom-row input[type="color"] {
    flex: 1;
}

.custom-row input[type="range"] {
    flex: 1;
    min-width: 100px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
}

.custom-row input[type="range"]::-moz-range-track {
    background: var(--border);
}

#cell-size-row,
#mixed-cell-size-row {
    flex-wrap: wrap;
}

#cell-size-row input[type="range"],
#mixed-cell-size-row input[type="range"] {
    order: 2;
    flex-basis: 100%;
    margin-top: 0.5rem;
}

#cell-size-row span,
#mixed-cell-size-row span {
    order: 3;
    flex-basis: 100%;
    text-align: center;
    margin-top: 0.25rem;
}

.custom-row span {
    min-width: 50px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

input[type="color"] {
    -webkit-appearance: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    height: 40px;
    cursor: pointer;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 4px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Sub-mode select styling */
#submode-group {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

/* Gray level slider for backlight mode */
#gray-level-group {
    display: none;
}

#gray-level-group.visible {
    display: block;
}

/* Mixed Mode Controls */
#mixed-controls {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.5rem;
}

#mixed-controls > label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--accent);
}

.mixed-sequence-info {
    background: rgba(99, 102, 241, 0.1);
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.mixed-sequence-info .hint {
    margin-bottom: 0.5rem;
}

.current-step {
    font-weight: 500;
    color: var(--text-primary);
}

.current-step span {
    color: var(--accent);
}

.custom-pattern-config {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1rem;
}

.custom-pattern-config > label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Fullscreen mode */
:fullscreen {
    overflow: hidden;
}

:fullscreen::-webkit-scrollbar {
    display: none;
}

:-webkit-full-screen {
    overflow: hidden;
}

:-moz-full-screen {
    overflow: hidden;
}
