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

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --primary: #00b894;
  --primary-dark: #00a07f;
  --danger: #e94560;
  --warning: #fdcb6e;
  --text: #2d3436;
  --text-light: #636e72;
  --bg: #f5f6fa;
  --white: #ffffff;
  --border: #dfe6e9;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  margin: 0;
}

.sidebar-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  margin: 2px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

.sidebar-nav a.active {
  background: rgba(0,184,148,0.12);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  max-width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
}

h1 { font-size: 28px; font-weight: 800; margin-bottom: 24px; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* ── Login ── */
.login-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.login-header p { color: var(--text-light); font-size: 14px; }

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

.stat-card {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-value { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Card ── */
.card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 24px;
}

.card-header { padding: 20px 24px 0; }
.card-body { padding: 20px 24px 24px; }

/* ── Table ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 12px 8px;
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover { background: #f8f9fa; }

.table-compact td, .table-compact th { padding: 8px 6px; font-size: 13px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending { background: #fff3cd; color: #856404; }
.badge-paid { background: #e8f5e9; color: #00b894; }
.badge-processing { background: #d1ecf1; color: #0c5460; }
.badge-shipped { background: #dbeafe; color: #1e40af; }
.badge-delivered { background: #c8f7e8; color: #00b894; }
.badge-cancelled, .badge-payment_failed { background: #fce4ec; color: #e94560; }
.badge-open { background: #fff3cd; color: #856404; }
.badge-in_progress { background: #d1ecf1; color: #0c5460; }
.badge-resolved { background: #e8f5e9; color: #00b894; }
.badge-closed { background: #e2e8f0; color: #636e72; }
.badge-whatsapp { background: #dcf8c6; color: #075e54; }
.badge-telegram { background: #d4edff; color: #0088cc; }
.badge-warning { background: #fff3cd; color: #856404; }

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

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #d63031; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: inherit; padding: 0; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,184,148,0.15); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.filter-form { margin-bottom: 0; }
.filter-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

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

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Alerts ── */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error { background: #fce4ec; color: #c62828; border: 1px solid #f8bbd0; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--white);
  border-radius: 16px;
  width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-lg { width: 700px; }

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

.modal-header h3 { margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0;
  line-height: 1;
}

.modal-body { padding: 24px; }
.modal + .modal { margin-top: 20px; }

/* ── Products Grid ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}

.product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.product-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #f0f0f0;
}

.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-image-placeholder { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 13px; }

.product-info { padding: 16px; }
.product-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.product-category { font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
.product-price { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.sale-price { color: var(--danger); }
.original-price { font-size: 13px; color: var(--text-light); text-decoration: line-through; margin-left: 6px; font-weight: 400; }
.product-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-light); margin-bottom: 12px; }
.product-actions { display: flex; gap: 8px; }

/* ── Order Detail ── */
.order-detail-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.order-detail-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.order-detail-section p { font-size: 13px; line-height: 1.8; color: var(--text-light); }

/* ── Ticket Messages ── */
.ticket-messages { max-height: 400px; overflow-y: auto; margin-bottom: 16px; }
.ticket-message { padding: 12px 16px; margin-bottom: 8px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.ticket-message.customer { background: #f0f0f0; margin-right: 40px; }
.ticket-message.agent { background: #e8f5e9; margin-left: 40px; }
.ticket-message .sender { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-light); margin-bottom: 4px; }
.ticket-message .time { font-size: 11px; color: var(--text-light); margin-top: 4px; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
  font-size: 14px;
}

/* ── Utility ── */
code { background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h1, .sidebar-subtitle, .sidebar-nav a span, .sidebar-footer div { display: none; }
  .sidebar-nav a { justify-content: center; padding: 14px; margin: 2px 4px; }
  .main-content { margin-left: 60px; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
