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

:root {
  --primary: #DC143C;
  --primary-dark: #9C0E2A;
  --primary-light: #FF6B7A;
  --secondary: #1a1a1a;
  --bg: #f5f5f5;
  --bg-dark: #fff;
  --text: #333;
  --text-light: #666;
  --border: #ddd;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Contenedor principal */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}

/* Encabezado */
header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo::before {
  content: "⚙️";
  font-size: 1.8rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  font-size: 0.9rem;
  opacity: 0.9;
}

.btn-logout {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.3);
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Diálogos */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Vistas */
.view {
  display: none;
}

.view.active {
  display: flex;
  flex: 1;
  flex-direction: column;
}

/* Login */
.login-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  margin-bottom: 1.5rem;
  color: var(--primary);
  text-align: center;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.95rem;
}

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

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

.form-group.error input,
.form-group.error select {
  border-color: var(--danger);
}

.error-message {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

/* Botones */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-block;
  text-align: center;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 20, 60, 0.3);
}

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

.btn-secondary {
  background: var(--gray-200);
  color: var(--text);
}

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

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

.btn-icon {
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dashboard */
.dashboard {
  display: flex;
  flex: 1;
  gap: 1rem;
  padding: 1rem 0;
}

.sidebar {
  width: 100%;
  max-width: 300px;
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  max-height: calc(100vh - 80px);
}

.sidebar h3 {
  color: var(--primary);
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.case-list {
  list-style: none;
}

.case-item {
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: var(--gray-100);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  border-left: 4px solid transparent;
}

.case-item:hover {
  background: var(--gray-200);
}

.case-item.active {
  background: var(--primary-light);
  color: white;
  border-left-color: var(--primary);
}

.case-item-title {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}

.case-item-meta {
  font-size: 0.8rem;
  opacity: 0.7;
}

.btn-new-case {
  width: 100%;
  margin-top: 1rem;
}

.main-content {
  flex: 1;
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Formulario nueva máquina */
.new-case-form {
  background: var(--gray-100);
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.new-case-form h3 {
  margin-bottom: 1rem;
  color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row.full {
  grid-template-columns: 1fr;
}

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

.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  background: var(--gray-100);
}

.message {
  margin-bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  animation: slideIn 0.3s ease-out;
}

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

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

.message-content {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  word-wrap: break-word;
}

.message.user .message-content {
  background: var(--primary);
  color: white;
}

.message.assistant .message-content {
  background: white;
  border: 1px solid var(--border);
  color: var(--text);
}

.message-time {
  font-size: 0.75rem;
  color: var(--text-light);
  align-self: flex-end;
  margin-top: 0.25rem;
}

.chat-input-area {
  display: flex;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-send {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s;
}

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

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

/* Estado de cargando */
.loading {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  animation: pulse 1.5s ease-in-out infinite;
  margin-right: 0.5rem;
}

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

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
  .dashboard {
    flex-direction: column;
  }

  .sidebar {
    max-width: 100%;
    max-height: 300px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .message-content {
    max-width: 90%;
  }

  .logo::before {
    font-size: 1.5rem;
  }

  .logo {
    font-size: 1.2rem;
  }

  .header-content {
    flex-direction: column;
    gap: 0.5rem;
  }

  .user-menu {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

/* Notificaciones */
.notification {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideDown 0.3s ease-out;
}

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

.notification.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.notification.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.notification.info {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}
