/* ===========================
   Global Styles
   =========================== */
   * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --danger-color: #f44336;
    --secondary-color: #2196F3;
    --dark-bg: #1a1a1a;
    --light-text: #ffffff;
    --panel-bg: rgba(30, 30, 30, 0.95);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: var(--light-text);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* ===========================
   Control Panel (Top Bar)
   =========================== */
#top-bar {
    background: var(--panel-bg);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.3s ease;
}

/* Hide top bar in greenscreen mode */
body.greenscreen #top-bar {
    transform: translateY(-100%);
    pointer-events: none;
}

.left-section, .center-section, .right-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.8rem;
}

.logo h1 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Select Dropdowns */
.select-modern {
    padding: 8px 15px;
    border-radius: 5px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--light-text);
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 220px;
    transition: all 0.3s ease;
}

.select-modern:hover {
    background: rgba(255, 255, 255, 0.15);
}

.select-modern option {
    background: #2a2a2a;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-start {
    background: var(--primary-color);
    color: white;
}

.btn-stop {
    background: var(--danger-color);
    color: white;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-icon-only {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.2rem;
}

.btn-icon-only:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

/* Connection Status */
#connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 5px;
    font-size: 0.85rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status.connected {
    background: rgba(76, 175, 80, 0.2);
}

.status.connected .status-dot {
    background: #4CAF50;
}

.status.disconnected {
    background: rgba(244, 67, 54, 0.2);
}

.status.disconnected .status-dot {
    background: #f44336;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===========================
   Floating Panels (Menu & Settings)
   =========================== */
.floating-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    background: var(--panel-bg);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    max-width: 450px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.floating-panel.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* Hide panels in greenscreen mode */
body.greenscreen .floating-panel {
    display: none;
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
}

.panel-header h2 {
    font-size: 1.2rem;
    margin: 0;
}

.btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s ease;
}

.btn-close:hover {
    color: var(--danger-color);
}

.panel-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

/* Menu Items */
.menu-content {
    padding: 10px;
}

.menu-item {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 5px;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    text-align: left;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.menu-icon {
    font-size: 1.3rem;
    width: 25px;
    text-align: center;
}

.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 0;
}

/* ===========================
   Settings Panel
   =========================== */
.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--secondary-color);
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-control.inline {
    justify-content: flex-start;
}

.setting-control input[type="range"] {
    flex: 1;
    min-width: 150px;
}

.value-display {
    font-size: 0.85rem;
    color: #aaa;
    min-width: 45px;
    text-align: right;
}

.setting-control input[type="color"] {
    width: 50px;
    height: 35px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.number-input {
    width: 60px;
    padding: 6px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    color: white;
    font-size: 0.9rem;
}

/* Color Presets */
.color-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-btn {
    width: 35px;
    height: 35px;
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-btn.active {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 8px;
}

.align-btn {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid transparent;
}

.align-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* Checkbox Labels */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.checkbox-label:hover {
    background: rgba(255, 255, 255, 0.05);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===========================
   Video Container (Webcam)
   =========================== */
#video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#video-container.hidden {
    display: none;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.webcam-controls {
    position: absolute;
    top: 70px;
    right: 20px;
    z-index: 10;
}

/* Hide webcam controls in greenscreen */
body.greenscreen .webcam-controls {
    display: none;
}

/* ===========================
   Display Area (Subtitles)
   =========================== */
#display-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    padding: 20px;
}

/* Green Screen Mode */
body.greenscreen #display-area {
    background: #00FF00 !important;
}

body.greenscreen {
    background: #00FF00 !important;
}

/* Subtitle Container */
#subtitle-container {
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    max-width: 90%;
}

body.greenscreen #subtitle-container {
    background: transparent !important;
    box-shadow: none;
}

/* Text Alignment */
#subtitle-container.align-left {
    text-align: left;
}

#subtitle-container.align-center {
    text-align: center;
}

#subtitle-container.align-right {
    text-align: right;
}

/* Subtitle Text */
.subtitle-text {
    margin: 8px 0;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.subtitle-text.original {
    font-size: 20px;
    color: #aaaaaa;
    font-style: italic;
    margin-bottom: 10px;
}

.subtitle-text.translation {
    font-size: 36px;
    color: #ffffff;
    font-weight: 600;
}

/* Position Variants */
#subtitle-container.position-top {
    position: absolute;
    top: 100px;
}

#subtitle-container.position-bottom {
    position: absolute;
    bottom: 80px;
}

#subtitle-container.position-center {
    /* Default centered */
}

/* ===========================
   Bottom Bar & Debug Console
   =========================== */
#bottom-bar {
    background: rgba(0, 0, 0, 0.9);
    padding: 8px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    transition: transform 0.3s ease;
}

body.greenscreen #bottom-bar {
    transform: translateY(100%);
}

.debug-toggle {
    display: flex;
    align-items: center;
}

#debug-console {
    background: rgba(0, 0, 0, 0.95);
    padding: 10px 20px;
    height: 150px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

#debug-console.hidden {
    height: 0;
    padding: 0;
    overflow: hidden;
}

body.greenscreen #debug-console {
    display: none;
}

#debug-messages {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.debug-message {
    padding: 4px 8px;
    border-left: 3px solid #666;
    font-size: 0.75rem;
}

.debug-message.info {
    border-left-color: #2196F3;
    color: #64B5F6;
}

.debug-message.success {
    border-left-color: #4CAF50;
    color: #81C784;
}

.debug-message.warning {
    border-left-color: #FF9800;
    color: #FFB74D;
}

.debug-message.error {
    border-left-color: #f44336;
    color: #E57373;
}

/* ===========================
   Green Screen Exit Button
   =========================== */
.exit-greenscreen-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: rgba(244, 67, 54, 0.95);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 3000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.exit-greenscreen-btn:hover {
    background: rgba(244, 67, 54, 1);
    transform: scale(1.05);
}

.exit-greenscreen-btn.hidden {
    display: none;
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0.5;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.subtitle-text.translation {
    animation: slideUp 0.4s ease;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    #top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }

    .left-section, .center-section, .right-section {
        width: 100%;
        justify-content: center;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    .floating-panel {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .subtitle-text.translation {
        font-size: 28px;
    }

    .subtitle-text.original {
        font-size: 18px;
    }
}

/* ===========================
   Utility Classes
   =========================== */
.hidden {
    display: none !important;
}