/* ============================================================
   DONA FULANA — Admin SPA Layout & Kanban
   ============================================================ */

/* ── Layout Principal ── */
.admin-layout {
  display: flex;
  height: 100vh;
  background: #F8F9FA;
  overflow: hidden;
}

/* ── Sidebar ── */
.admin-sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid var(--cream-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--cream-dark);
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--burgundy);
  font-size: 1.1rem;
}

.sidebar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.sidebar-nav {
  padding: 1.5rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-btn {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.nav-btn:hover {
  background: var(--cream);
  color: var(--burgundy);
}

.nav-btn.active {
  background: rgba(107, 28, 58, 0.08);
  color: var(--burgundy);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--cream-dark);
}

.text-danger {
  color: #DC3545 !important;
}

.text-danger:hover {
  background: rgba(220, 53, 69, 0.08) !important;
}

/* ── Content Area ── */
.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem;
}

.admin-view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.admin-view.active {
  display: block;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.view-header h2 {
  font-family: var(--font-heading);
  color: var(--burgundy);
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
}

.view-header p {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ── Dashboard Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

/* ── Kanban Board ── */
.kanban-board {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
}

.kanban-column {
  flex: 1;
  min-width: 300px;
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
}

.kanban-title {
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.bg-orange { background: #F59E0B; }
.bg-blue { background: #3B82F6; }
.bg-green { background: #10B981; }

.kanban-items {
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 150px;
  background: #F9FAFB;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.kanban-card {
  background: var(--white);
  padding: 1rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: grab;
  border-left: 4px solid var(--cream-dark);
  transition: transform 0.2s;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.kb-order-id { font-size: 0.75rem; color: var(--text-light); margin-bottom: 0.25rem; }
.kb-customer { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.kb-total { color: var(--burgundy); font-weight: 600; font-size: 0.9rem; }
.kb-status-select {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.25rem;
  font-size: 0.8rem;
  border-radius: 4px;
  border: 1px solid #ddd;
}

/* ── Settings Form ── */
.settings-form {
  max-width: 600px;
}

.settings-card {
  background: var(--white);
  padding: 2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.settings-card h3 {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--cream-dark);
}

.settings-img-preview {
  max-width: 150px;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid var(--cream-dark);
}

/* ── Auth Toggle ── */
.auth-toggle {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-light);
}

.btn-text {
  background: none;
  border: none;
  color: var(--burgundy);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-text:hover {
  text-decoration: underline;
}

/* ============================================================
   KANBAN ENHANCEMENTS & BADGES
   ============================================================ */
.bg-red { background: #DC3545; }

.kanban-card {
  position: relative;
}
.kb-delivery {
  font-size: 0.75rem;
  color: var(--text-medium);
  margin-top: 0.25rem;
  background: #f1f5f9;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  display: inline-block;
}

.kb-badges {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.kb-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-weight: bold;
}
.kb-badge-pickup { background: #E0E7FF; color: #3730A3; }
.kb-badge-manual { background: #FEF3C7; color: #92400E; }

/* Urgency Borders */
.urgency-late { border-left-color: #DC3545; }
.urgency-today { border-left-color: #F59E0B; }
.urgency-soon { border-left-color: #3B82F6; }

/* ============================================================
   MANUAL SALE
   ============================================================ */
.manual-sale-form-card {
  background: var(--white);
  padding: 2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  max-width: 800px;
}

.delivery-type-selector {
  display: flex;
  gap: 0.5rem;
}
.delivery-type-btn {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid var(--cream-dark);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-weight: bold;
  color: var(--text-medium);
  cursor: pointer;
  transition: all 0.2s;
}
.delivery-type-btn.active {
  border-color: var(--burgundy);
  background: rgba(107, 28, 58, 0.05);
  color: var(--burgundy);
}

.manual-item-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}
.manual-product-preview {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  border: 1px solid #cbd5e1;
  flex-shrink: 0;
}
#manual-sale-items {
  margin-bottom: 1rem;
}
.manual-item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.manual-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}
.manual-item-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
}
.manual-sale-total {
  font-size: 1.2rem;
  text-align: right;
  padding: 1rem 0;
  border-top: 1px solid var(--cream-dark);
  margin-top: 1rem;
}
.manual-sale-financial {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  background: #f8fafc;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}
.manual-balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 1.1rem;
}
.text-danger { color: #DC3545; }
.text-success { color: #10B981; }

.kb-balance {
  background: #FEF2F2;
  color: #DC3545;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  display: inline-block;
  margin-top: 0.25rem;
}

/* ============================================================
   REPORTS & CHARTS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  font-size: 2rem;
}
.stat-info {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 0.85rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--burgundy);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--white);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-main);
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.5rem;
}
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ============================================================
   LOGISTICS & ALERTS
   ============================================================ */
#logistics-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.alert-card {
  padding: 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  transition: transform 0.2s;
}
.alert-card:hover { transform: translateX(5px); }
.alert-warning { background: #FFFBEB; border-left: 4px solid #F59E0B; color: #92400E; }
.alert-danger { background: #FEF2F2; border-left: 4px solid #DC3545; color: #991B1B; }
.alert-urgent { background: #EFF6FF; border-left: 4px solid #3B82F6; color: #1E40AF; }
.alert-success { background: #ECFDF5; border-left: 4px solid #10B981; color: #065F46; }

.logistics-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.logistics-card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--cream-dark);
  transition: transform 0.2s;
}
.logistics-card:hover { transform: translateY(-3px); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.logistics-card-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}
.logistics-card-body {
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-medium);
  line-height: 1.4;
}
.logistics-status-label {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: #f1f5f9;
}
.logistics-late { border-top-color: #DC3545; }
.logistics-late .logistics-status-label { background: #FEF2F2; color: #DC3545; }
.logistics-today { border-top-color: #F59E0B; }
.logistics-today .logistics-status-label { background: #FFFBEB; color: #F59E0B; }
.logistics-soon { border-top-color: #3B82F6; }

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

/* ── Mobile Header hidden by default on desktop ── */
.admin-mobile-header {
  display: none;
}

.back-btn {
  display: none !important;
  margin-bottom: 1.5rem;
}

/* ── Responsividade para Celulares (max-width: 768px) ── */
@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column;
  }

  /* Header mobile */
  .admin-mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    background: var(--burgundy);
    color: var(--white);
    padding: 0 1rem;
    box-shadow: var(--shadow-sm);
    z-index: 999;
    flex-shrink: 0;
  }

  .mobile-brand-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
  }

  .hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    margin-left: -10px;
  }

  .hamburger-btn span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--white);
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  /* Alterações na Sidebar no Mobile */
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.25);
  }

  .admin-sidebar.active {
    transform: translateX(0);
  }

  /* Overlay de fundo ao abrir a sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Ajustes da Área de Conteúdo */
  .admin-content {
    padding: 1.5rem 1rem;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .view-header h2 {
    font-size: 1.5rem;
  }

  .view-header p {
    font-size: 0.85rem;
  }

  /* Grid do Kanban */
  .kanban-board {
    padding-bottom: 0.5rem;
    gap: 1rem;
  }

  .kanban-column {
    min-width: 280px;
    max-height: calc(100vh - 180px);
  }

  /* Grid de estatísticas */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
  }

  .stat-info {
    text-align: left;
    margin-left: 10px;
  }

  /* Ajustes das Modais no Mobile */
  .modal-overlay {
    padding: 1rem;
  }

  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.5rem 1rem !important;
    border-radius: var(--radius-md);
  }

  /* Evitar overlap de campos em formulários */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row .form-group {
    width: 100% !important;
    margin-bottom: 1rem;
  }

  .manual-sale-financial {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
    padding: 1rem;
  }

  .manual-balance {
    align-items: flex-start;
  }

  .manual-item-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .manual-item-row input[type="number"] {
    width: 100% !important;
  }

  /* Botão voltar visível no mobile */
  .back-btn {
    display: inline-flex !important;
  }
}
