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

:root {
    /* Light Theme (Default) */
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: white;
    --text-color: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #e0e0e0;
    --panel-bg: #f9f9f9;
    --input-bg: #f5f5f5;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.3);
}

body.dark-theme {
    /* Dark Theme */
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: #0f1419;
    --text-color: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #2d3748;
    --panel-bg: #1a202c;
    --input-bg: #2d3748;
    --shadow: rgba(0, 0, 0, 0.4);
    --shadow-strong: rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--container-bg);
    border-radius: 20px;
    box-shadow: 0 20px 60px var(--shadow-strong);
    overflow: hidden;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.2em;
    box-shadow: 0 4px 15px var(--shadow);
    transition: all 0.3s ease;
    z-index: 1000;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-strong);
}

/* Header Styles */
header {
    background: linear-gradient(135deg, #4CAF50 0%, #2196F3 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 2em;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header h2 {
    font-size: 1.6em;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1em;
    opacity: 0.9;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 55fr 45fr;
    gap: 25px;
    padding: 20px;
    align-items: start;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 15px;
        gap: 20px;
    }
}

/* Camera Section */
.camera-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 700px;
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#webcam {
    width: 100%;
    height: auto;
    display: block;
    transform: scaleX(-1); /* Mirror the video */
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1); /* Mirror the canvas */
}

#cropOverlay {
    position: absolute;
    top: 12.5%;
    left: 12.5%;
    width: 75%;
    height: 75%;
    border: 3px dashed rgba(76, 175, 80, 0.75);
    border-radius: 18px;
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(76, 175, 80, 0.25);
    transform: scaleX(-1);
    display: none;
}

.video-container.active #cropOverlay {
    display: block;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

.status-message {
    text-align: center;
    padding: 12px;
    background: #e3f2fd;
    border-radius: 10px;
    font-size: 1em;
    color: #1976d2;
    font-weight: 500;
}

/* Results Panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--panel-bg);
    padding: 0px 15px 15px 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px var(--shadow);
}

.results-panel h2 {
    color: var(--text-color);
    font-size: 1.5em;
    border-bottom: 3px solid #4CAF50;
    padding-bottom: 8px;
    margin: 0 0 10px 0;
}

.no-detection {
    text-align: center;
    padding: 20px 15px;
    color: var(--text-muted);
    min-height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.no-detection .icon {
    font-size: 2em;
    display: block;
    margin-bottom: 8px;
}

.no-detection p {
    font-size: 0.95em;
}

/* Item Details */
.item-details {
    animation: fadeIn 0.5s ease;
}

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

/* Three Column Row Layout */
.three-column-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
    align-items: center;
    min-height: 70px;
}

.column-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 70px;
}

.item-icon {
    font-size: 3em;
    flex-shrink: 0;
}

.item-name {
    font-size: 1.1em;
    color: #333;
    font-weight: 600;
    line-height: 1.2;
}

.column-status {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 70px;
}

.column-bin {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 70px;
}

.recyclable-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 12px 8px;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: bold;
    width: 100%;
    height: 70px;
}

.recyclable-status.recyclable {
    background: #c8e6c9;
    color: #2e7d32;
}

.recyclable-status.not-recyclable {
    background: #ffcdd2;
    color: #c62828;
}

.status-icon {
    font-size: 1.3em;
}

.bin-color-box {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.recycle-icon {
    width: 32px;
    height: 32px;
    color: white;
    stroke-width: 2.5;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.bin-text {
    flex: 1;
}

.label {
    font-weight: bold;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-size: 0.65em;
    text-transform: uppercase;
}

.bin-name {
    font-size: 0.8em;
    color: var(--text-color);
    font-weight: 600;
    line-height: 1.2;
}

.fun-fact {
    padding: 10px 12px;
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border-radius: 8px;
    border-left: 4px solid #fbc02d;
    margin-bottom: 12px;
}

.fun-fact .label {
    font-size: 0.75em;
    color: #856404;
    margin-bottom: 5px;
}

.fun-fact p {
    font-size: 0.85em;
    color: #333; /* Keep dark for readability on yellow */
    line-height: 1.4;
    margin: 0;
}

/* Confidence Meter */
.confidence {
    padding: 10px 12px;
    background: var(--input-bg);
    border-radius: 8px;
    margin-bottom: 12px;
}

.confidence .label {
    font-size: 0.75em;
    color: #666;
    margin-bottom: 6px;
}

.confidence-bar {
    width: 100%;
    height: 28px;
    background: #e0e0e0;
    border-radius: 14px;
    overflow: hidden;
    margin: 6px 0;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
    border-radius: 14px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: white;
    font-weight: bold;
    font-size: 0.85em;
}

#confidenceText {
    display: inline-block;
    font-size: 0.95em;
    font-weight: bold;
    color: #4CAF50;
}

/* Approval Buttons */
.approval-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    justify-content: center;
}

.btn-confirm {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 12px 16px;
    font-size: 0.95em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(76, 175, 80, 0.3);
    flex: 1;
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.5);
}

.btn-reject {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    padding: 12px 16px;
    font-size: 0.95em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(255, 152, 0, 0.3);
    flex: 1;
}

.btn-reject:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.5);
}

.status-warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

/* Model Loading Progress */
.model-progress {
    background: linear-gradient(135deg, #e8eaf6 0%, #c5cae9 100%);
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.progress-label {
    font-size: 1em;
    font-weight: bold;
    color: #3f51b5;
    margin-bottom: 10px;
    text-align: center;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3f51b5 0%, #5c6bc0 100%);
    border-radius: 15px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.95em;
    min-width: 0%;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    color: #3f51b5;
    font-weight: 600;
    font-size: 0.9em;
}

.progress-text span {
    padding: 0 8px;
}

/* Statistics */
.statistics {
    padding: 12px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-radius: 10px;
}

.statistics h3 {
    color: #1976d2;
    margin-bottom: 10px;
    font-size: 1.1em;
    text-align: center;
    font-weight: bold;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #1976d2;
    margin-bottom: 3px;
}

.stat-label {
    font-size: 0.8em;
    color: #666;
    font-weight: 500;
}

/* Footer */
footer {
    background: var(--input-bg);
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    border-top: 2px solid var(--border-color);
}

footer p {
    margin: 5px 0;
}

.tech-info {
    font-size: 0.9em;
    color: var(--text-muted);
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}