/* ==========================================================================
   iBin.Store - Modern Apple-Style Admin Dashboard
   ========================================================================== */

:root {
  --admin-primary: #0071e3;
  --admin-primary-hover: #0077ed;
  --admin-bg: #f5f5f7;
  --admin-card-bg: #ffffff;
  --admin-sidebar-bg: #1d1d1f;
  --admin-sidebar-text: #a1a1a6;
  --admin-sidebar-active: #ffffff;
  --admin-sidebar-hover: #2d2d2f;
  --admin-text-main: #1d1d1f;
  --admin-text-sub: #86868b;
  --admin-border: #e5e5ea;
  --admin-success: #34c759;
  --admin-warning: #ff9500;
  --admin-danger: #ff3b30;
  --admin-info: #5856d6;
  --admin-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body.admin-body {
  font-family: var(--admin-font);
  background-color: var(--admin-bg);
  color: var(--admin-text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- SIDEBAR --- */
.admin-sidebar {
  width: 260px;
  background-color: var(--admin-sidebar-bg);
  color: var(--admin-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: width 0.3s;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #2d2d2f;
}

.sidebar-header img {
  height: 36px;
  width: auto;
}

.sidebar-header-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.sidebar-header-badge {
  font-size: 10px;
  background: var(--admin-primary);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

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

.nav-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #6e6e73;
  padding: 12px 10px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.2s;
}

.sidebar-item:hover {
  background-color: var(--admin-sidebar-hover);
  color: var(--admin-sidebar-active);
}

.sidebar-item.active {
  background-color: var(--admin-primary);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-item-badge {
  margin-left: auto;
  background: var(--admin-danger);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #2d2d2f;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- MAIN CONTENT AREA --- */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Header */
.admin-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--admin-border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.admin-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--admin-text-main);
  letter-spacing: -0.4px;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--admin-border);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--admin-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

/* Page Views Container */
.admin-content {
  padding: 32px;
  flex: 1;
}

.admin-view {
  display: none;
  animation: fadeInView 0.25s ease;
}

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

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

/* --- STATS / KPI CARDS --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--admin-card-bg);
  border-radius: 16px;
  padding: 22px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stat-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--admin-text-sub);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.stat-card-val {
  font-size: 26px;
  font-weight: 700;
  color: var(--admin-text-main);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.stat-card-growth {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.growth-up { color: var(--admin-success); }
.growth-down { color: var(--admin-danger); }

/* --- ANALYTICS CHARTS SECTION --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--admin-card-bg);
  border-radius: 16px;
  padding: 24px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.chart-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--admin-text-main);
}

/* SVG Bar Chart */
.svg-chart-container {
  width: 100%;
  height: 220px;
}

/* Category Progress Bars */
.cat-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cat-breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-breakdown-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 500;
}

.cat-bar-bg {
  height: 8px;
  background: #f0f0f2;
  border-radius: 4px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* --- DATA TABLE CARD --- */
.data-card {
  background: var(--admin-card-bg);
  border-radius: 16px;
  border: 1px solid var(--admin-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  overflow: hidden;
  margin-bottom: 28px;
}

.data-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.data-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--admin-text-main);
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-search-input {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
  font-size: 13.5px;
  width: 240px;
  background: #fbfbfd;
  outline: none;
}

.table-search-input:focus {
  border-color: var(--admin-primary);
  background: #ffffff;
}

.table-filter-select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
  font-size: 13.5px;
  background: #fbfbfd;
  outline: none;
}

/* Table */
.admin-table-wrap {
  overflow-x: auto;
}

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

.admin-table th {
  background: #f9f9fb;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--admin-text-sub);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 16px 20px;
  font-size: 13.5px;
  color: var(--admin-text-main);
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background-color: #fafafc;
}

/* Product thumb in table */
.table-product-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: contain;
  background: #f5f5f7;
  padding: 2px;
}

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

.badge-pending { background: #fff3e0; color: #e65100; }
.badge-shipping { background: #e3f2fd; color: #1565c0; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }
.badge-cancelled { background: #ffebee; color: #c62828; }

/* Buttons */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-admin-primary {
  background: var(--admin-primary);
  color: #ffffff;
}

.btn-admin-primary:hover {
  background: var(--admin-primary-hover);
}

.btn-admin-secondary {
  background: #ffffff;
  border-color: var(--admin-border);
  color: var(--admin-text-main);
}

.btn-admin-secondary:hover {
  background: #f5f5f7;
}

.btn-admin-danger {
  background: #ffebee;
  color: var(--admin-danger);
  border-color: #ffcdd2;
}

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

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

/* --- SWITCH TOGGLE CONTROLS --- */
.switch-control {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e5e5ea;
  transition: 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch-control input:checked + .switch-slider {
  background-color: var(--admin-success);
}

.switch-control input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* --- WIDGET & SETTINGS CARDS --- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.widget-item-card {
  background: #fbfbfd;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.widget-item-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.widget-item-info p {
  font-size: 13px;
  color: var(--admin-text-sub);
}

/* Form Groups */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--admin-text-main);
  margin-bottom: 8px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
  font-size: 14px;
  background: #ffffff;
  color: var(--admin-text-main);
  outline: none;
  font-family: inherit;
  transition: border 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

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

/* --- MODAL DIALOGS --- */
.admin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  padding: 20px;
}

.admin-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.admin-modal {
  background: #ffffff;
  border-radius: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  animation: modalPop 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
  display: flex;
  flex-direction: column;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.admin-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-modal-title {
  font-size: 18px;
  font-weight: 700;
}

.admin-modal-body {
  padding: 24px;
}

.admin-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--admin-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #fafafc;
  border-radius: 0 0 20px 20px;
}

/* --- PRINT INVOICE FORMAT --- */
@media print {
  body * { visibility: hidden; }
  #printableInvoice, #printableInvoice * { visibility: visible; }
  #printableInvoice { position: absolute; left: 0; top: 0; width: 100%; }
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  body.admin-body { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; }
  .stats-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}
