/* ══════════════════════════════════════════
   Neshy Admin — Custom Dark Theme
   Matches the mobile app's design system
   ══════════════════════════════════════════ */

:root {
  --neshy-bg-primary: #0A0E1A;
  --neshy-bg-secondary: #111827;
  --neshy-bg-tertiary: #1F2937;
  --neshy-surface: rgba(31, 41, 55, 0.5);
  --neshy-surface-border: rgba(75, 85, 99, 0.3);
  --neshy-primary: #06B6D4;
  --neshy-primary-dark: #0891B2;
  --neshy-secondary: #8B5CF6;
  --neshy-accent: #3B82F6;
  --neshy-success: #10B981;
  --neshy-warning: #F59E0B;
  --neshy-danger: #EF4444;
  --neshy-text-primary: #F9FAFB;
  --neshy-text-secondary: #9CA3AF;
  --neshy-text-tertiary: #6B7280;
  --neshy-text-muted: #4B5563;
  --neshy-glow-cyan: rgba(6, 182, 212, 0.15);
  --neshy-glow-purple: rgba(139, 92, 246, 0.15);
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--neshy-primary);
  color: #0A0E1A;
  font-weight: 700;
  transform: translateY(-160%);
  transition: transform 0.2s;
}

.skip-link:focus { transform: translateY(0); }

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid var(--neshy-primary);
  outline-offset: 3px;
}

body {
  background: var(--neshy-bg-primary);
  color: var(--neshy-text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--neshy-bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--neshy-text-muted); border-radius: 3px; }

/* Sidebar */
.sidebar {
  background: var(--neshy-bg-secondary);
  border-right: 1px solid var(--neshy-surface-border);
  width: 260px;
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--neshy-surface-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--neshy-primary), var(--neshy-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.sidebar-brand-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--neshy-text-primary);
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--neshy-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--neshy-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--neshy-text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--neshy-text-primary);
}

.sidebar-link.active {
  background: var(--neshy-glow-cyan);
  color: var(--neshy-primary);
  font-weight: 600;
}

.sidebar-link .badge {
  margin-left: auto;
  background: var(--neshy-danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--neshy-surface-border);
}

/* Main content */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
  padding: 0;
}

.top-bar {
  padding: 20px 32px;
  border-bottom: 1px solid var(--neshy-surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--neshy-bg-primary);
  position: sticky;
  top: 0;
  z-index: 30;
}

.top-bar h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--neshy-text-primary);
}

.page-content {
  padding: 28px 32px;
}

.admin-footer {
  padding: 18px 32px;
  border-top: 1px solid var(--neshy-surface-border);
  color: var(--neshy-text-muted);
  font-size: 12px;
  text-align: center;
}

.login-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  border-top: 0;
}

/* Cards */
.card {
  background: var(--neshy-bg-tertiary);
  border: 1px solid var(--neshy-surface-border);
  border-radius: 16px;
  padding: 20px;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: rgba(75, 85, 99, 0.5);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--neshy-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--neshy-text-primary);
}

.card-sub {
  font-size: 13px;
  color: var(--neshy-text-tertiary);
  margin-top: 4px;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 16px 16px 0 0;
}

.kpi-card.kpi-cyan::before { background: var(--neshy-primary); }
.kpi-card.kpi-purple::before { background: var(--neshy-secondary); }
.kpi-card.kpi-green::before { background: var(--neshy-success); }
.kpi-card.kpi-yellow::before { background: var(--neshy-warning); }
.kpi-card.kpi-red::before { background: var(--neshy-danger); }
.kpi-card.kpi-blue::before { background: var(--neshy-accent); }

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--neshy-surface-border);
  background: var(--neshy-bg-tertiary);
}

.neshy-table {
  width: 100%;
  border-collapse: collapse;
}

.neshy-table thead th {
  background: var(--neshy-bg-secondary);
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--neshy-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  border-bottom: 1px solid var(--neshy-surface-border);
}

.neshy-table tbody td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--neshy-text-secondary);
  border-bottom: 1px solid rgba(75, 85, 99, 0.15);
}

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

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

/* Status badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-cyan { background: rgba(6, 182, 212, 0.15); color: var(--neshy-primary); }
.badge-cyan .dot { background: var(--neshy-primary); }

.badge-yellow { background: rgba(245, 158, 11, 0.15); color: var(--neshy-warning); }
.badge-yellow .dot { background: var(--neshy-warning); }

.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--neshy-success); }
.badge-green .dot { background: var(--neshy-success); }

.badge-red { background: rgba(239, 68, 68, 0.15); color: var(--neshy-danger); }
.badge-red .dot { background: var(--neshy-danger); }

.badge-gray { background: rgba(107, 114, 128, 0.15); color: var(--neshy-text-tertiary); }
.badge-gray .dot { background: var(--neshy-text-tertiary); }

/* Forms */
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--neshy-bg-secondary);
  border: 1px solid var(--neshy-surface-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--neshy-text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--neshy-primary);
  box-shadow: 0 0 0 3px var(--neshy-glow-cyan);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--neshy-text-muted);
}

.form-select option {
  background: var(--neshy-bg-secondary);
  color: var(--neshy-text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--neshy-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover {
  background: var(--neshy-primary-dark);
  box-shadow: 0 4px 16px rgba(6, 182, 212, 0.4);
  color: white;
}

.btn-secondary {
  background: var(--neshy-secondary);
  color: white;
}

.btn-secondary:hover {
  opacity: 0.9;
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--neshy-surface-border);
  color: var(--neshy-text-secondary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--neshy-text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 160px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.pagination a, .pagination span {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--neshy-text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
}

.pagination a:hover {
  background: rgba(255, 255, 255, 0.05);
}

.pagination .current {
  background: var(--neshy-primary);
  color: white;
  font-weight: 600;
}

/* Messages / Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: rgba(16, 185, 129, 0.15); color: var(--neshy-success); border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-error { background: rgba(239, 68, 68, 0.15); color: var(--neshy-danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-info { background: rgba(6, 182, 212, 0.15); color: var(--neshy-primary); border: 1px solid rgba(6, 182, 212, 0.3); }

/* Login page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0A0E1A, #1F2937, #0A0E1A);
}

.login-card {
  background: var(--neshy-bg-secondary);
  border: 1px solid var(--neshy-surface-border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--neshy-primary), var(--neshy-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
}

/* Detail cards */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.detail-main { display: flex; flex-direction: column; gap: 20px; }
.detail-sidebar { display: flex; flex-direction: column; gap: 16px; }

/* User info in ticket detail */
.user-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--neshy-bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--neshy-surface-border);
}

.user-mini-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--neshy-primary), var(--neshy-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 1024px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
}


/* Phase 4: layout responsivo e navegação móvel */
.mobile-nav-toggle,
.sidebar-backdrop { display: none; }

.sidebar-nav {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page-content,
.top-bar,
.admin-footer {
  width: 100%;
  max-width: 1600px;
  margin-right: auto;
  margin-left: auto;
}

.card,
.detail-main,
.detail-sidebar,
.filter-bar > * { min-width: 0; }

.card-value,
.neshy-table td,
.user-mini-card,
.top-bar h1 { overflow-wrap: anywhere; }

@media (max-width: 768px) {
  body.sidebar-open { overflow: hidden; }

  .sidebar {
    display: flex;
    width: min(280px, calc(100vw - 40px));
    height: 100dvh;
    min-height: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 16px 0 40px rgba(0, 0, 0, 0.45);
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.65);
  }

  body.sidebar-open .sidebar-backdrop { display: block; }

  .mobile-nav-toggle {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 8px;
    border: 1px solid var(--neshy-surface-border);
    border-radius: 10px;
    background: var(--neshy-bg-tertiary);
    color: var(--neshy-text-primary);
  }

  .top-bar {
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .top-bar h1 {
    flex: 1;
    min-width: 0;
    font-size: 18px;
    line-height: 1.35;
  }

  .top-bar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

  .page-content { padding: 20px 16px; }
  .admin-footer { padding: 18px 16px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .filter-bar {
    align-items: stretch;
  }

  .filter-bar .form-input,
  .filter-bar .form-select {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100%;
  }

  .detail-grid { gap: 16px; }
  .pagination { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; border-radius: 12px; }
  .card-value { font-size: 24px; }
  .btn { white-space: normal; text-align: center; justify-content: center; }
  .filter-bar .btn { flex: 1 1 calc(50% - 6px); }
  .login-container { align-items: flex-start; padding: 24px 12px 80px; }
  .login-card { padding: 24px 18px; }
  [style*="grid-template-columns: repeat(4"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [style*="gap: 16px; font-size: 13px"] { flex-wrap: wrap !important; }
}

@media (max-width: 340px) {
  .page-content { padding-right: 10px; padding-left: 10px; }
  .top-bar { padding-right: 10px; padding-left: 10px; }
  [style*="grid-template-columns: repeat(4"] { grid-template-columns: minmax(0, 1fr) !important; }
  .filter-bar .btn { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
