/* frontend/css/style.css */

/* --- THEME & FONT DEFINITIONS --- */
:root {
    --blue-dark: #001f3f;
    --blue-primary: #0074D9;
    --red-primary: #FF4136;
    --white-primary: #FFFFFF;
    --white-off: #F0F0F0;
    --grey-dark: #111111;
    --text-primary: var(--white-off);
    --text-secondary: #AAAAAA;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --player-height: 80px;
}

.hidden {
  display: none;
}

#project-detail-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#project-detail-modal .modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  width: 60%;
  max-height: 80%;
  overflow-y: auto;
}


/* --- GLOBAL RESETS & BODY LAYOUT --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    background-color: var(--blue-dark);
}

body {
    font-family: var(--font-main);
    color: var(--text-primary);
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 1;
}

#dynamic-background {
    position: fixed;
    top: -5%; left: -5%;
    width: 110%; height: 110%;
    background-size: cover;
    background-position: center;
    filter: blur(40px) brightness(0.4);
    z-index: 0;
    transition: background-image 0.8s ease-in-out;
}

/* --- HEADER --- */
#main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    flex-shrink: 0;
}

h1 {
    font-size: 1.2rem;
}

#open-station-modal-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#open-station-modal-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- MAIN CONTENT (TRANSCRIPT) --- */
#main-content {
    flex-grow: 1;
    padding: 0 1rem 1rem 1rem;
    min-height: 0; /* Flexbox overflow fix */
    display: flex;
}

#transcript-container {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: 1.8em;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scroll-behavior: smooth;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#transcript-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.utterance {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.3s ease-in;
    border-left: 4px solid var(--blue-primary);
}
.utterance.final {
    border-left-color: var(--red-primary);
}
.utterance.summarized {
    /* IMPROVED: Use a subtle yellow left border instead of a heavy background */
    background: rgba(255, 220, 115, 0.1); /* A very faint, translucent yellow glow */
    transition: background-color 0.5s ease-in-out;
    border-left-color: #FFDC73; /* Bright yellow border for clear marking */
}
.highlight {
    color: var(--white-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    font-weight: bold;
}

/* --- FOOTER (PLAYER BAR) --- */
#player-bar {
    height: var(--player-height);
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.player-station-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.station-logo {
    height: 50px;
    width: 50px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--grey-dark);
}

#player-station-name {
    font-size: 1.1rem;
    font-weight: bold;
}
.sub-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
}

/* Performance Mode Indicator */
#performance-mode-indicator {
    font-weight: bold;
    font-family: monospace;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: help;
    transition: all 0.3s ease;
}

#performance-mode-indicator:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.4);
}

#player-controls {
    display: flex;
    align-items: center;
}

#player-controls button {
    font-size: 1.5rem;
    background: none;
    border: none;
    color: var(--white-primary);
    cursor: pointer;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    transition: background-color 0.2s, transform 0.1s;
}
#player-controls button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
#player-controls button:active {
    transform: scale(0.9);
}
#player-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- STATION SELECTION MODAL --- */
#station-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#station-modal.visible {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    border-radius: 12px;
    max-width: 900px;
    max-height: 80vh;
    width: 90%;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    border: 1px solid #333;
}

.modal-content h2 {
    color: #fff;
    margin: 0 0 1.5rem 0;
    text-align: center;
    font-size: 1.8rem;
}

/* Station Browser Tabs */
.station-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #333;
    padding-bottom: 1rem;
}

.tab-btn {
    background: transparent;
    border: 1px solid #444;
    color: #ccc;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.tab-btn:hover {
    background: #333;
    border-color: #555;
}

.tab-btn.active {
    background: #4a90e2;
    border-color: #4a90e2;
    color: #fff;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Search and Filters */
.search-filters {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.search-row, .filter-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.search-row:last-child, .filter-row:last-child {
    margin-bottom: 0;
}

#station-search {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: #222;
    color: #fff;
    font-size: 1rem;
}

#station-search:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

#search-btn {
    padding: 0.75rem 1.5rem;
    background: #4a90e2;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

#search-btn:hover {
    background: #357abd;
}

.filter-row select {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #444;
    border-radius: 6px;
    background: #222;
    color: #fff;
    font-size: 0.9rem;
}

.filter-row select:focus {
    outline: none;
    border-color: #4a90e2;
}

/* Search Results */
.search-results {
    max-height: 400px;
    overflow-y: auto;
}

#loading-indicator {
    text-align: center;
    padding: 2rem;
    color: #ccc;
    font-size: 1.1rem;
}

.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.station-item {
    background: linear-gradient(135deg, #2a2a2a, #3d3d3d);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.station-item:hover {
    background: linear-gradient(135deg, #3a3a3a, #4d4d4d);
    border-color: #4a90e2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.station-item .station-logo {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: #444;
    flex-shrink: 0;
}

.station-item .station-info {
    flex: 1;
    min-width: 0;
}

.station-item .station-name {
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-item .station-details {
    color: #aaa;
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.station-item .station-tag {
    background: #4a90e2;
    color: #fff;
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
}

.station-item .language-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #28a745;
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.station-item .unsupported-language {
    background: #dc3545;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #444;
    color: #fff;
}

/* --- SUMMARY PANEL --- */
#summary-panel {
    flex-shrink: 0;
    padding: 1rem;
    padding-top: 0;
}

.summary-content {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.summary-content h3 {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.summary-time-ago {
    float: right;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
    padding-top: 4px;
}

.close-btn {
    position: absolute;
    top: 1rem; right: 1rem;
    font-size: 2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}
.modal-content h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}
.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
    overflow-y: auto;
}
.station-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.station-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.station-item .station-logo {
    height: 80px;
    width: 80px;
}
.station-item span {
    font-size: 0.9rem;
    text-align: center;
}

/* --- UTILITY & DEBUG STYLES (REDESIGNED) --- */

#debug-toggle {
    /* Style for the new icon button in the player bar */
    order: -1; /* Places it at the beginning of the station info flex container */
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-secondary);
    background-color: transparent;
    border: 1px solid var(--text-secondary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
    flex-shrink: 0;
}

#debug-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white-primary);
}

#debug-panel {
    /* The new slide-up panel */
    position: fixed;
    bottom: var(--player-height);
    left: 0;
    width: 100%;
    max-height: 40vh;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    
    /* Animation for sliding in and out */
    transform: translateY(100%);
    transition: transform 0.4s ease-in-out;
    visibility: hidden;
}

#debug-panel.visible {
    transform: translateY(0);
    visibility: visible;
}

/* Reset old positioning and integrate into the new panel */
.sync-control-container, #debug-box {
    position: static;
    background-color: transparent;
    width: 100%;
    padding: 0;
}

.sync-control-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

#debug-box {
    flex-grow: 1; /* Allows the message list to take available space */
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#debug-box h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

#debug-box ul {
    overflow-y: auto; /* Make the message list scrollable */
    list-style: none;
    font-size: 0.9rem;
    flex-grow: 1;
}

audio { display: none; }

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

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 600px) {
    h1 { font-size: 1rem; }
    #transcript-container { font-size: 1.2rem; padding: 1rem; }
    .station-logo { height: 40px; width: 40px; }
    #player-station-name { font-size: 0.9rem; }
    .sub-info { font-size: 0.7rem; }
    #player-controls button { font-size: 1.2rem; width: 40px; height: 40px; }
    .station-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

/* --- VOLUME CONTROLS --- */
#volume-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem; /* Add some space from the play/stop buttons */
}

#muteBtn {
    font-size: 1.2rem; /* Slightly smaller than play/stop for a better look */
}

#volumeSlider {
    -webkit-appearance: none; /* Override default CSS */
    appearance: none;
    width: 100px; /* Or whatever width you prefer */
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}

#volumeSlider:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* --- SLIDER THUMB STYLING (for Chrome/Safari/Edge) --- */
#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--white-off);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

#volumeSlider::-webkit-slider-thumb:hover {
    background: var(--white-primary);
}

/* --- SLIDER THUMB STYLING (for Firefox) --- */
#volumeSlider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--white-off);
    border-radius: 50%;
    cursor: pointer;
    border: none; /* Firefox adds a border by default */
    transition: background 0.2s;
}

#volumeSlider::-moz-range-thumb:hover {
    background: var(--white-primary);
}

/* Language fallback notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.language-fallback-notification {
    background: rgba(255, 165, 0, 0.95);
    border: 1px solid #ff8c00;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideInRight 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: #000;
}

.notification-icon {
    font-size: 18px;
    margin-right: 10px;
}

.notification-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.notification-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}