/* ==========================================================================
   PANEL ADMINISTRATIVO — MIGUEL CASTILLO ABARCA
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  --admin-bg: #0d0f14;
  --admin-sidebar: #131720;
  --admin-card: #171c26;
  --admin-border: #232938;
  --admin-accent: #ff6b4a;
  --admin-text: #f0f3f8;
  --admin-muted: #8b94a5;
  --admin-success: #2ed573;
  --admin-danger: #ff4757;
  --admin-warning: #ffa502;
}

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

body {
  background: var(--admin-bg);
  color: var(--admin-text);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

.admin-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--admin-sidebar);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--admin-text);
  text-decoration: none;
}

.sidebar-nav {
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--admin-muted);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.nav-item a:hover,
.nav-item.active a {
  background: rgba(255, 107, 74, 0.12);
  color: var(--admin-accent);
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--admin-border);
}

/* Main Content Area */
.admin-main {
  margin-left: 260px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  height: 70px;
  background: var(--admin-sidebar);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.admin-content {
  padding: 2.5rem;
  flex-grow: 1;
}

/* Tarjetas y Contenedores */
.card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--admin-border);
}

.card-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--admin-text);
}

/* Tablas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.admin-table th {
  padding: 0.9rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  color: var(--admin-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--admin-border);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.admin-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
}

.badge-success { background: rgba(46, 213, 115, 0.15); color: var(--admin-success); }
.badge-warning { background: rgba(255, 165, 2, 0.15); color: var(--admin-warning); }
.badge-danger  { background: rgba(255, 71, 87, 0.15); color: var(--admin-danger); }
.badge-primary { background: rgba(255, 107, 74, 0.15); color: var(--admin-accent); }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--admin-accent);
  color: #fff;
}
.btn-primary:hover {
  background: #ff8566;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--admin-text);
  border-color: var(--admin-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: var(--admin-danger);
  color: #fff;
}

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

/* Formularios */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--admin-muted);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #0d0f14;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  color: var(--admin-text);
  font-family: inherit;
  font-size: 0.9rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--admin-accent);
}

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

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

/* Alertas */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.alert-success { background: rgba(46, 213, 115, 0.15); border: 1px solid var(--admin-success); color: var(--admin-success); }
.alert-error { background: rgba(255, 71, 87, 0.15); border: 1px solid var(--admin-danger); color: var(--admin-danger); }
.alert-info { background: rgba(255, 107, 74, 0.15); border: 1px solid var(--admin-accent); color: var(--admin-accent); }

/* Galería en admin */
.admin-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.admin-gallery-item {
  position: relative;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}

.admin-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-gallery-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 71, 87, 0.9);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

/* ==========================================================================
   PRIORIZACIÓN Y REORDENAMIENTO DE PROYECTOS
   ========================================================================== */
.priority-info-box {
  display: flex;
  gap: 1rem;
  background: rgba(255, 107, 74, 0.05);
  border: 1px solid rgba(255, 107, 74, 0.25);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}

.priority-info-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.priority-info-text {
  font-size: 0.88rem;
  color: var(--admin-text);
  flex: 1;
}

.order-control-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 28px;
  color: var(--admin-muted);
  font-size: 1.1rem;
  cursor: grab;
  user-select: none;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.drag-handle:hover {
  background: rgba(255, 107, 74, 0.15);
  color: var(--admin-accent);
}

.drag-handle:active {
  cursor: grabbing;
}

.order-move-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-order-move {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--admin-border);
  color: var(--admin-muted);
  width: 22px;
  height: 14px;
  line-height: 1;
  font-size: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.btn-order-move:hover {
  background: var(--admin-accent);
  color: #fff;
  border-color: var(--admin-accent);
}

.order-input {
  width: 58px;
  padding: 0.35rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  background: #090b0e;
  border: 1px solid var(--admin-border);
  color: var(--admin-text);
  border-radius: 4px;
  transition: border-color 0.2s;
}

.order-input:focus {
  outline: none;
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2);
}

.priority-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--admin-muted);
  border: 1px solid var(--admin-border);
  min-width: 32px;
  text-align: center;
}

.priority-badge.priority-top {
  background: rgba(255, 107, 74, 0.15);
  color: var(--admin-accent);
  border-color: rgba(255, 107, 74, 0.4);
}

/* Efectos visuales de Drag & Drop */
tr.project-row {
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

tr.project-row.row-dragging {
  opacity: 0.35;
  background: rgba(255, 107, 74, 0.08) !important;
}

tr.project-row.row-dragover {
  border-top: 2px solid var(--admin-accent);
  background: rgba(255, 107, 74, 0.12) !important;
}

/* Toast flotante de estado */
.order-status-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.85rem 1.4rem;
  border-radius: 8px;
  background: #171c26;
  color: #fff;
  border: 1px solid var(--admin-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideToastIn 0.25s ease-out;
}

.order-status-toast.toast-success {
  border-color: var(--admin-success);
  background: rgba(23, 28, 38, 0.95);
  color: var(--admin-success);
}

.order-status-toast.toast-loading {
  border-color: var(--admin-accent);
  background: rgba(23, 28, 38, 0.95);
  color: var(--admin-accent);
}

.order-status-toast.toast-error {
  border-color: var(--admin-danger);
  background: rgba(23, 28, 38, 0.95);
  color: var(--admin-danger);
}

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

@media (max-width: 900px) {
  .admin-sidebar {
    display: none;
  }
  .admin-main {
    margin-left: 0;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
