/* =========================================
   Admin Panel V2 – Modern Mobile-First Design
   ========================================= */

.admin-app-v2 {
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-gray-100);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* =========================================
   Top Header
   ========================================= */
.admin-top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-md);
  background: var(--color-white);
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.admin-brand-icon {
  width: 44px;
  height: 44px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-brand-icon svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.admin-brand-text {
  display: flex;
  flex-direction: column;
}

.admin-brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.admin-brand-subtitle {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.admin-notification-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.admin-notification-btn svg {
  width: 24px;
  height: 24px;
  fill: var(--color-gray-700);
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background: var(--color-primary);
  border-radius: 50%;
  border: 2px solid var(--color-gray-100);
  display: none;
}

.notification-dot.active {
  display: block;
}

/* =========================================
   Filter Tabs
   ========================================= */
.admin-filter-tabs {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-white);
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--color-gray-200);
}

.admin-filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--color-gray-100);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gray-600);
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-tab.active {
  background: var(--color-primary);
  color: white;
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: rgba(0,0,0,0.1);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
}

.filter-tab.active .filter-count {
  background: rgba(255,255,255,0.25);
}

/* =========================================
   Main Content
   ========================================= */
.admin-main-content {
  flex: 1;
  padding: var(--space-md);
  padding-bottom: 100px;
  overflow-y: auto;
}

.admin-view {
  display: none;
}

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

/* =========================================
   Orders List
   ========================================= */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.order-card-v2 {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
}

.order-card-v2.status-new {
  border-left-color: var(--color-primary);
}

.order-card-v2.status-preparing {
  border-left-color: #f59e0b;
}

.order-card-v2.status-ready {
  border-left-color: #10b981;
}

.order-header-v2 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}

.order-table-v2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-primary);
}

.order-badge-v2 {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.order-badge-v2.new {
  background: var(--color-primary);
  color: white;
}

.order-badge-v2.preparing {
  background: #fef3c7;
  color: #92400e;
}

.order-badge-v2.ready {
  background: #d1fae5;
  color: #065f46;
}

.order-time-v2 {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.order-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-menu-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--color-gray-500);
}

.order-items-v2 {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.order-item-qty {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
  margin-right: var(--space-sm);
}

.order-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
}

.order-item-extras {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-left: var(--space-sm);
}

.order-actions-v2 {
  display: flex;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
}

.order-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.order-action-btn svg {
  width: 18px;
  height: 18px;
}

.order-action-btn--primary {
  background: var(--color-primary);
  color: white;
}

.order-action-btn--primary:active {
  background: var(--color-primary-dark);
}

.order-action-btn--secondary {
  background: var(--color-gray-100);
  color: var(--color-text);
  border: 1px solid var(--color-gray-300);
}

.order-action-btn--success {
  background: #10b981;
  color: white;
}

.order-action-btn--success:active {
  background: #059669;
}

/* =========================================
   Empty State
   ========================================= */
.empty-state-v2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
}

.empty-state-v2 svg {
  width: 64px;
  height: 64px;
  fill: var(--color-gray-300);
  margin-bottom: var(--space-md);
}

.empty-state-v2 p {
  font-size: 16px;
  color: var(--color-text-muted);
}

/* =========================================
   Tables View
   ========================================= */
.tables-header {
  margin-bottom: var(--space-lg);
}

.tables-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.stat-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--color-gray-200);
}

.stat-card--alert {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-card--alert .stat-label {
  color: rgba(255,255,255,0.8);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-text);
}

.stat-card--alert .stat-value {
  color: white;
}

.tables-legend {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-dot--empty {
  background: var(--color-gray-200);
  border: 2px dashed var(--color-gray-400);
}

.legend-dot--ordering {
  background: #fbbf24;
}

.legend-dot--eating {
  background: #10b981;
}

.legend-dot--call {
  background: var(--color-primary);
}

.tables-section {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.tables-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.tables-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.tables-section-floor {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.table-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.table-cell:active {
  transform: scale(0.95);
}

.table-cell--empty {
  background: var(--color-white);
  border: 2px dashed var(--color-gray-300);
  color: var(--color-gray-400);
}

.table-cell--ordering {
  background: #fbbf24;
  color: white;
}

.table-cell--eating {
  background: #10b981;
  color: white;
}

.table-cell--call {
  background: var(--color-primary);
  color: white;
  animation: pulse-call 1.5s infinite;
}

@keyframes pulse-call {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 24, 55, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(227, 24, 55, 0); }
}

.table-cell-id {
  font-size: 11px;
  opacity: 0.8;
}

.table-cell-seats {
  font-size: 20px;
  font-weight: 800;
}

.table-cell-icon {
  position: absolute;
  top: 6px;
  right: 6px;
}

.table-cell-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* =========================================
   History View
   ========================================= */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.history-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.btn-clear-history {
  padding: 8px 16px;
  background: var(--color-gray-100);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.history-item {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item-info {
  flex: 1;
}

.history-item-table {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.history-item-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

.history-item-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
}

/* =========================================
   Settings View
   ========================================= */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.settings-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

.settings-item {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.settings-item-info {
  flex: 1;
}

.settings-item-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.settings-item-desc {
  display: block;
  font-size: 13px;
  color: var(--color-text-muted);
}

.toggle-switch {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--color-gray-300);
  border-radius: var(--radius-full);
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background: #10b981;
}

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

.settings-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  background: var(--color-white);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-sm);
}

.settings-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--color-gray-600);
}

.settings-btn--danger {
  color: var(--color-primary);
}

.settings-btn--danger svg {
  fill: var(--color-primary);
}

/* =========================================
   Waiter Call Banner
   ========================================= */
.waiter-call-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  background: var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-xl);
  z-index: 60;
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.call-banner-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.call-banner-icon svg {
  width: 24px;
  height: 24px;
  fill: white;
}

.call-banner-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.call-banner-table {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.call-banner-text {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}

.call-banner-btn {
  padding: 10px 20px;
  background: white;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.call-banner-btn:active {
  background: var(--color-gray-100);
}

/* =========================================
   Bottom Navigation
   ========================================= */
.admin-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--color-white);
  display: flex;
  justify-content: space-around;
  padding: var(--space-sm) 0;
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--color-gray-200);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-xs) var(--space-md);
  color: var(--color-gray-500);
  transition: color 0.2s;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.nav-item span {
  font-size: 11px;
  font-weight: 600;
}

.nav-item.active {
  color: var(--color-primary);
}

.powered-by-link {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--color-gray-400);
  text-decoration: none;
  white-space: nowrap;
}

.powered-by-link strong {
  color: var(--color-gray-500);
  font-weight: 600;
}

.powered-by-link:hover {
  color: var(--color-primary);
}

.powered-by-link:hover strong {
  color: var(--color-primary);
}

/* =========================================
   Table Detail Modal
   ========================================= */
.table-detail-modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  background: var(--color-white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
  z-index: 201;
  transition: transform 0.3s ease-out;
}

.table-detail-modal.open {
  transform: translateX(-50%) translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--color-gray-300);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-md);
}

.table-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xs);
}

.table-detail-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.table-detail-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-text);
}

.table-detail-badge {
  padding: 4px 10px;
  background: rgba(227, 24, 55, 0.1);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.5px;
}

.table-detail-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  padding: 6px 12px;
  background: var(--color-gray-100);
  border-radius: var(--radius-md);
}

.table-detail-meta {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.table-detail-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  max-height: 200px;
  overflow-y: auto;
}

.table-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-gray-100);
}

.table-item-row:last-child {
  border-bottom: none;
}

.table-item-name {
  font-size: 15px;
  color: var(--color-text);
}

.table-item-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.table-detail-actions {
  display: flex;
  gap: var(--space-sm);
}

.table-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
}

.table-action-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.table-action-btn--secondary {
  background: var(--color-white);
  color: var(--color-text);
  border: 1px solid var(--color-gray-300);
}

.table-action-btn--primary {
  background: var(--color-primary);
  color: white;
}

/* =========================================
   Utilities
   ========================================= */
.hidden {
  display: none !important;
}

/* =========================================
   Desktop Responsive
   ========================================= */
@media (min-width: 768px) {
  .admin-app-v2 {
    max-width: 480px;
    box-shadow: var(--shadow-xl);
    min-height: 100vh;
    margin: 0 auto;
  }
}
