/* ═══════════════════════════════════════════════════════════
   👥 USERS PAGE - Gestión de Usuarios
   ═══════════════════════════════════════════════════════════
   
   СТРУКТУРА:
   1. Body override для users page
   2. Container и layout
   3. Page header
   4. Barra de búsqueda y filtros
   5. Grid de tarjetas
   6. Tarjeta individual de usuario
   7. Modal de edición/creación
   8. Botones específicos
   9. Badges y estados
   10. Responsive
   
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────
   📦 1. BODY OVERRIDE PARA USERS PAGE
   ───────────────────────────────────────────────────────── */
body.users-page {
  background: #f5f7fa;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
}

/* ─────────────────────────────────────────────────────────
   📦 2. CONTAINER Y LAYOUT
   ───────────────────────────────────────────────────────── */
.users-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* ─────────────────────────────────────────────────────────
   📋 3. PAGE HEADER
   ───────────────────────────────────────────────────────── */
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  border-radius: 15px;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.page-header h1 {
  color: white;
  margin: 0;
  font-size: 32px;
}

.page-header p {
  color: rgba(255, 255, 255, 0.9);
  margin: 5px 0 0 0;
  font-size: 14px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
}

/* ─────────────────────────────────────────────────────────
   🔍 4. BARRA DE BÚSQUEDA Y FILTROS
   ───────────────────────────────────────────────────────── */
.search-bar {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-group {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.search-input-group input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 15px;
  transition: all 0.3s ease;
}

.search-input-group input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  outline: none;
}

.search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 18px;
  pointer-events: none;
}

.search-results-count {
  color: #666;
  font-size: 14px;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────
   📇 5. GRID DE TARJETAS
   ───────────────────────────────────────────────────────── */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

/* ─────────────────────────────────────────────────────────
   🎴 6. TARJETA INDIVIDUAL DE USUARIO
   ───────────────────────────────────────────────────────── */
.user-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.user-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-color: #667eea;
}

/* Header de tarjeta */
.user-card-header {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  align-items: flex-start;
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  font-size: 13px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Contacto */
.user-contact {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.user-contact-item {
  font-size: 14px;
  color: #555;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-contact-item:last-child {
  margin-bottom: 0;
}

.contact-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* Trabajo */
.user-work {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.user-work-item {
  font-size: 13px;
  color: #666;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-work-item:last-child {
  margin-bottom: 0;
}

.work-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

/* Estado y rol */
.user-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.user-role {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-ADMIN {
  background: #fed7d7;
  color: #742a2a;
}

.role-SUPERVISOR {
  background: #feebc8;
  color: #7c2d12;
}

.role-WORKER {
  background: #c6f6d5;
  color: #22543d;
}

.role-EXECUTOR {
  background: #bee3f8;
  color: #2c5282;
}

.role-MATERIALS {
  background: #fbd38d;
  color: #744210;
}

.role-VIEWER {
  background: #e2e8f0;
  color: #2d3748;
}

.user-status {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-active {
  background: #c6f6d5;
  color: #22543d;
}

.status-inactive {
  background: #fed7d7;
  color: #742a2a;
}

/* Acciones */
.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.user-actions .btn {
  flex: 1;
  min-width: 100px;
  font-size: 13px;
  padding: 8px 12px;
}

/* ─────────────────────────────────────────────────────────
   📱 7. MODAL DE EDICIÓN/CREACIÓN
   ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.show {
  display: flex;
}

.modal-container {
  background: white;
  border-radius: 20px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 25px 30px;
  border-bottom: 2px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 20px 20px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  color: white;
}

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.modal-body {
  padding: 30px;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 2px solid #f0f0f0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Secciones del formulario */
.form-section {
  margin-bottom: 30px;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section h3 {
  font-size: 18px;
  color: #333;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

/* ─────────────────────────────────────────────────────────
   🔘 8. BOTONES ESPECÍFICOS
   ───────────────────────────────────────────────────────── */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

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

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-success {
  background: #48bb78;
  color: white;
}

.btn-success:hover {
  background: #38a169;
}

.btn-danger {
  background: #f56565;
  color: white;
}

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

.btn-warning {
  background: #ed8936;
  color: white;
}

.btn-warning:hover {
  background: #dd6b20;
}

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
}

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

.btn-whatsapp {
  background: #25d366;
  color: white;
}

.btn-whatsapp:hover {
  background: #1ebe57;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
}

/* ─────────────────────────────────────────────────────────
   ⏳ 9. LOADING Y MENSAJES
   ───────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-overlay.show {
  display: flex;
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 3000;
  animation: toastSlideIn 0.3s ease-out;
  max-width: 400px;
}

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

.toast.show {
  display: flex;
}

.toast-success {
  border-left: 4px solid #48bb78;
}

.toast-error {
  border-left: 4px solid #f56565;
}

.toast-warning {
  border-left: 4px solid #ed8936;
}

.toast-info {
  border-left: 4px solid #4299e1;
}

/* ─────────────────────────────────────────────────────────
   📱 10. RESPONSIVE
   ───────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .users-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

@media (max-width: 768px) {
  .users-container {
    padding: 15px;
  }

  .page-header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
    padding: 20px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .page-header-actions {
    width: 100%;
    flex-direction: column;
  }

  .page-header-actions .btn {
    width: 100%;
  }

  .search-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input-group {
    min-width: 100%;
  }

  .users-grid {
    grid-template-columns: 1fr;
  }

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

  .modal-container {
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal-header {
    border-radius: 0;
  }

  .user-actions {
    flex-direction: column;
  }

  .user-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .page-header {
    padding: 15px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .modal-body {
    padding: 20px 15px;
  }

  .modal-footer {
    padding: 15px;
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .user-card {
    padding: 15px;
  }

  .user-avatar {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .user-name {
    font-size: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════
   ✅ FIN DE ESTILOS USERS PAGE
   ═══════════════════════════════════════════════════════════ */
