/* ============================================
   Role-Play Training - Estilos CSS
   ============================================ */

/* Variables - Gold/Artisan Theme */
:root {
  --primary: #c9a227;
  --primary-dark: #a68520;
  --secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e5e2dc;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

.subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card.centered {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
}

.card h1 {
  margin-bottom: 8px;
}

/* Forms */
.form {
  margin-top: 24px;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

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

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

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

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Error/Success messages */
.error {
  color: var(--danger);
  background: #fef2f2;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.spinner.large {
  width: 60px;
  height: 60px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Role-play Grid */
.roleplay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.roleplay-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.roleplay-card h3 {
  margin-bottom: 8px;
  color: var(--primary);
}

.roleplay-card p {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.roleplay-meta {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-light);
}

/* Play screen */
.screen {
  min-height: calc(100vh - 40px);
}

.scenario-box {
  background: var(--bg);
  padding: 20px;
  border-radius: var(--radius);
  margin: 20px 0;
  text-align: left;
}

.scenario-box h3 {
  margin-bottom: 12px;
  color: var(--primary);
}

.scenario-content {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.7;
}

.info-box {
  background: #fef3c7;
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  text-align: left;
}

.info-box p {
  margin: 4px 0;
  font-size: 0.9rem;
}

/* Active roleplay */
.roleplay-active {
  max-width: 600px;
  margin: 0 auto;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--secondary);
}

.status-indicator.connecting .dot {
  background: var(--warning);
  animation: pulse 1s infinite;
}

.status-indicator.active .dot {
  background: var(--success);
}

.status-indicator.error .dot {
  background: var(--danger);
}

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

.timer {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: monospace;
}

/* Audio visualizer */
.audio-visualizer {
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 20px;
}

.visualizer-bars {
  display: flex;
  justify-content: center;
  gap: 6px;
  height: 60px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.visualizer-bars .bar {
  width: 8px;
  background: var(--primary);
  border-radius: 4px;
  height: 20px;
  transition: height 0.1s;
}

.visualizer-bars.speaking .bar:nth-child(1) { animation: wave 0.5s ease-in-out infinite; }
.visualizer-bars.speaking .bar:nth-child(2) { animation: wave 0.5s ease-in-out 0.1s infinite; }
.visualizer-bars.speaking .bar:nth-child(3) { animation: wave 0.5s ease-in-out 0.2s infinite; }
.visualizer-bars.speaking .bar:nth-child(4) { animation: wave 0.5s ease-in-out 0.3s infinite; }
.visualizer-bars.speaking .bar:nth-child(5) { animation: wave 0.5s ease-in-out 0.4s infinite; }

@keyframes wave {
  0%, 100% { height: 20px; }
  50% { height: 50px; }
}

/* Transcript */
.transcript-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.transcript-container h4 {
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-light);
}

.transcript-box {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.transcript-item {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
}

.transcript-item.user {
  background: #fef3c7;
}

.transcript-item.assistant {
  background: #f0fdf4;
}

.controls {
  text-align: center;
}

/* Results */
.score-total-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  margin-bottom: 20px;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 2.5rem;
  font-weight: 700;
  border: 4px solid var(--border);
}

.score-circle.score-high {
  border-color: var(--success);
  color: var(--success);
}

.score-circle.score-medium {
  border-color: var(--warning);
  color: var(--warning);
}

.score-circle.score-low {
  border-color: var(--danger);
  color: var(--danger);
}

.score-label {
  color: var(--text-light);
  font-size: 0.95rem;
}

.feedback-text {
  font-size: 1rem;
  line-height: 1.7;
}

/* Criteria list */
.criteria-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.criteria-item {
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
}

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

.criteria-name {
  font-weight: 500;
}

.criteria-score {
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.score-high {
  background: #dcfce7;
  color: #166534;
}

.score-medium {
  background: #fef3c7;
  color: #92400e;
}

.score-low {
  background: #fee2e2;
  color: #991b1b;
}

.criteria-justification {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* History */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.session-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}

.session-card:hover {
  transform: translateX(4px);
}

.session-info h4 {
  margin-bottom: 4px;
}

.session-date,
.session-duration {
  font-size: 0.85rem;
  color: var(--text-light);
}

.session-score {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

/* Links */
.links {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.link-secondary {
  color: var(--text-light);
  font-size: 0.9rem;
  text-decoration: none;
}

.link-secondary:hover {
  color: var(--primary);
}

/* Admin nav */
.admin-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--bg-card);
  padding: 8px;
  border-radius: var(--radius);
}

.admin-nav .nav-item {
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
}

.admin-nav .nav-item:hover {
  background: var(--bg);
}

.admin-nav .nav-item.active {
  background: var(--primary);
  color: white;
}

/* Admin cards */
.admin-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.admin-card.inactive {
  opacity: 0.7;
}

.admin-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.admin-card-meta {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 12px 0;
}

.admin-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-inactive {
  background: #f1f5f9;
  color: #64748b;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 500;
  color: var(--text-light);
  font-size: 0.85rem;
}

.table tbody tr:hover {
  background: var(--bg);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  overflow-y: auto;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.25rem;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

.modal-content .form {
  padding: 24px;
  margin: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

/* Criteria editor */
.criterion-item {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.criterion-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 500;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
}

.criterion-fields {
  display: grid;
  grid-template-columns: 1fr 2fr 80px;
  gap: 8px;
  margin-bottom: 8px;
}

.criterion-fields input,
.criterion-item textarea {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
}

.criterion-item textarea {
  width: 100%;
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 8px;
}

.weight-sum {
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 8px;
}

.weight-sum.valid {
  color: var(--success);
}

.weight-sum.invalid {
  color: var(--danger);
}

/* Sections */
.section {
  margin-bottom: 32px;
}

.section h2 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}

.section h3 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

/* Collapsible */
.collapsible summary {
  cursor: pointer;
  list-style: none;
}

.collapsible summary::-webkit-details-marker {
  display: none;
}

.collapsible summary h3 {
  display: inline;
}

.collapsible summary h3::before {
  content: '+ ';
  color: var(--primary);
}

.collapsible[open] summary h3::before {
  content: '- ';
}

.transcript-full {
  margin-top: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.transcript-full p {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

/* Session details */
.session-details p {
  margin: 8px 0;
}

/* Audio player */
.audio-player {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.audio-player h4 {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 500;
}

.audio-player audio {
  width: 100%;
  border-radius: var(--radius);
  outline: none;
}

.audio-player audio::-webkit-media-controls-panel {
  background: var(--bg);
}

/* Filters */
.filters {
  margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .header h1 {
    font-size: 1.5rem;
  }
  
  .roleplay-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .criterion-fields {
    grid-template-columns: 1fr;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .admin-nav {
    flex-wrap: wrap;
  }
  
  .table th,
  .table td {
    padding: 8px;
    font-size: 0.85rem;
  }
}

/* Print styles */
@media print {
  .btn,
  .admin-nav,
  .header-right {
    display: none;
  }
}
