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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.logo-section {
    text-align: left;
}

.logo {
    font-size: 2.5em;
    font-weight: bold;
}

.logo span {
    color: #ff0000;
}

.subtitle {
    font-size: 1.1em;
    color: #cbd5e0;
}

.language-selector {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.language-selector select {
    background: transparent;
    border: none;
    color: white;
    font-size: 1em;
    cursor: pointer;
    outline: none;
}

.language-selector select option {
    background: #1a237e;
    color: white;
}

.mission {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4CAF50;
    border-radius: 15px;
    padding: 1px;
    margin: 1px 0;
    font-style: italic;
    text-align: center;
}

.video-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.video-container.single-view {
    border: 3px solid #4CAF50 !important;
    background: rgba(76, 175, 80, 0.1) !important;
    border-radius: 15px !important;
    padding: 10px !important;
    transition: all 0.3s ease !important;
}
.video-container.single-view .video-wrapper:first-child {
    display: none;
}

.video-wrapper {
    transition: all 0.3s ease-in-out;
}

video, canvas {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border: 3px solid #333;
    border-radius: 15px;
    background: #000;
    transform: scaleX(-1); /* Mirror consistent */
}

.info-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

button:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

.button-start {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.button-stop {
    background: linear-gradient(135deg, #f44336, #da190b);
}

.button-test {
    background: linear-gradient(135deg, #FF9800, #F57C00);
}

.button-record {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
}

.button-exit {
    background: linear-gradient(135deg, #607D8B, #455A64);
}

.button-voice {
    background: linear-gradient(135deg, #00bcd4, #0097a7);
}

.button-voice.listening {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    animation: pulse 1.5s infinite;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.coordinates {
    font-family: 'Courier New', monospace;
    font-size: 1.3em;
    color: #4CAF50;
    font-weight: bold;
}

.status {
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    font-weight: bold;
    font-size: 1.1em;
    text-align: center;
}

.status.connected {
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid #4CAF50;
}

.status.disconnected {
    background: rgba(244, 67, 54, 0.3);
    border: 1px solid #f44336;
}

.status.pending {
    background: rgba(255, 152, 0, 0.3);
    border: 1px solid #ff9800;
}

.instructions {
    background: rgba(255, 255, 255, 0.05);
    border-left: 4px solid #2196F3;
    padding: 20px;
    margin: 15px 0;
    border-radius: 8px;
    text-align: left;
}

.footer {
    margin-top: 40px;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e0;
    text-align: center;
}

.hidden {
    display: none;
}

.detection-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.color-detection-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
}

.color-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.color-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-checkbox:hover {
    background: rgba(255, 255, 255, 0.15);
}

.color-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.color-red .color-indicator {
    background-color: #ff0000;
}

.color-blue .color-indicator {
    background-color: #0000ff;
}

.color-green .color-indicator {
    background-color: #00ff00;
}

.color-yellow .color-indicator {
    background-color: #ffff00;
}

.detected-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.detected-color {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.9em;
}

.color-coordinates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.color-coord-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}
.blue-dot {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    box-shadow: 
        0 0 20px var(--secondary-color),
        0 0 40px var(--secondary-color),
        0 0 60px rgba(52, 152, 219, 0.5);
    pointer-events: none;
    z-index: 10;
    display: none;
    transition: all 0.05s ease;
    border: 2px solid white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.tracking-area {
    position: relative;
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, var(--dark-color), var(--primary-color));
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
}
.color-coord-card.red {
    border-left: 4px solid #ff0000;
}

.color-coord-card.blue {
    border-left: 4px solid #0000ff;
}

.color-coord-card.green {
    border-left: 4px solid #00ff00;
}

.color-coord-card.yellow {
    border-left: 4px solid #ffff00;
}

.color-coord-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: bold;
}

.color-coord-value {
    font-family: 'Courier New', monospace;
    font-size: 1.2em;
    font-weight: bold;
}

.color-coord-value.red {
    color: #ff6666;
}

.color-coord-value.blue {
    color: #6666ff;
}

.color-coord-value.green {
    color: #66ff66;
}

.color-coord-value.yellow {
    color: #ffff66;
}

.voice-control-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    border: 1px solid rgba(0, 188, 212, 0.3);
}

.voice-command-display {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #00bcd4;
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
}

.voice-command-display.active {
    background: rgba(0, 188, 212, 0.2);
    border-color: #ff9800;
}

.voice-commands-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.voice-command-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9em;
}

.api-status {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 0.9em;
    margin-left: 15px;
    background: linear-gradient(135deg, #00bcd4, #0097a7);
    color: white;
    font-weight: bold;
    border: 2px solid #00e5ff;
    box-shadow: 0 4px 20px rgba(0, 188, 212, 0.4);
    animation: pulse-glow 2s infinite;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.api-status.offline {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    border: 2px solid #ffb74d;
    box-shadow: 0 4px 20px rgba(255, 152, 0, 0.4);
    animation: pulse-glow-orange 2s infinite;
}
/* ============================================= */
/* ESTILS DEL COMPTADOR DE CRÈDITS */
/* ============================================= */
.credit-display {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 15px;
    margin-left: 15px;
    min-width: 200px;
    animation: fadeInDown 0.5s ease;
}

.credit-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
}

.credit-icon {
    font-size: 1.2em;
}

.credit-text {
    font-weight: bold;
    color: #4CAF50;
}

.credit-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.credit-progress {
    height: 100%;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.credit-requests {
    font-size: 0.8em;
    color: #cbd5e0;
}

.credit-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #00bcd4;
    border-radius: 10px;
    padding: 20px;
    z-index: 1002;
    animation: slideInRight 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.credit-notification-content h3 {
    margin-bottom: 10px;
    color: #00bcd4;
    text-align: center;
}

.credit-notification-content p {
    margin: 8px 0;
    color: #cbd5e0;
}

.credit-notification-content button {
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #00bcd4;
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
}

.credit-notification-content button:hover {
    background: #0097a7;
}

.credit-low {
    animation: pulse-warning 2s infinite;
}

.credit-very-low {
    animation: pulse-danger 1s infinite;
}
/* Millores per el mode detecció única */
.video-container.single-view .video-wrapper:first-child {
    display: none !important;
}

.video-container.single-view .video-wrapper:last-child {
    grid-column: 1 / -1;
    text-align: center;
}
.video-container.single-view::before {
    content: "🔍 MODO DETECCIÓN ACTIVO" !important;
    display: block !important;
    text-align: center !important;
    color: #4CAF50 !important;
    font-weight: bold !important;
    margin-bottom: 10px !important;
    font-size: 1.1em !important;
}
/* Assegurar que el canvas es vegi bé */
.video-container.single-view canvas {
    width: 100% !important;
    height: 500px !important; /* Altura fixa per a millor visualització */
    object-fit: contain;
    border: 3px solid #4CAF50; /* Bord verd per indicar mode detecció */
}

/* Indicador visual del mode */
.detection-only-indicator {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    z-index: 10;
}

/* Estat dels botons per indicar mode actiu */
.button-active {
    background: linear-gradient(135deg, #4CAF50, #45a049) !important;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}
@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes pulse-danger {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
}

/* Responsiu */
@media (max-width: 768px) {
    .credit-display {
        margin-left: 0;
        margin-top: 10px;
        min-width: auto;
    }
    
    .credit-info {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .credit-bar {
        width: 100%;
    }
}


@keyframes pulse-glow {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(0, 188, 212, 0.4);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(0, 188, 212, 0.7);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(0, 188, 212, 0.4);
    }
}

@keyframes pulse-glow-orange {
    0% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(255, 152, 0, 0.4);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(255, 152, 0, 0.7);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(255, 152, 0, 0.4);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}