/* Estilos para el panel de administración */
:root {
  --primary: #00632a;
  --primary-light: #0a9a48;
  --primary-dark: #00491f;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  max-width: 400px;
  width: 100%;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo img {
  max-width: 150px;
  height: auto;
}

.login-title {
  color: var(--primary);
  text-align: center;
  margin-bottom: 30px;
  font-weight: 700;
}

.btn-login {
  background: var(--primary);
  border: none;
  padding: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-login:hover {
  background: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 99, 42, 0.3);
}

/* Admin Panel */
.admin-header {
  background: var(--primary);
  color: white;
  padding: 20px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.admin-content {
  padding: 30px 0;
  min-height: calc(100vh - 80px);
}

.stats-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.stats-card h3 {
  color: var(--primary);
  font-size: 2rem;
  margin-bottom: 5px;
}

.stats-card p {
  color: #666;
  margin: 0;
}

.upload-area {
  border: 3px dashed var(--primary);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  background: #f8f9fa;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-area:hover {
  background: #e9ecef;
  border-color: var(--primary-light);
}

.upload-area.drag-over {
  background: #d4edda;
  border-color: var(--primary-light);
}

.image-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin: 20px 0;
}

/* Multiple images list */
#imageList {
  max-height: 300px;
  overflow-y: auto;
}

#imageList .list-group-item {
  padding: 10px 15px;
  transition: background 0.2s;
}

#imageList .list-group-item:hover {
  background: #f8f9fa;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  max-height: 600px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
}

/* Scrollbar personalizada para la galería */
.gallery-grid::-webkit-scrollbar {
  width: 8px;
}

.gallery-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.gallery-grid::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

.gallery-grid::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

.gallery-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.gallery-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.gallery-card-body {
  padding: 15px;
}

.gallery-card-title {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.gallery-card-description {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 15px;
  min-height: 40px;
}

.gallery-card-actions {
  display: flex;
  gap: 10px;
}

.btn-edit {
  background: #0dcaf0;
  border: none;
  color: white;
  flex: 1;
}

.btn-edit:hover {
  background: #0aa2c0;
  color: white;
}

.btn-delete {
  background: #dc3545;
  border: none;
  color: white;
  flex: 1;
}

.btn-delete:hover {
  background: #bb2d3b;
  color: white;
}

.btn-back {
  background: #6c757d;
  border: none;
  color: white;
}

.btn-back:hover {
  background: #5a6268;
  color: white;
}

.alert-float {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

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

/* Estilos para la galería pública */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: block;
  text-decoration: none;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.gallery-item:hover .gallery-overlay {
  opacity: 1;
}

.gallery-item:focus {
  outline: none;
}

.gallery-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  display: block;
}

.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.3));
  color: white;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.gallery-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gallery-title {
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 1.1rem;
}

.gallery-description {
  font-size: 0.9rem;
  margin: 0;
  opacity: 0.9;
}

/* Contenedor con scroll para galería pública */
.gallery-scroll-container {
  max-height: 800px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
}

/* Scrollbar personalizada para galería pública */
.gallery-scroll-container::-webkit-scrollbar {
  width: 10px;
}

.gallery-scroll-container::-webkit-scrollbar-track {
  background: #e9ecef;
  border-radius: 10px;
  margin: 10px 0;
}

.gallery-scroll-container::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
  border: 2px solid #e9ecef;
}

.gallery-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--primary-light);
}

/* Responsive */
@media (max-width: 768px) {
  /* Login Page */
  .login-card {
    margin: 20px;
    padding: 30px;
  }

  /* Admin Header */
  .admin-header {
    padding: 15px 0;
  }

  .admin-header h1 {
    font-size: 1.2rem;
  }

  .admin-header small {
    font-size: 0.75rem;
  }

  /* Header buttons stack vertically on mobile */
  .admin-header .d-flex {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  .admin-header .btn {
    width: 100%;
    margin: 0 !important;
  }

  /* Stats cards */
  .stats-card {
    margin-bottom: 15px;
  }

  .stats-card h3 {
    font-size: 1.5rem;
  }

  /* Upload area */
  .upload-area {
    padding: 30px 20px;
  }

  .upload-area i {
    font-size: 2rem !important;
  }

  .upload-area p {
    font-size: 0.9rem;
  }

  /* Image preview */
  .image-preview {
    max-height: 200px;
  }

  /* Form inputs */
  .form-control,
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Gallery grid */
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 15px;
    max-height: 500px;
  }

  .gallery-card-image {
    height: 180px;
  }

  .gallery-card-title {
    font-size: 1rem;
  }

  .gallery-card-description {
    font-size: 0.85rem;
    min-height: auto;
  }

  .gallery-card-actions {
    flex-direction: column;
    gap: 8px;
  }

  .gallery-card-actions .btn {
    width: 100%;
  }

  /* Modals */
  .modal-dialog {
    margin: 10px;
  }

  .modal-body {
    padding: 20px;
  }

  .modal-footer {
    flex-direction: column;
    gap: 10px;
  }

  .modal-footer .btn {
    width: 100%;
    margin: 0 !important;
  }

  /* Alert float */
  .alert-float {
    right: 10px;
    left: 10px;
    min-width: auto;
    top: 10px;
  }

  /* Card headers */
  .card-header {
    padding: 15px;
  }

  .card-header h5 {
    font-size: 1rem;
  }

  .card-body {
    padding: 15px;
  }

  /* Upload button */
  #uploadBtn {
    width: 100%;
    margin-top: 10px;
  }

  /* Refresh button */
  #refreshGallery {
    width: 100%;
    margin-top: 10px;
  }
}

/* Extra small devices */
@media (max-width: 576px) {
  .admin-content {
    padding: 20px 0;
  }

  .container {
    padding-left: 15px;
    padding-right: 15px;
  }

  .stats-card h3 {
    font-size: 1.3rem;
  }

  .stats-card p {
    font-size: 0.85rem;
  }

  .gallery-card-image {
    height: 150px;
  }

  /* Galería pública en móvil */
  .gallery-scroll-container {
    max-height: 600px;
  }

  /* Modals full width on very small screens */
  .modal-dialog {
    margin: 5px;
    max-width: calc(100% - 10px);
  }

  /* Change password modal */
  #changePasswordModal .modal-body {
    padding: 15px;
  }

  #changePasswordModal .input-group-text {
    padding: 0.375rem 0.5rem;
  }

  #changePasswordModal .form-label {
    font-size: 0.9rem;
  }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .admin-header {
    padding: 10px 0;
  }

  .admin-header .d-flex {
    flex-direction: row;
    gap: 5px;
  }

  .admin-header .btn {
    width: auto;
    font-size: 0.85rem;
    padding: 8px 12px;
  }

  .stats-card {
    margin-bottom: 10px;
  }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets for mobile */
  .btn {
    min-height: 44px;
    padding: 12px 16px;
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
  }

  .form-control,
  .form-select {
    min-height: 44px;
    padding: 10px 12px;
  }

  /* Upload area more prominent on touch */
  .upload-area {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  /* Gallery cards easier to tap */
  .gallery-card {
    margin-bottom: 20px;
  }

  .gallery-card-actions {
    padding-top: 10px;
  }
}
