/* CSS Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --dark-bg: #34495e;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #bdc3c7;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --transition: all 0.3s ease;
    
    /* Role Colors */
    --role-patient: #e74c3c;
    --role-family: #9b59b6;
    --role-medical: #3498db;
    --role-therapy: #1abc9c;
    --role-support: #f39c12;
    --role-management: #2c3e50;
    --role-care: #27ae60;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* Header */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.app-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--danger-color);
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background-color: var(--success-color);
}

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

/* Main Container */
.app-container {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Lobby Screen */
.lobby-container {
    max-width: 900px;
    margin: 0 auto;
}

.lobby-container h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.lobby-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.option-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.option-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.option-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.option-card p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

/* Forms */
.lobby-form,
.problems-form,
.goals-form,
.sbar-form,
.evaluation-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-dark);
}

input[type="text"],
input[type="number"],
textarea,
select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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

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

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

.btn-primary:hover {
    background-color: #2980b9;
}

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

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

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.25rem;
    transition: var(--transition);
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* Waiting Room */
.waiting-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.room-info {
    grid-column: 1 / -1;
    text-align: center;
}

.room-code-display {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 1.25rem;
}

.room-code-display strong {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    color: var(--secondary-color);
}

/* Waiting Timer */
.waiting-timer {
    margin-top: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-radius: var(--radius);
    text-align: center;
}

.timer-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.timer-display {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--secondary-color);
    font-variant-numeric: tabular-nums;
}

.waiting-timer.attention {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
}

.waiting-timer.attention .timer-display {
    color: var(--warning-color);
}

.waiting-timer.warning {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
    animation: pulse 1s ease-in-out infinite;
}

.waiting-timer.warning .timer-display {
    color: var(--danger-color);
}

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

/* Roles Grid */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    max-height: 600px;
    overflow-y: auto;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
}

.role-card {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.role-card:hover {
    border-color: var(--secondary-color);
    background-color: rgba(52, 152, 219, 0.05);
}

.role-card.selected {
    border-color: var(--secondary-color);
    background-color: rgba(52, 152, 219, 0.1);
}

.role-card.occupied {
    background-color: var(--light-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

.role-card.patient { border-left: 4px solid var(--role-patient); }
.role-card.family { border-left: 4px solid var(--role-family); }
.role-card.medical { border-left: 4px solid var(--role-medical); }
.role-card.therapy { border-left: 4px solid var(--role-therapy); }
.role-card.support { border-left: 4px solid var(--role-support); }
.role-card.management { border-left: 4px solid var(--role-management); }
.role-card.care { border-left: 4px solid var(--role-care); }

.role-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.role-status {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* AI-controlled roles */
.role-card.ai-controlled {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    border: 2px dashed #6c757d;
    opacity: 0.9;
}

.role-card.ai-controlled .role-status {
    color: #6c757d;
    font-weight: 600;
}

/* Participants Panel */
.participants-panel {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--light-bg);
    border-radius: var(--radius);
}

.participant-item .role-badge {
    padding: 0.25rem 0.75rem;
    background: var(--secondary-color);
    color: white;
    border-radius: 1rem;
    font-size: 0.875rem;
}

/* Host Controls */
.host-controls {
    grid-column: 1 / -1;
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--warning-color);
}

.host-controls h3 {
    color: var(--warning-color);
}

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

/* Game Screen */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.round-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.round-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--secondary-color);
}

.round-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light-bg);
    border-radius: var(--radius);
}

.timer-value {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-dark);
}

/* Game Tabs */
.game-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--light-bg);
}

.tab-btn.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

/* Tab Panels */
.game-content {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-height: 500px;
}

.tab-panel {
    display: none;
    padding: 2rem;
}

.tab-panel.active {
    display: block;
}

/* Casus Card */
.casus-card {
    max-width: 900px;
    margin: 0 auto;
}

.casus-summary {
    font-size: 1.125rem;
    color: var(--text-dark);
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--light-bg);
    border-radius: var(--radius);
}

.casus-content {
    margin: 1.5rem 0;
}

.casus-iframe {
    width: 100%;
    min-height: 400px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
}

.casus-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.detail-section {
    padding: 1rem;
    background: rgba(52, 152, 219, 0.05);
    border-radius: var(--radius);
    border-left: 4px solid var(--secondary-color);
}

.detail-section h4 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.vitals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.vital-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: white;
    border-radius: calc(var(--radius) / 2);
}

.vital-item span:first-child {
    font-weight: 500;
    color: var(--text-light);
}

.vital-item span:last-child {
    font-weight: 600;
    color: var(--text-dark);
}

.medication-list,
.risks-list {
    list-style: none;
}

.medication-list li,
.risks-list li {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: calc(var(--radius) / 2);
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.chat-type-selector {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-type-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: var(--light-bg);
    border-radius: var(--radius);
}

.chat-message.own {
    background: rgba(52, 152, 219, 0.1);
    align-self: flex-end;
    max-width: 70%;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.chat-message-sender {
    font-weight: 600;
    color: var(--secondary-color);
}

.chat-message-time {
    color: var(--text-light);
}

.chat-message-text {
    color: var(--text-dark);
    word-wrap: break-word;
}

.chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-form input {
    flex: 1;
}

/* Problems */
.problems-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.problem-item {
    display: flex;
    gap: 0.5rem;
}

.problem-item input {
    flex: 1;
}

.btn-remove {
    padding: 0.5rem 0.75rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove:hover {
    background: #c0392b;
}

.submitted-problems,
.submitted-goals,
.submitted-sbar {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.submitted-item {
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--light-bg);
    border-radius: var(--radius);
}

.submitted-by {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* SBAR */
.sbar-section {
    margin-bottom: 1rem;
}

.sbar-section h4 {
    color: var(--secondary-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* Evaluation */
.rating-scale {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.rating-scale label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--light-bg);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.rating-scale label:hover {
    background: rgba(52, 152, 219, 0.1);
}

.rating-scale input[type="radio"]:checked + label {
    background: var(--secondary-color);
    color: white;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.modal-content {
    padding: 2rem;
}

.modal-content h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.export-content {
    max-height: 400px;
    overflow: auto;
    background: var(--light-bg);
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.export-content pre {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
}

/* Footer */
.app-footer {
    background: var(--dark-bg);
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    
    .lobby-options {
        grid-template-columns: 1fr;
    }
    
    .waiting-container {
        grid-template-columns: 1fr;
    }
    
    .game-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .game-tabs {
        flex-wrap: wrap;
    }
    
    .casus-details {
        grid-template-columns: 1fr;
    }
    
    .modal {
        width: 95%;
    }
}

/* Accessibility */
:focus-visible {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Print Styles */
@media print {
    .app-header,
    .app-footer,
    .game-controls,
    .host-controls,
    .btn,
    .modal {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .screen.active {
        display: block !important;
    }
}
