:root {
    --primary-red: #ff0000;
    --alert-yellow: #ffff00;
    --dark-bg: #0a0a0a;
    --panel-bg: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #333333;
    --glow-red: rgba(255, 0, 0, 0.8);
    --glow-yellow: rgba(255, 255, 0, 0.8);
}

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

body {
    font-family: 'Roboto Mono', monospace;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0a0a 50%, #0a0a1a 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    transition: all 0.3s ease;
    animation: rgbShift 10s ease-in-out infinite;
}

@keyframes rgbShift {
    0% { filter: hue-rotate(0deg); }
    25% { filter: hue-rotate(90deg); }
    50% { filter: hue-rotate(180deg); }
    75% { filter: hue-rotate(270deg); }
    100% { filter: hue-rotate(360deg); }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 0, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 20%, rgba(255, 255, 0, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Black and white theme overrides */
body.bw-theme {
    --primary-red: #ffffff;
    --alert-yellow: #ffffff;
    --dark-bg: #000000;
    --panel-bg: #111111;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #333333;
    --glow-red: rgba(255, 255, 255, 0.8);
    --glow-yellow: rgba(255, 255, 255, 0.8);
}

body.bw-theme .tv-screen {
    filter: grayscale(100%) contrast(150%);
}

body.bw-theme .emergency-header {
    background: #ffffff;
    color: #000000;
}

body.bw-theme .crawl-text {
    background: #ffffff;
    color: #000000;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #1a0000, var(--panel-bg));
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    box-shadow: 0 0 20px var(--glow-red);
}

.header h1 {
    font-family: 'Orbitron', monospace;
    font-weight: 900;
    font-size: 2rem;
    color: var(--primary-red);
    text-shadow: 0 0 10px var(--glow-red);
    letter-spacing: 0.2em;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    box-shadow: 0 0 10px currentColor;
    animation: pulse 2s infinite;
}

.status-light.active {
    background: var(--primary-red);
    box-shadow: 0 0 15px var(--glow-red);
}

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

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.control-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--alert-yellow);
    text-transform: uppercase;
    font-size: 0.9rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: 'Roboto Mono', monospace;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 10px var(--glow-red);
}

textarea.input-field {
    resize: vertical;
    min-height: 100px;
}

.btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 4px;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 0.5rem;
}

.btn-primary {
    background: var(--primary-red);
    color: white;
    box-shadow: 0 0 10px var(--glow-red);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--glow-red);
}

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

.btn-tertiary {
    background: var(--alert-yellow);
    color: #000;
    box-shadow: 0 0 10px var(--glow-yellow);
}

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

.display-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tv-screen {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tv-screen:hover {
    box-shadow: 0 0 50px var(--glow-red);
}

.tv-off-screen {
    position: absolute;
    inset: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #333;
    font-family: 'Orbitron', monospace;
    font-size: 4rem;
    font-weight: 900;
    transition: all 0.5s ease;
}

.tv-text {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    animation: tvGlow 2s ease-in-out infinite alternate;
}

@keyframes tvGlow {
    from { text-shadow: 0 0 20px rgba(255, 255, 255, 0.1); }
    to { text-shadow: 0 0 30px rgba(255, 255, 255, 0.3); }
}

.tv-power-indicator {
    font-size: 1rem;
    margin-top: 1rem;
    opacity: 0.5;
}

.tv-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, rgba(255, 0, 0, 0.1), rgba(255, 255, 0, 0.1));
    display: flex;
    flex-direction: column;
    padding: 2rem;
    opacity: 0;
    transition: all 0.5s ease;
}

.tv-overlay.active {
    opacity: 1;
}

.tv-glitch {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 0, 0, 0.03) 2px,
        rgba(255, 0, 0, 0.03) 4px
    );
    opacity: 0;
    pointer-events: none;
}

.tv-glitch.active {
    animation: glitch 0.3s ease-in-out;
}

@keyframes glitch {
    0%, 100% { transform: translateX(0); opacity: 0; }
    10% { transform: translateX(-2px); opacity: 1; }
    20% { transform: translateX(2px); opacity: 1; }
    30% { transform: translateX(-1px); opacity: 1; }
    40% { transform: translateX(1px); opacity: 1; }
    50% { transform: translateX(0); opacity: 0; }
}

.emergency-header {
    background: var(--primary-red);
    color: white;
    padding: 1rem;
    text-align: center;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    box-shadow: 0 0 20px var(--glow-red);
}

.alert-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.alert-type, .alert-event, .alert-location {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--alert-yellow);
    text-shadow: 0 0 10px var(--glow-yellow);
}

.alert-message {
    flex: 1;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.crawl-text {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--alert-yellow);
    color: #000;
    padding: 0.5rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    animation: crawl 20s linear infinite;
}

@keyframes crawl {
    from { transform: translateX(100%); }
    to { transform: translateX(-100%); }
}

.scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(255, 255, 255, 0.03) 1px,
        rgba(255, 255, 255, 0.03) 2px
    );
    pointer-events: none;
}

.audio-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.volume-percentage {
    font-family: 'Orbitron', monospace;
    color: var(--alert-yellow);
    min-width: 40px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100px;
    height: 4px;
    background: var(--border-color);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-red);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--glow-red);
}

.range-display {
    font-family: 'Orbitron', monospace;
    color: var(--alert-yellow);
    margin-left: 1rem;
    font-size: 0.9rem;
}

.frequency-display {
    font-family: 'Orbitron', monospace;
    color: var(--alert-yellow);
}

.alert-history {
    background: var(--panel-bg);
    margin: 0 2rem 2rem;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.alert-history h3 {
    color: var(--alert-yellow);
    margin-bottom: 1rem;
    font-family: 'Orbitron', monospace;
}

.history-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--dark-bg);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.history-item:hover {
    background: var(--border-color);
    transform: translateX(5px);
}

.history-clip-btn {
    margin-top: 0.25rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-family: 'Orbitron', monospace;
    text-transform: uppercase;
    border: none;
    border-radius: 3px;
    background: var(--primary-red);
    color: #fff;
    cursor: pointer;
}

.history-clip-btn:hover {
    opacity: 0.9;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
}