/* Reset y estilos base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", sans-serif;
  min-height: 100vh;
  overflow-y: auto;
}

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
  background: linear-gradient(135deg, #003f7d 0%, #0066cc 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  color: #2563eb;
  margin-right: 10px;
}

.login-card h1 {
  color: #1e293b;
  margin: 0;
  font-size: 1.8rem;
}

.welcome-text {
  color: #64748b;
  text-align: center;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: #94a3b8;
  z-index: 2;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 0.75rem 0.75rem 40px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  background-color: #f8fafc;
}

.login-card input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background-color: white;
}

.login-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1rem;
  background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.login-btn:hover {
  background: linear-gradient(90deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
}

.btn-icon {
  width: 20px;
  height: 20px;
}

.footer-links {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5rem;
  font-size: 0.85rem;
}

.footer-links a {
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: #2563eb;
}

/* Estilos para la aplicación principal */
#app-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: #003f7d;
  color: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  position: relative;
}

header h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

header h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#user-info {
  order: -1;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Estilos para la tabla en el dashboard */
.stats {
  margin-bottom: 1.5rem;
}

.stats p {
  margin: 0.5rem 0;
}

/* Paginación */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.pagination-btn {
  padding: 0.5rem 1rem;
  min-width: 100px;
}

#page-info {
  font-size: 0.9rem;
  color: #64748b;
}

#current-user {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 20px;
}

.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 250px;
  background-color: #f8fafc;
  padding: 1.5rem 1rem;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu li {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-menu li:hover {
  background-color: #e0e7ff;
}

.sidebar-menu li.active {
  background-color: #2563eb;
  color: white;
}

.content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background-color: #f9fafb;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
}

.card {
  background: white;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  margin-top: 0;
  color: #003f7d;
  font-size: 1.25rem;
}

.btn {
  background-color: #2563eb;
  color: white;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-family: "Inter", sans-serif;
  transition: background-color 0.2s ease;
}

.btn:hover {
  background-color: #1d4ed8;
}

input,
select {
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: "Inter", sans-serif;
}

input:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.oculto {
  display: none;
}

.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.course-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.25rem;
  transition: transform 0.2s ease;
}

.course-card:hover {
  transform: translateY(-2px);
}

.diploma-preview {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.diploma-preview img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
}

.search-container {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: "Inter", sans-serif;
}

.table-container {
  overflow-x: auto;
  margin-top: 20px;
}

.courses-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.courses-table th,
.courses-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.courses-table th {
  background-color: #f8fafc;
  font-weight: 600;
  color: #003f7d;
}

.courses-table tr:hover {
  background-color: #f5f7fa;
}

.download-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
}

.pagination-btn {
  padding: 0.5rem 1rem;
}

.admin .sidebar-menu li[data-section="courses"],
.admin .sidebar-menu li[data-section="students"],
.user .sidebar-menu li[data-section="my-courses"],
.user .sidebar-menu li[data-section="diplomas"] {
  display: none;
}

.admin .sidebar-menu li[data-section="courses"],
.admin .sidebar-menu li[data-section="students"] {
  display: flex;
}

.user .sidebar-menu li[data-section="my-courses"],
.user .sidebar-menu li[data-section="diplomas"] {
  display: flex;
}

@media (max-width: 768px) {
  .main-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
  }

  .login-card {
    width: 90%;
    padding: 1.5rem;
  }
}

.loader {
  text-align: center;
  padding: 2rem;
  font-style: italic;
  color: #64748b;
}

.course-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: transform 0.2s ease;
}

.course-card:hover {
  transform: translateY(-2px);
}

.course-card h3 {
  margin-top: 0;
  color: #003f7d;
}

.diploma-preview {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.diploma-preview h3 {
  color: #003f7d;
}

.search-container {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
}

header h1 {
  position: static;
  transform: none;
  margin: 0;
}

#user-info {
  order: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logout-link {
  color: #333;
  text-decoration: none;
  padding: 0.75rem 1rem;
  display: block;
  transition: all 0.2s ease;
}

.logout-link:hover {
  color: #e53e3e;
  background-color: #fee2e2;
}

.courses-table td:last-child {
  text-align: center;
}

.download-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  background-color: #38a169;
}

.download-btn:hover {
  background-color: #2f855a;
}

.download-btn:disabled {
  background-color: #a0aec0;
  cursor: not-allowed;
}

.badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: capitalize;
}

.badge.active {
  background-color: #4caf50;
  color: white;
}

.badge.completed {
  background-color: #2196f3;
  color: white;
}

.badge.archived {
  background-color: #9e9e9e;
  color: white;
}

.badge.type-inyeccion {
  background-color: #2196f3;
  color: white;
}

.badge.type-pildora {
  background-color: #ff9800;
  color: white;
}

.badge.type-tratamiento {
  background-color: #9c27b0;
  color: white;
}

.description-cell {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.description-cell:hover {
  background: inherit;
  box-shadow: none;
  cursor: default;
}

.no-data {
  text-align: center;
  padding: 20px;
  color: #64748b;
  font-style: italic;
}

textarea {
  min-height: 100px;
  resize: vertical;
  font-family: "Inter", sans-serif;
}

.error-card {
  border-left-color: #e53e3e !important;
}

.error-card h2 {
  color: #e53e3e;
}

.students-management {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#studentForm {
  margin-top: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #334155;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: "Inter", sans-serif;
  transition: all 0.2s ease;
}

.form-group input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
  outline: none;
}

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

/* Tabla */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-box {
  position: relative;
  min-width: 250px;
}

.search-box input {
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
  background-size: 1rem;
}

.table-responsive {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.students-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.students-table th {
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
}

.students-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.students-table tr:last-child td {
  border-bottom: none;
}

.students-table tr:hover td {
  background-color: #f8fafc;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.btn-edit {
  background-color: #f59e0b;
  color: white;
}

.btn-edit:hover {
  background-color: #d97706;
}

.no-data {
  text-align: center;
  padding: 2rem;
  color: #64748b;
}

.no-data svg {
  margin-bottom: 1rem;
  stroke-width: 1.5;
}

.no-data h3 {
  color: #334155;
  margin-bottom: 0.5rem;
}

.no-data p {
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-box {
    width: 100%;
  }

  .action-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }

  .action-buttons button {
    width: 100%;
  }
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.modal-header h3 {
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  background-color: #f9fafb;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 4px;
  color: white;
  z-index: 1001;
  animation: slideIn 0.3s ease-out;
}

.toast-success {
  background-color: #4caf50;
}

.toast-error {
  background-color: #f44336;
}

.toast-warning {
  background-color: #ff9800;
}

.fade-out {
  animation: fadeOut 0.3s ease-in;
}

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

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

.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background-color: #f9fafb;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem;
  background-color: #ffffff;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.checkbox-group label:hover {
  background-color: #e2e8f0;
}

.checkbox-group input[type="checkbox"] {
  accent-color: #2563eb;
}

.course-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.course-badge {
  background-color: #e0e7ff;
  color: #2563eb;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.description-cell {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.truncated-text {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.modal-description {
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
}

.read-more {
  color: #2563eb;
  font-size: 0.85rem;
  text-decoration: underline;
  margin-left: 6px;
  cursor: pointer;
}

#courses-content h2 + form,
#courses-content h2 + #courseForm {
  margin-top: 1.5rem;
}

#courses-content textarea[name="descripcion"] {
  font-size: 0.95rem;
}

textarea[name="descripcion"] {
  resize: none; 
  overflow-y: hidden;
}

.tooltip-csv {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 140%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #2563eb;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 0.75rem;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 10;
}

.tooltip-csv::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent #2563eb transparent;
}

svg:hover + .tooltip-csv,
.tooltip-csv:hover {
  visibility: visible;
  opacity: 1;
}

.table-container td,
.table-container th {
  vertical-align: middle;
}

.table-container td:nth-child(1),
.table-container td:nth-child(2) {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
