/* ==========================================================================
   LYUMÉ ADMIN PANEL DESIGN SYSTEM
   Visual Prototype & Developer Handoff Specification
   Warm Off-White Surfaces, Charcoal Sidebar, Muted Gold Accents, Clean Tables
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-page: #F9F9F8;
  --bg-card: #FFFFFF;
  --bg-sidebar: #141414;
  --bg-sidebar-hover: #1F1F1F;
  --bg-sidebar-active: #242424;
  
  --text-main: #111111;
  --text-muted: #666666;
  --text-subtle: #8A8A8A;
  --text-sidebar: #A0A0A0;
  --text-sidebar-active: #FFFFFF;
  
  --border-light: #EBEAE6;
  --border-card: #E5E3DF;
  --border-dark: #1E1E1E;
  
  --accent-gold: #C5A880;
  --accent-gold-dark: #A6865A;
  --accent-gold-light: #F4ECE1;

  --color-success: #1E824C;
  --color-success-bg: #E8F5E9;
  --color-warning: #D97706;
  --color-warning-bg: #FEF3C7;
  --color-info: #2563EB;
  --color-info-bg: #EFF6FF;
  --color-purple: #7C3AED;
  --color-purple-bg: #F5F3FF;
  --color-danger: #DC2626;
  --color-danger-bg: #FEE2E2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-modal: 0 20px 40px rgba(0, 0, 0, 0.16);

  --font-sans: 'Plus Jakarta Sans', 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Montserrat', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Clean Minimalist Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
}

/* Login View Layout Overrides */
body.login-view .admin-sidebar,
body.login-view .admin-topbar,
body.login-view .sidebar-overlay {
  display: none !important;
}
body.login-view .admin-main {
  margin-left: 0 !important;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Persistent Charcoal Sidebar */
.admin-sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  border-right: 1px solid var(--border-dark);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-header {
  padding: 32px 24px 20px 24px;
  border-bottom: 1px solid #1E1E1E;
  position: relative;
}

.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 20px;
  right: 16px;
  background: none;
  border: none;
  color: #888888;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.sidebar-close-btn:hover {
  color: #FFFFFF;
}

/* Mobile Sidebar Backdrop */
.sidebar-overlay {
  display: none;
}

.sidebar-logo {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #FFFFFF;
}

.sidebar-sub {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-top: 4px;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #555555;
  padding: 24px 24px 8px 24px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: #FFFFFF;
}

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 600;
  border-left: 3px solid var(--accent-gold);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid #1E1E1E;
  font-size: 0.75rem;
  color: #666666;
}

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

.admin-topbar {
  height: 68px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  margin-right: 4px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.mobile-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: #111111;
  border-radius: 2px;
  transition: all 0.2s ease;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-badge {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background-color: #F0ECE4;
  color: #7A6348;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.88rem;
}

.admin-user {
  font-weight: 500;
  color: #333333;
}

.btn-signout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.86rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
}

.btn-signout:hover {
  color: var(--color-danger);
}

.admin-content {
  flex: 1;
  padding: 36px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   COMPONENTS: HEADINGS, CARDS & KPIS
   ========================================================================== */

.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 4px;
}

/* 4 KPI Metric Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: var(--accent-gold);
}

.kpi-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 10px;
}

.kpi-subtitle {
  font-size: 0.76rem;
  color: var(--text-subtle);
  margin-top: 6px;
}

/* Card Container */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

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

.card-title {
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-main);
}

/* ==========================================================================
   DATA TABLES & FILTERS
   ========================================================================== */

.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 240px;
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  background-color: #FFFFFF;
}

.filter-select, .date-input {
  padding: 10px 14px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  background-color: #FFFFFF;
  color: #333333;
}

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
}

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

.admin-table th {
  background-color: #F8F7F4;
  color: #555555;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

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

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

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

.table-action-link {
  color: #111111;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.table-action-link:hover {
  color: var(--accent-gold-dark);
}

.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Pagination Bar */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  background: #FFFFFF;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-info {
  background-color: var(--color-info-bg);
  color: var(--color-info);
}

.badge-purple {
  background-color: var(--color-purple-bg);
  color: var(--color-purple);
}

.badge-danger {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-neutral {
  background-color: #EFEFEF;
  color: #555555;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background-color: #111111;
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: #2A2A2A;
}

.btn-secondary {
  background-color: #FFFFFF;
  color: #111111;
  border-color: var(--border-card);
}

.btn-secondary:hover {
  background-color: #F5F5F5;
}

.btn-gold {
  background-color: var(--accent-gold);
  color: #FFFFFF;
}

.btn-gold:hover {
  background-color: var(--accent-gold-dark);
}

.btn-danger {
  background-color: #FFFFFF;
  color: var(--color-danger);
  border-color: #FCA5A5;
}

.btn-danger:hover {
  background-color: var(--color-danger-bg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* ==========================================================================
   03 ORDER DETAILS INSPECTOR SPECIFICS
   ========================================================================== */

.order-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.order-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* Shiprocket 5-stage tracking timeline */
.tracking-timeline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  padding: 24px 10px 10px 10px;
}

.tracking-timeline::before {
  content: '';
  position: absolute;
  top: 35px;
  left: 40px;
  right: 40px;
  height: 3px;
  background-color: #E5E3DF;
  z-index: 1;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  text-align: center;
  flex: 1;
}

.step-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: #E5E3DF;
  border: 3px solid #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.step-label {
  font-size: 0.76rem;
  font-weight: 500;
  color: #777777;
}

.timeline-step.completed .step-circle {
  background-color: #111111;
}

.timeline-step.completed .step-label {
  color: #111111;
  font-weight: 600;
}

.timeline-step.active .step-circle {
  background-color: var(--accent-gold);
  box-shadow: 0 0 0 4px var(--accent-gold-light);
}

.timeline-step.active .step-label {
  color: var(--accent-gold-dark);
  font-weight: 700;
}

/* Order Action Toolbar */
.order-actions-bar {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

/* Responsive Layout Helpers */
.analytics-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  font-size: 0.9rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

/* ==========================================================================
   MODALS & TOAST NOTIFICATIONS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 16px;
  box-sizing: border-box;
}

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

.modal-box {
  background-color: #FFFFFF;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.modal-overlay.open .modal-box {
  transform: translateY(0);
}

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

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #888;
}

.modal-body {
  padding: 24px;
  font-size: 0.9rem;
  color: #333333;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  max-height: calc(88vh - 120px);
}

.modal-footer {
  padding: 16px 24px;
  background: #FAFAFA;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 48px);
}

.toast {
  background: #111111;
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.2s ease forwards;
  word-break: break-word;
}

.toast.toast-error {
  background: var(--color-danger);
}

.toast.toast-success {
  background: var(--color-success);
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   ========================================================================== */

@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .order-detail-grid {
    grid-template-columns: 1fr;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 260px;
    max-width: 82vw;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    box-shadow: none;
  }

  .admin-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.55);
  }

  .sidebar-close-btn {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

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

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

  .topbar-badge {
    display: none;
  }

  .admin-user {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .admin-content {
    padding: 20px 16px;
  }

  .analytics-metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .filter-bar {
    gap: 8px;
  }

  .search-input {
    width: 100%;
    min-width: 100%;
  }

  .filter-select, .date-input {
    flex: 1 1 calc(50% - 6px);
    min-width: 130px;
  }

  .filter-bar .btn {
    flex: 1 1 auto;
  }

  .order-actions-bar .btn {
    flex: 1 1 auto;
    min-width: 140px;
  }
}

@media (max-width: 540px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .page-header h1 {
    font-size: 1.45rem;
  }

  .card {
    padding: 18px 16px;
  }

  .modal-box {
    max-height: calc(100vh - 20px);
  }

  .modal-header {
    padding: 14px 18px;
  }

  .modal-body {
    padding: 16px 18px;
  }

  .modal-footer {
    padding: 12px 18px;
  }

  .modal-body div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .filter-select, .date-input {
    flex: 1 1 100%;
    width: 100%;
  }

  .tracking-timeline {
    min-width: 440px;
  }
}
