/* ========================================
   AumAum 便當訂餐系統 - 全域樣式
   ======================================== */

/* 基礎設定 */
html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin-bottom: 60px;
  font-family: 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
}

/* 焦點樣式 */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* ========================================
   響應式設計調整 (T162)
   ======================================== */

/* 行動裝置調整 */
@media (max-width: 576px) {
  /* 導覽列 */
  .navbar-brand {
    font-size: 1rem;
  }

  /* 容器內距 */
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  /* 表格響應式 */
  .table-responsive {
    font-size: 0.85rem;
  }

  /* 按鈕組 */
  .btn-group-responsive {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group-responsive .btn {
    width: 100%;
  }

  /* 卡片 */
  .card {
    margin-bottom: 1rem;
  }

  .card-body {
    padding: 0.75rem;
  }

  /* 購物車項目 */
  .cart-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .cart-item-actions {
    margin-top: 0.5rem;
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  /* 時段選擇 */
  .time-slot-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Modal */
  .modal-dialog {
    margin: 0.5rem;
  }

  /* 表單 */
  .form-label {
    font-size: 0.9rem;
  }

  /* 價格標籤 */
  .price-tag {
    font-size: 1rem;
  }
}

/* 平板裝置調整 */
@media (min-width: 577px) and (max-width: 991px) {
  .time-slot-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 桌面裝置 */
@media (min-width: 992px) {
  .time-slot-grid {
    grid-template-columns: repeat(6, 1fr) !important;
  }

  .menu-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   元件樣式
   ======================================== */

/* 訂餐頁面日曆 */
.calendar-container {
  max-width: 100%;
  overflow-x: auto;
}

/* 時段選擇網格 */
.time-slot-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(4, 1fr);
}

.time-slot-btn {
  padding: 0.5rem 0.25rem;
  font-size: 0.85rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.time-slot-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.time-slot-btn.selected {
  background-color: #0d6efd;
  color: white;
  border-color: #0d6efd;
}

.time-slot-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 菜單項目網格 */
.menu-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}

.menu-item-card {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.menu-item-card:hover {
  border-color: #0d6efd;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.menu-item-card.selected {
  border-color: #0d6efd;
  background-color: #f0f7ff;
}

.menu-item-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.menu-item-price {
  color: #dc3545;
  font-weight: 600;
}

/* 購物車樣式 */
.cart-container {
  position: sticky;
  top: 1rem;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid #dee2e6;
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-summary {
  background-color: #f8f9fa;
  padding: 1rem;
  border-radius: 0.5rem;
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.cart-summary-total {
  font-weight: 700;
  font-size: 1.25rem;
  color: #dc3545;
  border-top: 2px solid #dee2e6;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

/* 價格標籤 */
.price-tag {
  font-size: 1.25rem;
  font-weight: 700;
  color: #dc3545;
}

.price-original {
  text-decoration: line-through;
  color: #6c757d;
  font-size: 0.9rem;
  margin-right: 0.5rem;
}

/* 數量選擇器 */
.quantity-selector {
  display: inline-flex;
  align-items: center;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
}

.quantity-selector button {
  border: none;
  background: none;
  padding: 0.25rem 0.5rem;
  font-size: 1rem;
  cursor: pointer;
}

.quantity-selector button:hover {
  background-color: #e9ecef;
}

.quantity-selector input {
  width: 3rem;
  text-align: center;
  border: none;
  border-left: 1px solid #dee2e6;
  border-right: 1px solid #dee2e6;
}

/* 訂單狀態徽章 */
.status-badge {
  padding: 0.35rem 0.65rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-pending {
  background-color: #ffc107;
  color: #000;
}

.status-confirmed {
  background-color: #0dcaf0;
  color: #000;
}

.status-preparing {
  background-color: #0d6efd;
  color: #fff;
}

.status-ready {
  background-color: #198754;
  color: #fff;
}

.status-completed {
  background-color: #6c757d;
  color: #fff;
}

.status-cancelled {
  background-color: #dc3545;
  color: #fff;
}

/* 付款狀態 */
.payment-pending {
  color: #ffc107;
}

.payment-paid {
  color: #198754;
}

.payment-failed {
  color: #dc3545;
}

/* ========================================
   表單驗證樣式 (T156)
   ======================================== */

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #dc3545;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid,
.form-select.is-valid {
  border-color: #198754;
  padding-right: calc(1.5em + 0.75rem);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right calc(0.375em + 0.1875rem) center;
  background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: #dc3545;
}

.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback,
.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback {
  display: block;
}

.valid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: #198754;
}

.form-control.is-valid ~ .valid-feedback,
.form-select.is-valid ~ .valid-feedback,
.was-validated .form-control:valid ~ .valid-feedback,
.was-validated .form-select:valid ~ .valid-feedback {
  display: block;
}

/* ========================================
   載入動畫
   ======================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0d6efd;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   管理後台樣式
   ======================================== */

.admin-sidebar {
  min-height: calc(100vh - 120px);
  background-color: #f8f9fa;
  padding: 1rem;
  border-right: 1px solid #dee2e6;
}

.admin-sidebar .nav-link {
  color: #495057;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 0.25rem;
}

.admin-sidebar .nav-link:hover {
  background-color: #e9ecef;
}

.admin-sidebar .nav-link.active {
  background-color: #0d6efd;
  color: #fff;
}

.admin-card {
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 0.5rem;
}

.admin-card .card-header {
  background-color: #fff;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
}

/* 統計卡片 */
.stat-card {
  padding: 1.5rem;
  border-radius: 0.5rem;
  color: #fff;
}

.stat-card.primary {
  background: linear-gradient(135deg, #0d6efd, #0b5ed7);
}

.stat-card.success {
  background: linear-gradient(135deg, #198754, #157347);
}

.stat-card.warning {
  background: linear-gradient(135deg, #ffc107, #e0a800);
  color: #000;
}

.stat-card.danger {
  background: linear-gradient(135deg, #dc3545, #bb2d3b);
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
}

.stat-card-label {
  opacity: 0.8;
  font-size: 0.9rem;
}

/* ========================================
   列印樣式
   ======================================== */

@media print {
  .navbar,
  .footer,
  .btn,
  .no-print {
    display: none !important;
  }

  body {
    margin: 0;
    padding: 1rem;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .card {
    border: 1px solid #000;
    box-shadow: none;
  }
}
