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

:root {
  --admin-bg: #f8fafc;
  --admin-card-bg: #ffffff;
  --admin-sidebar-bg: #ffffff;
  --admin-text-main: #0f172a;
  --admin-text-muted: #64748b;
  --admin-border: #e2e8f0;
  --admin-primary: #2563eb;
  --admin-primary-light: #eff6ff;
  --admin-accent-green: #10b981;
  --admin-accent-green-bg: #ecfdf5;
  --admin-accent-yellow: #f59e0b;
  --admin-accent-yellow-bg: #fffbeb;
  --admin-accent-pink: #ec4899;
  --admin-accent-pink-bg: #fdf2f8;
  --admin-accent-purple: #8b5cf6;
  --admin-accent-purple-bg: #f5f3ff;
  --admin-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --admin-radius: 1rem;
}

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

body.admin-body {
  font-family: 'Inter', sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Admin Wrapper Layout */
.admin-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

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

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

.sidebar-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--admin-primary), #1d4ed8);
  color: #fff;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.sidebar-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--admin-text-main);
  line-height: 1.2;
}
.sidebar-subtitle {
  font-size: 0.7rem;
  color: var(--admin-text-muted);
  font-weight: 500;
}

.sidebar-nav {
  padding: 1.25rem 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--admin-text-muted);
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--admin-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0.65rem;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.sidebar-item:hover {
  background: #f1f5f9;
  color: var(--admin-text-main);
}

.sidebar-item.active {
  background: var(--admin-primary-light);
  color: var(--admin-primary);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.sidebar-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* Main Content Area */
.admin-main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.admin-topbar {
  height: 65px;
  background: var(--admin-sidebar-bg);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.breadcrumb-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-muted);
  background: #f1f5f9;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f1f5f9;
  border: 1px solid var(--admin-border);
  padding: 0.45rem 0.85rem;
  border-radius: 0.65rem;
  width: 220px;
}
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.8rem;
  color: var(--admin-text-main);
  width: 100%;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.avatar-circle {
  width: 36px;
  height: 36px;
  background: #e2e8f0;
  color: var(--admin-text-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

/* Page Content Body */
.admin-content-body {
  padding: 2rem 1.75rem;
  flex: 1;
}

/* Stat Cards Grid (Exactly like screenshot) */
.stat-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--admin-shadow);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.06);
}

.stat-icon-badge {
  width: 48px;
  height: 48px;
  border-radius: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stat-icon-blue { background: var(--admin-primary-light); color: var(--admin-primary); }
.stat-icon-green { background: var(--admin-accent-green-bg); color: var(--admin-accent-green); }
.stat-icon-yellow { background: var(--admin-accent-yellow-bg); color: var(--admin-accent-yellow); }
.stat-icon-pink { background: var(--admin-accent-pink-bg); color: var(--admin-accent-pink); }
.stat-icon-purple { background: var(--admin-accent-purple-bg); color: var(--admin-accent-purple); }

.stat-info {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--admin-text-muted);
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--admin-text-main);
  line-height: 1.2;
  margin-top: 0.15rem;
}

/* Card Boxes */
.admin-card-box {
  background: var(--admin-card-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1.75rem;
  box-shadow: var(--admin-shadow);
  margin-bottom: 1.75rem;
}

.card-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--admin-border);
}
.card-box-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--admin-text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Clean Form Controls for Admin */
.admin-form-group {
  margin-bottom: 1.25rem;
}
.admin-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.4rem;
}
.admin-input, .admin-select, .admin-textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 0.65rem;
  font-size: 0.85rem;
  color: var(--admin-text-main);
  outline: none;
  transition: all 0.2s;
}
.admin-input:focus, .admin-select:focus, .admin-textarea:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.admin-btn-primary {
  padding: 0.65rem 1.35rem;
  background: var(--admin-primary);
  color: #ffffff;
  border: none;
  border-radius: 0.65rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.admin-btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.admin-btn-outline {
  padding: 0.5rem 1rem;
  background: #ffffff;
  color: #475569;
  border: 1px solid var(--admin-border);
  border-radius: 0.65rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.admin-btn-outline:hover {
  background: #f8fafc;
  color: var(--admin-text-main);
  border-color: #cbd5e1;
}

/* Data Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}
.admin-table th {
  padding: 0.85rem 1rem;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--admin-border);
}
.admin-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--admin-border);
  color: var(--admin-text-main);
  vertical-align: middle;
}
.admin-table tr:hover td {
  background: #f8fafc;
}

.badge-status-green {
  background: #dcfce7;
  color: #15803d;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.25rem 0.65rem;
  border-radius: 0.5rem;
  display: inline-block;
}
.badge-status-gray {
  background: #f1f5f9;
  color: #64748b;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.25rem 0.65rem;
  border-radius: 0.5rem;
  display: inline-block;
}

/* MOBILE BACKDROP OVERLAY */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* RESPONSIVE BREAKPOINTS FOR ALL CMS & ADMIN PANELS */
@media (max-width: 1024px) {
  .admin-sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  }
  .admin-sidebar.open {
    transform: translateX(0);
    z-index: 55;
  }
  .admin-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  .topbar-right .search-box {
    display: none;
  }
  div[style*="grid-column: span 2"] {
    grid-column: auto !important;
  }
}

@media (max-width: 768px) {
  .admin-topbar {
    padding: 0.75rem 1rem !important;
    height: auto !important;
    min-height: 60px !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
  .topbar-left {
    gap: 0.5rem !important;
  }
  .breadcrumb-tag {
    font-size: 0.65rem !important;
    padding: 0.2rem 0.5rem !important;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-right {
    gap: 0.5rem !important;
  }
  .user-profile-badge {
    padding: 0.25rem 0.5rem !important;
  }
  .user-profile-badge div:last-child {
    display: none !important; /* Hide username text on mobile, keep avatar */
  }
  .admin-content-body {
    padding: 1rem 0.75rem !important;
  }
  
  /* Grids and Cards */
  .stat-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }
  .stat-card {
    padding: 0.85rem !important;
    gap: 0.5rem !important;
  }
  .stat-value {
    font-size: 1.25rem !important;
  }
  .admin-card-box {
    padding: 1rem !important;
    border-radius: 0.85rem !important;
    margin-bottom: 1.25rem !important;
  }
  
  /* Form Grids & Controls */
  div[style*="grid-template-columns"],
  .grid,
  .md\:grid-cols-2,
  .md\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }
  
  .admin-table-wrapper,
  div[style*="overflow-x: auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
  }
  
  .admin-table {
    min-width: 600px !important; /* Ensures table scrolls smoothly without cramped text */
  }
  .admin-table th,
  .admin-table td {
    padding: 0.65rem 0.5rem !important;
    font-size: 0.78rem !important;
  }

  /* Pop-up Modals */
  div[id*="Modal"] > div,
  div[id*="modal"] > div {
    padding: 1.25rem !important;
    max-width: 95vw !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
}

@media (max-width: 580px) {
  .breadcrumb-tag {
    display: none !important;
  }
  .admin-topbar {
    justify-content: space-between !important;
  }
}

@media (max-width: 480px) {
  .stat-cards-grid {
    grid-template-columns: 1fr !important;
  }
  .card-box-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }
  .card-box-header form,
  .card-box-header div {
    width: 100% !important;
    max-width: 100% !important;
  }
  .admin-btn-primary,
  .admin-btn-outline {
    font-size: 0.75rem !important;
    padding: 0.45rem 0.75rem !important;
  }
}

/* DUAL TABLE VS MOBILE CARDS VIEW SWITCHER */
@media (max-width: 768px) {
  .desktop-table-view {
    display: none !important;
  }
  .mobile-cards-view {
    display: flex !important;
  }
}

@media (min-width: 769px) {
  .desktop-table-view {
    display: block !important;
  }
  .mobile-cards-view {
    display: none !important;
  }
}
