/* ============================================
   ADMIN PANEL — "Obsidian Noir" Admin Styles
   Redesign 2026
   ============================================ */

/* ---------- Login Screen ---------- */
.admin-login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* decorative gradient orb behind login */
.admin-login-screen::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 181, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card-solid);
  border: none;
  border-radius: var(--radius-xl);
  padding: 44px 36px;
  box-shadow: var(--shadow-xl);
  animation: fadeSlideDown 0.5s var(--ease-out-expo) both;
  backdrop-filter: blur(24px);
  position: relative;
  z-index: 1;
}

/* top accent line */
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--accent-gradient);
  border-radius: 0 0 2px 2px;
}

.login-brand {
  text-align: center;
  margin-bottom: 36px;
}

.login-brand .brand-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 18px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-accent);
  position: relative;
}

.login-brand .brand-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: calc(var(--radius-md) + 3px);
  background: var(--accent-gradient);
  opacity: 0.2;
  filter: blur(10px);
  z-index: -1;
}

.login-brand .brand-icon i {
  font-size: 1.5rem;
  color: #000;
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.login-brand p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-wrapper i {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
  transition: color var(--transition);
}

.input-icon-wrapper input {
  padding-left: 44px !important;
}

.input-icon-wrapper input:focus ~ i,
.input-icon-wrapper:focus-within i {
  color: var(--accent);
}

.btn-full {
  width: 100%;
  padding: 14px;
  min-height: 48px; /* [UX §2] touch-target-size */
  font-size: 1rem;
  margin-top: 10px;
}

#loginError {
  margin: 14px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--error-dim);
  border: 1px solid rgba(255, 71, 87, 0.2);
  color: var(--error);
  font-size: 0.84rem;
  display: none;
}

#loginError:not(:empty) {
  display: block;
}

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--accent);
}

/* ---------- Dashboard Layout ---------- */
.admin-dashboard {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* ---------- Sidebar ---------- */
.admin-sidebar {
  width: 270px;
  background: var(--bg-secondary);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.4s var(--ease-out-expo);
  backdrop-filter: blur(20px);
}

.sidebar-header {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: none;
}

.brand-icon-sm {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-accent);
}

.brand-icon-sm i {
  font-size: 0.9rem;
  color: #000;
}

.sidebar-brand-text {
  flex: 1;
  min-width: 0;
}

.sidebar-title {
  display: block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-subtitle {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
}

.sidebar-close {
  display: none;
  width: 44px;
  height: 44px; /* [UX §2] touch-target-size */
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.sidebar-close:hover {
  background: var(--error-dim);
  color: var(--error);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px; /* [UX §2] touch-target-size */
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
  width: 100%;
  text-align: left;
  letter-spacing: 0.01em;
  position: relative;
}

.sidebar-item i {
  width: 20px;
  text-align: center;
  font-size: 0.92rem;
  flex-shrink: 0;
}

.sidebar-item:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-item.active i {
  color: var(--accent);
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  text-decoration: none;
}

.sidebar-logout {
  color: var(--error) !important;
}

.sidebar-logout:hover {
  background: var(--error-dim) !important;
}

/* ---------- Main Content ---------- */
.admin-main {
  flex: 1;
  margin-left: 270px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.4s var(--ease-out-expo);
}

/* ---------- Top Bar ---------- */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  height: 68px;
  background: var(--bg-glass);
  border-bottom: none;
  backdrop-filter: blur(var(--blur-amount)) saturate(1.8);
  -webkit-backdrop-filter: blur(var(--blur-amount)) saturate(1.8);
}

.topbar-menu {
  display: none;
  width: 44px;
  height: 44px; /* [UX §2] touch-target-size */
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.topbar-menu:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.admin-topbar h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: var(--bg-surface);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.topbar-user i {
  color: var(--accent);
  font-size: 0.82rem;
}

/* ---------- Admin Content ---------- */
.admin-content {
  flex: 1;
  padding: 32px;
  width: 100%;
  max-width: 1200px;
}

.admin-page {
  display: none;
  animation: fadeSlideUp 0.35s var(--ease-out-expo);
}

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

/* ---------- Stats Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  transition: all 0.3s var(--ease-out-expo);
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}

.stat-card:hover {
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-2px);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-blue { background: var(--info-dim); color: var(--info); }
.stat-green { background: var(--success-dim); color: var(--success); }
.stat-red { background: var(--error-dim); color: var(--error); }
.stat-gold { background: var(--accent-dim); color: var(--accent); }

.stat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-label {
  font-family: var(--font-display);
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ---------- Dashboard Section ---------- */
.dashboard-section {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 24px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.dashboard-section h3 {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.dashboard-section h3 i {
  color: var(--accent);
}

.recent-product-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: none;
  transition: all var(--transition);
}

.recent-product-item:last-child {
  border-bottom: none;
}

.recent-product-item:hover {
  padding-left: 8px;
}

.recent-product-item img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  background: #fff;
  padding: 5px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

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

.recent-product-info h4 {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-product-info span {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.recent-product-price {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Page Toolbar ---------- */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.search-wrapper-sm {
  flex: 1;
  min-width: 200px;
  max-width: 380px;
  position: relative;
}

.search-wrapper-sm .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-wrapper-sm input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  min-height: 44px; /* [UX §8] touch-friendly-input */
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: all var(--transition);
}

.search-wrapper-sm input::placeholder {
  color: var(--text-muted);
}

.search-wrapper-sm input:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

/* ---------- Products Table ---------- */
.products-table-wrapper {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.products-table thead {
  background: var(--bg-surface);
}

.products-table th {
  padding: 14px 18px;
  text-align: left;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: none;
  white-space: nowrap;
}

.products-table td {
  padding: 14px 18px;
  color: var(--text-primary);
  border-bottom: none;
  vertical-align: middle;
}

.products-table tbody tr {
  transition: all var(--transition);
}

.products-table tbody tr:hover {
  background: var(--bg-card-hover);
}

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

.table-product-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #fff;
  padding: 4px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
}

.table-product-name {
  font-family: var(--font-display);
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.table-price {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.table-stock {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.table-stock::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.table-stock.in-stock { color: var(--success); }
.table-stock.in-stock::before { background: var(--success); box-shadow: 0 0 6px var(--success); }
.table-stock.low-stock { color: var(--warning); }
.table-stock.low-stock::before { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.table-stock.out-of-stock { color: var(--error); }
.table-stock.out-of-stock::before { background: var(--error); box-shadow: 0 0 6px var(--error); }

.table-actions {
  display: flex;
  gap: 8px;
}

.table-actions button {
  padding: 10px 14px;
  min-height: 36px; /* compact but still accessible with spacing */
  border: none;
  border-radius: var(--radius-xs);
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.01em;
}

.table-actions .btn-edit {
  background: var(--info-dim);
  color: var(--info);
}
.table-actions .btn-edit:hover {
  background: var(--info);
  color: #fff;
  box-shadow: 0 4px 12px rgba(55, 66, 250, 0.25);
}

.table-actions .btn-delete {
  background: var(--error-dim);
  color: var(--error);
}
.table-actions .btn-delete:hover {
  background: var(--error);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 71, 87, 0.25);
}

.table-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.table-empty i {
  font-size: 2.5rem;
  margin-bottom: 14px;
  display: block;
  opacity: 0.25;
}

.table-empty p {
  font-size: 0.9rem;
}

/* ---------- Form Card ---------- */
.form-card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md);
  padding: 36px;
  max-width: 100%;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.form-card textarea {
  min-height: 180px;
  line-height: 1.7;
  font-size: 0.95rem;
}

.form-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.form-card h3 i {
  color: var(--accent);
}

.image-preview {
  width: 84px;
  height: 84px;
  object-fit: contain;
  background: #fff;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: none;
  box-shadow: var(--shadow-sm);
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Sidebar Overlay (mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out-expo);
  backdrop-filter: blur(4px);
}

.sidebar-overlay.show {
  opacity: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-close {
    display: flex;
  }

  .admin-main {
    margin-left: 0;
  }

  .topbar-menu {
    display: flex;
  }

  .topbar-user span {
    display: none;
  }

  .admin-content {
    padding: 18px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
    gap: 14px;
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .form-card {
    padding: 20px;
  }

  .form-card textarea {
    min-height: 150px;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
  }

  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-wrapper-sm {
    max-width: none;
  }

  /* Make table horizontally scrollable */
  .products-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .products-table {
    min-width: 580px;
  }

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

  .form-actions {
    flex-direction: column-reverse;
  }

  .admin-topbar {
    padding: 0 14px;
    height: 60px;
  }

  .admin-topbar h2 {
    font-size: 0.95rem;
  }
}

@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 32px 22px;
  }
}

/* ---------- Animations ---------- */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
