/**
 * NUE 112 Training System - Complete Stylesheet
 */

/* ===== Variables ===== */
:root {
    --primary: #4ECDC4;
    --primary-dark: #3dafa7;
    --danger: #FF6B6B;
    --danger-dark: #e85555;
    --success: #51CF66;
    --warning: #FFD93D;
    --info: #4A90E2;
    --dark: #2C3E50;
    --light: #ECF0F1;
    --gray: #95A5A6;
    --white: #FFFFFF;
    
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --border-radius: 12px;
    --box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* ===== Container & Layout ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    color: var(--white);
    margin-bottom: 40px;
    padding: 20px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

.version {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 5px;
}

.main {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

.main h2 {
    color: var(--dark);
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.footer {
    text-align: center;
    color: var(--white);
    padding: 20px;
    opacity: 0.8;
}

/* ===== User Cards (Home) ===== */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.user-card {
    background: var(--white);
    border: 2px solid var(--light);
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    text-decoration: none;
    color: var(--dark);
    transition: var(--transition);
    cursor: pointer;
}

.user-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-color: var(--primary);
}

.user-avatar {
    font-size: 4rem;
    margin-bottom: 15px;
}

.user-card h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.user-username {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.user-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--light);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark);
}

.stat-value.score {
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 3px;
}

.last-session {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 10px;
}

.no-users {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

/* ===== Scenario Cards ===== */
.user-quick-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 0.95rem;
}

.category-section {
    margin-bottom: 40px;
}

.category-section h3 {
    color: var(--dark);
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.scenario-card {
    background: var(--white);
    border: 2px solid var(--light);
    border-radius: var(--border-radius);
    padding: 25px;
    transition: var(--transition);
}

.scenario-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-color: var(--primary);
}

.scenario-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.scenario-card h4 {
    color: var(--dark);
    font-size: 1.2rem;
    flex: 1;
}

.difficulty {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.difficulty-easy {
    background: #d4edda;
    color: #155724;
}

.difficulty-medium {
    background: #fff3cd;
    color: #856404;
}

.difficulty-hard {
    background: #f8d7da;
    color: #721c24;
}

.scenario-description {
    color: var(--gray);
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.scenario-preview {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.scenario-preview strong {
    display: block;
    margin-bottom: 5px;
    color: var(--dark);
}

.initial-message {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* ===== Chat Interface ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--white);
}

.chat-header {
    background: linear-gradient(135deg, var(--primary) 0%, #3dafa7 100%);
    color: var(--white);
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    font-size: 0.9rem;
}

.status-indicator.active {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.timer {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
}

.chat-header h2 {
    margin: 10px 0;
    font-size: 1.6rem;
}

.scenario-desc {
    opacity: 0.9;
    font-size: 0.95rem;
    margin: 5px 0;
}

.operator-info {
    margin-top: 10px;
    font-size: 0.9rem;
}

.chat-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    overflow: hidden;
}

.messages-container {
    padding: 20px;
    overflow-y: auto;
    background: #f5f7fa;
}

.message {
    margin-bottom: 15px;
    display: flex;
    animation: slideIn 0.3s ease;
}

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

.message-user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 18px;
    position: relative;
}

.message-user .message-content {
    background: linear-gradient(135deg, var(--primary) 0%, #3dafa7 100%);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message-assistant .message-content {
    background: var(--white);
    color: var(--dark);
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.message-system .message-content {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    max-width: 90%;
    text-align: center;
    margin: 0 auto;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.5;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 5px;
}

/* ===== Evaluation Sidebar ===== */
.evaluation-sidebar {
    background: #f9fafb;
    padding: 20px;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
}

.evaluation-sidebar h3 {
    color: var(--dark);
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.current-score {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 25px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.score-circle {
    margin-bottom: 15px;
}

.score-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    display: block;
}

.score-label {
    font-size: 0.9rem;
    color: var(--gray);
    margin-top: 5px;
}

.score-percentage {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--dark);
    margin: 10px 0;
}

.score-level {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-block;
}

.level-excellent {
    background: #d4edda;
    color: #155724;
}

.level-good {
    background: #d1ecf1;
    color: #0c5460;
}

.level-sufficient {
    background: #fff3cd;
    color: #856404;
}

.level-needs_improvement {
    background: #f8d7da;
    color: #721c24;
}

.criteria-checklist {
    margin-top: 20px;
}

.feedback-section {
    margin-bottom: 20px;
}

.feedback-section h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--dark);
}

.feedback-section ul {
    list-style: none;
    padding: 0;
}

.feedback-section li {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.feedback-section li.strength {
    background: #d4edda;
    color: #155724;
    border-left: 3px solid #28a745;
}

.feedback-section li.improvement {
    background: #fff3cd;
    color: #856404;
    border-left: 3px solid #ffc107;
}

.session-stats {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.session-stats .stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

/* ===== Chat Footer ===== */
.chat-footer {
    padding: 20px;
    background: var(--white);
    border-top: 1px solid #e0e0e0;
}

#messageForm {
    margin-bottom: 15px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

#messageInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(78,205,196,0.1);
}

.chat-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-text {
    font-size: 0.85rem;
    color: var(--gray);
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #3dafa7 100%);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78,205,196,0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #e85555 100%);
    color: var(--white);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255,107,107,0.4);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

.btn-secondary:hover {
    background: #d5dbdb;
}

.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Loading Overlay - FIX: Hidden by default */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none; /* ← FIXED: Changed from flex to none */
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Show overlay when active */
.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #4ECDC4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* ===== Utilities ===== */
.text-muted {
    color: var(--gray);
    font-size: 0.9rem;
    font-style: italic;
}

.text-center {
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .main {
        padding: 20px;
    }
    
    .users-grid,
    .scenarios-grid {
        grid-template-columns: 1fr;
    }
    
    .chat-main {
        grid-template-columns: 1fr;
    }
    
    .evaluation-sidebar {
        display: none;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .header {
        padding: 15px 10px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .main {
        padding: 15px;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .messages-container {
        padding: 15px;
    }
}
