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

:root {
    /* Healthcare Color Scheme */
    --primary-color: #0288D1;        /* Medical Blue - Trust, Professionalism */
    --secondary-color: #00897B;      /* Medical Teal - Health, Calm */
    --accent-color: #26A69A;         /* Soft Teal - Healthcare */
    --success-color: #4CAF50;        /* Medical Green - Health, Positive */
    --warning-color: #FFA726;        /* Soft Orange - Caution */
    --error-color: #EF5350;          /* Medical Red - Alerts */
    --background-color: #F5F7FA;     /* Clean Light Gray - Clinical */
    --card-background: #FFFFFF;      /* Pure White - Sterile, Clean */
    --text-color: #37474F;           /* Dark Blue-Gray - Professional */
    --border-color: #CFD8DC;         /* Light Blue-Gray - Subtle */
    --shadow: 0 2px 8px rgba(0, 136, 209, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 136, 209, 0.12);
    --gradient-start: #E3F2FD;       /* Light Medical Blue */
    --gradient-end: #B2EBF2;         /* Light Teal */
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 30px;
    text-align: center;
    border-bottom: 4px solid var(--accent-color);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main Content */
.main-content {
    display: flex;
    gap: 30px;
    padding: 30px;
    min-height: 600px;
}

/* Left Panel */
.left-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.image-container {
    background: var(--card-background);
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    max-height: 700px;
    position: relative;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

.placeholder {
    text-align: center;
    color: #7f8c8d;
}

.placeholder-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.placeholder p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.placeholder-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

.preview-image {
    max-width: 100%;
    max-height: 700px;
    object-fit: contain;
    display: block;
}

.camera-video {
    max-width: 100%;
    max-height: 700px;
    object-fit: contain;
    display: block;
    /* Flip horizontally to make front camera look natural */
    transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
}

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

/* Right Panel */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.controls-section,
.results-section {
    background: var(--card-background);
    padding: 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.controls-section h2,
.results-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 10px;
    font-weight: 600;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 15px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2980b9;
}

.btn-accent {
    background: var(--success-color);
    color: white;
}

.btn-accent:hover:not(:disabled) {
    background: #43A047;
}

.btn-success {
    background: var(--success-color);
    color: white;
    width: auto;
    padding: 12px 25px;
}

.btn-success:hover:not(:disabled) {
    background: #229954;
}

.btn-secondary {
    background: #78909C;
    color: white;
    width: auto;
    padding: 12px 25px;
}

.btn-secondary:hover:not(:disabled) {
    background: #607D8B;
}

.btn-icon {
    font-size: 1.2rem;
}

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    background: linear-gradient(135deg, #E3F2FD 0%, #E0F7FA 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 2px solid var(--accent-color);
}

.score-label {
    font-size: 1rem;
    color: #7f8c8d;
    font-weight: 600;
}

.score-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.score-max {
    font-size: 1.5rem;
    color: #7f8c8d;
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 30px;
    background: #E0F2F1;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color) 0%, var(--warning-color) 50%, var(--error-color) 100%);
    transition: width 0.5s ease;
    border-radius: 15px;
}

/* Interpretation */
.interpretation {
    background: var(--card-background);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.interpretation strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

#interpretationText {
    color: #555;
    line-height: 1.8;
}

/* Action Units */
.au-values {
    background: var(--card-background);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.au-values h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-weight: 600;
}

.au-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.au-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: var(--background-color);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    border-left: 3px solid var(--accent-color);
    transition: all 0.2s ease;
}

.au-item:hover {
    background: #E0F2F1;
    transform: translateX(5px);
}

.au-name {
    font-weight: 600;
    color: var(--text-color);
}

.au-value {
    color: var(--secondary-color);
    font-weight: 500;
}

.au-placeholder {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 20px;
}

/* Custom Scrollbar */
.au-list::-webkit-scrollbar {
    width: 8px;
}

.au-list::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 10px;
}

.au-list::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

.au-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Alert */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.alert-error {
    background: #FFEBEE;
    border-left: 4px solid var(--error-color);
    color: #C62828;
}

.alert strong {
    display: block;
    margin-bottom: 5px;
}

/* Footer */
footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
}

.footer-note {
    opacity: 0.7;
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading-overlay p {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .left-panel,
    .right-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 20px;
        gap: 20px;
    }

    .controls-section,
    .results-section {
        padding: 20px;
    }

    .score-value {
        font-size: 2.5rem;
    }

    .btn {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .main-content {
        padding: 15px;
    }

    .controls-section,
    .results-section {
        padding: 15px;
    }

    .camera-controls {
        flex-direction: column;
    }

    .btn-success,
    .btn-secondary {
        width: 100%;
    }
}

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

.results-section > * {
    animation: fadeIn 0.5s ease;
}

