* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: #f5f3f0; color: #2D1B0E; }
h1, h2 { font-family: 'Montserrat', sans-serif; }

#loginSection { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1A1008 0%, #2D1B0E 100%); }
#dashboardSection { display: none; }

.login-container { background: white; padding: 40px; border-radius: 12px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.login-container h1 { font-size: 28px; margin-bottom: 30px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; }
.form-group input { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-family: 'Inter', sans-serif; }
.form-group input:focus { outline: none; border-color: #DAA520; box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.1); }
.btn { width: 100%; padding: 12px; background-color: #DAA520; color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 16px; }
.btn:hover { background-color: #FFD93D; color: #1A1008; }
.btn:disabled { background-color: #ccc; cursor: not-allowed; }
.error { color: #FF6B6B; margin-top: 15px; display: none; }

.admin-header { background: #1A1008; color: white; padding: 20px; display: flex; justify-content: space-between; align-items: center; }
.btn-logout { background-color: #FF6B6B; color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.btn-logout:hover { background-color: #ff5555; }

.dashboard-container { max-width: 1400px; margin: 0 auto; padding: 20px; }

.table-container { background: white; border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
table { width: 100%; border-collapse: collapse; }
th { background-color: #f0ede8; border-bottom: 2px solid #ddd; padding: 15px; text-align: left; font-weight: 600; font-size: 13px; text-transform: uppercase; }
td { padding: 15px; border-bottom: 1px solid #eee; }
tbody tr:hover { background-color: #faf9f8; }

.order-number { font-weight: 600; color: #DAA520; }
.status { display: inline-block; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-pending { background-color: #FFE5B4; color: #8B5E3C; }
.status-confirmed { background-color: #B3E5FC; color: #01579B; }
.status-in_progress { background-color: #FFF9C4; color: #F57F17; }
.status-delivered { background-color: #C8E6C9; color: #1B5E20; }
.status-cancelled { background-color: #FFCDD2; color: #B71C1C; }

.loading { text-align: center; padding: 40px; color: #999; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #2D1B0E; color: white; padding: 15px 20px; border-radius: 6px; display: none; z-index: 1000; }
.toast.show { display: block; animation: slideIn 0.3s ease; }
.toast.success { background-color: #1B5E20; }
.toast.error { background-color: #B71C1C; }

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

.tab-btn { padding: 12px 20px; background: none; border: none; cursor: pointer; font-weight: 600; color: #999; border-bottom: 3px solid transparent; transition: all 0.3s; font-family: 'Inter', sans-serif; }
.tab-btn.active { color: #DAA520; border-bottom-color: #DAA520; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.filter-bar { background: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 15px; align-items: flex-end; }
.filter-bar input, .filter-bar select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-family: 'Inter', sans-serif; }
.filter-bar input:focus, .filter-bar select:focus,
.stats-date-bar input:focus, .stats-date-bar select:focus { outline: none; border-color: #DAA520; box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.1); }
.btn-export, .btn-export-stats { background-color: #1B5E20; color: white; padding: 10px 15px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-export:hover, .btn-export-stats:hover { background-color: #2d7a2f; }

.detail-row { display: none; }
.detail-row.show { display: table-row; background-color: #f5f5f5; }
.detail-content { padding: 20px 15px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; }
.detail-field { font-size: 14px; }
.detail-field-label { font-weight: 600; color: #999; font-size: 12px; text-transform: uppercase; margin-bottom: 5px; }
.detail-field-value { color: #2D1B0E; }
.raw-cart-section { grid-column: 1 / -1; }
.raw-cart-list { font-size: 13px; line-height: 1.6; max-height: 400px; overflow-y: auto; }

.inline-edit { display: flex; gap: 5px; align-items: center; }
.inline-edit input { width: 100px; padding: 8px; border: 1px solid #DAA520; border-radius: 4px; font-family: 'Inter', sans-serif; }
.btn-confirm, .btn-cancel { padding: 6px 10px; border: none; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 12px; }
.btn-confirm { background-color: #1B5E20; color: white; }
.btn-confirm:hover { background-color: #2d7a2f; }
.btn-cancel { background-color: #FF6B6B; color: white; }
.btn-cancel:hover { background-color: #ff5555; }

.pagination { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 20px; }
.pagination button { padding: 8px 15px; background-color: #f0ede8; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; font-weight: 600; }
.pagination button:hover:not(:disabled) { background-color: #DAA520; color: white; }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-info { color: #666; font-size: 14px; }

.btn-expand { background: none; border: none; cursor: pointer; padding: 5px 10px; font-size: 14px; }

.stats-date-bar { background: white; padding: 15px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.stats-date-bar label { font-size: 12px; font-weight: 600; color: #999; text-transform: uppercase; display: block; margin-bottom: 6px; }
.stats-date-bar input, .stats-date-bar select { padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-family: 'Inter', sans-serif; }
.stats-date-bar button { padding: 10px 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi-card { background: white; border-radius: 10px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); text-align: center; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.kpi-card.revenue::before { background: linear-gradient(90deg, #DAA520, #FFD93D); }
.kpi-card.orders::before { background: linear-gradient(90deg, #01579B, #B3E5FC); }
.kpi-card.ticket::before { background: linear-gradient(90deg, #1B5E20, #C8E6C9); }
.kpi-card.repeat::before { background: linear-gradient(90deg, #F57F17, #FFF9C4); }
.kpi-icon { font-size: 28px; margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 800; color: #2D1B0E; margin-bottom: 4px; font-family: 'Montserrat', sans-serif; }
.kpi-label { font-size: 13px; color: #999; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-card { background: white; border-radius: 10px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: #2D1B0E; }
.chart-card.full-width { grid-column: 1 / -1; }
.chart-card canvas { max-height: 320px; }
.top-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.top-table th { background: #f0ede8; padding: 10px 12px; text-align: left; font-size: 12px; text-transform: uppercase; font-weight: 600; color: #999; }
.top-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.top-table tr:hover { background: #faf9f8; }
.rank-badge { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #DAA520; color: white; font-size: 12px; font-weight: 700; }
.stats-loader { text-align: center; padding: 40px; color: #999; }
.stats-loader::after { content: ' '; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #DAA520; animation: pulse 1.5s infinite; }
.kpi-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 12px; margin-top: 6px; display: inline-block; }
.kpi-badge.up { background: #C8E6C9; color: #1B5E20; }
.kpi-badge.down { background: #FFCDD2; color: #B71C1C; }
.stats-quick-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-quick { padding: 8px 12px; background: #f0ede8; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: #2D1B0E; transition: all 0.2s; }
.btn-quick:hover { background: #DAA520; color: white; border-color: #DAA520; }
.no-data { text-align: center; padding: 60px 20px; color: #999; font-size: 16px; }

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@media (max-width: 768px) {
  /* Tab bar scrolling */
  .tabs-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .tab-btn {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Admin header wrap */
  .admin-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .admin-header h1 {
    font-size: 18px;
  }

  /* Filter bar collapse to 1 column */
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .filter-bar .csv-btn {
    width: 100%;
  }

  /* Modal adjustments */
  .modal-panel {
    padding: 20px;
    width: 95% !important;
  }

  /* Edit order form 1 column */
  .edit-order-form-grid {
    grid-template-columns: 1fr;
  }

  /* Add customer form 1 column */
  .add-customer-form {
    grid-template-columns: 1fr;
  }
  .customers-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .customers-header h2 {
    width: 100%;
  }

  /* Config WhatsApp wrap */
  .config-wa-row {
    flex-wrap: wrap;
  }
  .config-wa-row input {
    width: 100%;
  }

  /* Detail grid collapse */
  .detail-grid {
    grid-template-columns: 1fr;
  }

  /* Stats KPI fix: 1 column on mobile */
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .kpi-value {
    font-size: 24px;
  }
  .kpi-card {
    padding: 16px;
  }

  /* Stats charts */
  .charts-grid {
    grid-template-columns: 1fr;
  }

  /* Stats date bar fix: proper flex layout */
  .stats-date-bar {
    flex-direction: column;
  }
  .stats-date-bar input,
  .stats-date-bar select,
  .stats-date-bar button {
    width: 100%;
  }

  /* Hide secondary table columns on mobile */
  .hide-mobile {
    display: none;
  }

  /* Reduce padding on tables for small screens */
  th {
    padding: 12px;
  }
  td {
    padding: 12px;
  }

  /* Reduce chart card padding */
  .chart-card {
    padding: 16px;
  }
}
