/**
 * Bleu Cafe 訂位 Widget 樣式
 * 配色方案：
 * - Primary: #003D52 (深藍綠 - 按鈕、標題)
 * - Secondary: #83968B (灰綠 - 次要元素)
 * - Accent: #BCDBE4 (淺藍 - 選中狀態)
 * - Background: #FFFFFF (白色背景)
 */

/* CSS 變數 */
:root {
  --color-primary: #003D52;
  --color-primary-hover: #00546e;
  --color-secondary: #83968B;
  --color-accent: #BCDBE4;
  --color-background: #FFFFFF;
  --color-text: #003D52;
  --color-text-light: #83968B;
  --color-error: #c33;
  --color-warning: #f59e0b;
  --color-success: #10b981;
}

/* Material Symbols styling */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}

.reservation-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  max-width: 600px;
  margin: 0 auto;
  background: var(--color-background);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 61, 82, 0.1);
  overflow: hidden;
}

/* ====== Header ====== */
.widget-header {
  background: var(--color-primary);
  color: #fff;
  padding: 32px 24px;
  text-align: center;
}

.widget-title {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px 0;
  letter-spacing: 1px;
}

.widget-subtitle {
  font-size: 16px;
  margin: 0;
  opacity: 0.9;
  letter-spacing: 2px;
}

/* ====== Body ====== */
.widget-body {
  padding: 32px 24px;
}

.step-section {
  margin-bottom: 32px;
}

.step-section:last-child {
  margin-bottom: 0;
}

.step-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-secondary);
}

/* ====== Date Buttons ====== */
.date-scroll-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  background: #f9f9f9;
}

.date-month-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-primary);
  margin: 16px 0 12px 0;
  padding: 8px 12px;
  background: var(--color-accent);
  border-radius: 8px;
  text-align: center;
}

.date-month-header:first-child {
  margin-top: 0;
}

.date-month-group {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.date-month-group:last-child {
  margin-bottom: 0;
}

.date-buttons {
  display: block;
}

.date-button {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.date-button:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(188, 219, 228, 0.4);
}

.date-button.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 61, 82, 0.3);
}

.date-weekday {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.date-day {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 2px;
}

/* ====== Time Slots ====== */
.timeslot-info {
  padding: 16px;
  background: #f9f9f9;
  border-radius: 8px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

.timeslot-category {
  margin-bottom: 20px;
}

.timeslot-category:last-child {
  margin-bottom: 0;
}

.category-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 12px 0;
  padding-left: 12px;
  border-left: 3px solid var(--color-secondary);
}

.timeslot-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
}

.timeslot-button {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
  font-weight: 500;
  color: #333;
  min-height: 44px;
}

.timeslot-button:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-primary);
  transform: translateY(-2px);
}

.timeslot-button.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 61, 82, 0.3);
}

.timeslot-button.unavailable {
  background: #f5f5f5;
  border-color: #e0e0e0;
  color: #999;
  cursor: not-allowed;
  opacity: 0.6;
  position: relative;
}

.timeslot-button.unavailable:hover {
  transform: none;
  background: #f5f5f5;
  border-color: #e0e0e0;
  color: #999;
}

/* Status indicators for unavailable slots */
.timeslot-button.unavailable::after {
  content: '已額滿';
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 10px;
  color: #999;
  font-weight: 500;
}

.timeslot-button.blocked {
  background: #fff9f0;
  border-color: #fbbf24;
  color: #92400e;
  cursor: not-allowed;
  opacity: 0.8;
}

.timeslot-button.blocked::after {
  content: '暫停預約';
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 10px;
  color: #92400e;
  font-weight: 500;
}

.timeslot-button.blocked:hover {
  transform: none;
  background: #fff9f0;
}

/* Holiday indicator */
.holiday-notice {
  background: #fef3c7;
  border: 2px solid #fbbf24;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  color: #92400e;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.holiday-notice .material-symbols-outlined {
  font-size: 28px;
  color: #f59e0b;
}

/* ====== Form ====== */
.reservation-form {
  max-width: 100%;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(188, 219, 228, 0.2);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.btn-submit {
  width: 100%;
  padding: 16px 32px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 61, 82, 0.3);
  background: var(--color-primary-hover);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ====== Confirmation ====== */
.confirmation-message {
  text-align: center;
  padding: 40px 20px;
}

.confirmation-icon {
  width: 80px;
  height: 80px;
  line-height: 80px;
  margin: 0 auto 20px;
  background: #4caf50;
  color: #fff;
  border-radius: 50%;
  font-size: 48px;
  font-weight: bold;
  animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.confirmation-message h3 {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0 0 12px 0;
}

.confirmation-message p {
  font-size: 16px;
  color: #666;
  margin: 8px 0;
}

.confirmation-detail {
  font-size: 14px !important;
  color: #999 !important;
}

.btn-new-reservation {
  margin-top: 24px;
  padding: 12px 32px;
  background: #fff;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-new-reservation:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ====== Responsive Design ====== */

/* Tablet */
@media (max-width: 768px) {
  .reservation-widget {
    border-radius: 0;
    box-shadow: none;
  }

  .widget-header {
    padding: 24px 20px;
  }

  .widget-title {
    font-size: 24px;
  }

  .widget-subtitle {
    font-size: 14px;
  }

  .widget-body {
    padding: 24px 20px;
  }

  .step-title {
    font-size: 16px;
  }

  .date-month-group {
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }

  .date-button {
    padding: 6px 4px;
    min-height: 44px;
  }

  .date-day {
    font-size: 16px;
  }

  .date-weekday {
    font-size: 10px;
  }

  .timeslot-buttons {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .timeslot-button {
    padding: 10px 6px;
    font-size: 14px;
    min-height: 44px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* 防止 iOS 自動縮放 */
  }
}

/* Mobile */
@media (max-width: 480px) {
  .widget-body {
    padding: 20px 16px;
  }

  .date-month-group {
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }

  .date-button {
    padding: 6px 2px;
    min-height: 44px;
  }

  .date-day {
    font-size: 14px;
  }

  .date-weekday {
    font-size: 9px;
  }

  .timeslot-buttons {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .timeslot-button {
    padding: 10px 6px;
    font-size: 14px;
    min-height: 44px;
  }

  .btn-submit {
    padding: 14px 24px;
    font-size: 16px;
  }
}

/* ====== Inline Selectors ====== */
.inline-selectors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.inline-selector-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-selector-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
}

.inline-select {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.inline-select:hover:not(:disabled) {
  border-color: var(--color-accent);
}

.inline-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(188, 219, 228, 0.2);
}

.inline-select:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

.date-selector-wrapper {
  position: relative;
}

.date-select {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  background: #fff;
}

.dropdown-arrow {
  font-size: 12px;
  color: #666;
}

/* ====== Calendar Popup ====== */
.calendar-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.calendar-popup-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.calendar-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.calendar-month-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-primary);
  flex: 1;
  text-align: center;
}

.calendar-nav-btn {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
  color: var(--color-primary);
}

.calendar-nav-btn:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.calendar-grid {
  width: 100%;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  text-align: center;
  font-weight: 600;
  color: var(--color-text-light);
  font-size: 14px;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #e0e0e0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fff;
  position: relative;
}

.calendar-day:hover:not(.disabled):not(.other-month) {
  background: var(--color-accent);
  border-color: var(--color-accent);
  transform: scale(1.1);
}

.calendar-day.selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.calendar-day.today:not(.selected) {
  border-color: var(--color-primary);
  font-weight: 600;
}

.calendar-day.disabled {
  background: #f5f5f5;
  color: #ccc;
  cursor: not-allowed;
  border-color: #f0f0f0;
}

.calendar-day.disabled:hover {
  transform: none;
}

.calendar-day.holiday {
  background: #fff3cd;
  border-color: #ffc107;
}

.calendar-day.holiday .calendar-day-label {
  color: #856404;
}

.calendar-day.other-month {
  opacity: 0.3;
  cursor: default;
  border-color: transparent;
}

.calendar-day.other-month:hover {
  transform: none;
  background: #fff;
}

.calendar-day-number {
  font-size: 14px;
  font-weight: 500;
}

.calendar-day-label {
  font-size: 9px;
  position: absolute;
  bottom: 2px;
  color: #666;
}

/* Responsive - Inline Selectors */
@media (max-width: 768px) {
  .inline-selectors {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .calendar-popup-content {
    padding: 16px;
    max-width: 350px;
  }

  .calendar-nav-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .calendar-month-title {
    font-size: 16px;
  }
}

/* ====== 輔助樣式 ====== */
* {
  box-sizing: border-box;
}

button {
  font-family: inherit;
}

button:focus {
  outline: none;
}

/* ====== 骨架屏載入動畫 ====== */
.skeleton {
  animation: skeleton-loading 1s linear infinite alternate;
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-line {
  height: 20px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.skeleton-box {
  border-radius: 8px;
}

.widget-skeleton {
  padding: 32px 24px;
}

@media (max-width: 768px) {
  .widget-skeleton {
    padding: 24px 20px;
  }
  
  .widget-skeleton .selector-skeleton {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .widget-skeleton {
    padding: 20px 16px;
  }
}

/* ====== Enhanced Mobile Design (Apple-style) ====== */

@media (max-width: 768px) {
  /* Widget container improvements */
  .reservation-widget {
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
  }

  .widget-body {
    padding: 24px 20px;
  }

  /* Step title improvements */
  .step-title {
    font-size: 20px;
    margin-bottom: 20px;
  }

  /* Inline selectors - stack vertically on mobile */
  .inline-selectors {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .inline-selector-group {
    width: 100%;
  }

  .inline-selector-group label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
  }

  .inline-select {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 12px;
  }

  /* Date selector button */
  .date-select {
    width: 100%;
    text-align: left;
    justify-content: space-between;
  }

  /* Calendar popup improvements */
  .calendar-popup {
    padding: 0;
  }

  .calendar-popup-content {
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
    width: 100%;
  }

  .calendar-popup-header {
    padding: 20px;
  }

  .calendar-month-title {
    font-size: 20px;
  }

  .calendar-nav-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 20px;
  }

  /* Calendar grid improvements */
  .calendar-weekdays {
    padding: 12px 8px;
  }

  .calendar-weekdays > div {
    font-size: 14px;
    font-weight: 600;
  }

  .calendar-days-grid {
    padding: 0 8px 20px;
  }

  .calendar-day {
    aspect-ratio: 1;
    min-height: 60px;
    padding: 8px 4px;
    border-radius: 12px;
  }

  .calendar-day-number {
    font-size: 16px;
    font-weight: 600;
  }

  .calendar-day-label {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
  }

  /* Form improvements */
  .form-group {
    margin-bottom: 20px;
  }

  .form-group label {
    font-size: 15px;
    font-weight: 600;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
  }

  .form-group textarea {
    min-height: 120px;
  }

  /* Submit button */
  .btn-submit {
    width: 100%;
    min-height: 52px;
    font-size: 17px;
    font-weight: 600;
    border-radius: 12px;
    padding: 14px 24px;
  }

  /* Confirmation message */
  .confirmation-message {
    padding: 32px 20px;
    text-align: center;
  }

  .confirmation-icon {
    font-size: 64px;
    margin-bottom: 20px;
  }

  .confirmation-message h3 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  .confirmation-message p {
    font-size: 16px;
    line-height: 1.6;
  }

  .btn-new-reservation {
    margin-top: 24px;
    min-height: 48px;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 32px;
    border-radius: 12px;
  }

  /* Time select dropdown improvements */
  select#timeSelect {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23003D52' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
  }

  /* Better touch feedback */
  .inline-select:active,
  .btn:active,
  .calendar-day:active:not(.disabled) {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  /* Improve spacing */
  .step-section {
    margin-bottom: 32px;
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  .widget-body {
    padding: 20px 16px;
  }

  .step-title {
    font-size: 18px;
  }

  .calendar-day {
    min-height: 50px;
    padding: 6px 2px;
  }

  .calendar-day-number {
    font-size: 14px;
  }

  .calendar-day-label {
    font-size: 9px;
    padding: 1px 4px;
  }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
  .calendar-popup-content {
    max-height: 90vh;
    overflow-y: auto;
  }

  .calendar-day {
    min-height: 50px;
  }
}

/* Touch device optimizations */
@media (pointer: coarse) {
  /* Ensure all interactive elements are at least 44x44px */
  .inline-select,
  .btn,
  .calendar-day:not(.disabled),
  .calendar-nav-btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Add subtle active states for better feedback */
  .inline-select:active,
  .btn:active,
  .calendar-day:active:not(.disabled) {
    opacity: 0.8;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .timeslot-button {
    border-width: 2px;
  }

  .timeslot-button.unavailable,
  .timeslot-button.blocked {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
