@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

:root {
  /* เปลี่ยนเป็นโทนสีฟ้าเรียบๆ สวยๆ */
  --background: #f0f7ff; /* พื้นหลังหลักเป็นสีฟ้าอ่อนมาก */
  --foreground: #1e3a5f; /* ตัวอักษรหลักเป็นสีน้ำเงินเข้ม */
  --card: #ffffff; /* การ์ดเป็นสีขาว */
  --card-foreground: #1e3a5f;
  --popover: #ffffff;
  --popover-foreground: #1e3a5f;
  --primary: #3b82f6; /* สีหลักเป็นสีน้ำเงินสด */
  --primary-foreground: #ffffff;
  --secondary: #93c5fd; /* สีรองเป็นสีฟ้าอ่อน */
  --secondary-foreground: #1e3a5f;
  --muted: #dbeafe; /* สีอ่อนเป็นสีฟ้าอ่อนมาก */
  --muted-foreground: #64748b;
  --accent: #60a5fa; /* สีเน้นเป็นสีฟ้า */
  --accent-foreground: #ffffff;
  --destructive: #e74c3c;
  --destructive-foreground: #ffffff;
  --border: rgba(59, 130, 246, 0.15); /* ขอบโปร่งใสโทนฟ้า */
  --input: rgba(255, 255, 255, 0.9); /* ช่องใส่ข้อมูลโปร่งใส */
  --ring: #3b82f6; /* วงแหวนโฟกัสสีน้ำเงิน */
  --radius: 0.5rem;
  --success: #27ae60;
  --warning: #f39c12;
  --info: #3498db;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* เปลี่ยนเป็นไล่เฉดสีฟ้า */
  background: linear-gradient(135deg, #f0f7ff 0%, #dbeafe 50%, #bfdbfe 100%);
  color: var(--foreground);
  min-height: 100vh;
  line-height: 1.6;
}

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

.sidebar {
  width: 280px;
  /* เปลี่ยนพื้นหลัง sidebar เป็นสีขาวโปร่งใสพร้อม hint สีฟ้า */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.main-content {
  flex: 1;
  margin-left: 280px;
  padding: 2rem;
  max-width: calc(100vw - 280px);
}

.logo {
  padding: 0 2rem 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--foreground);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-menu {
  list-style: none;
  padding: 0 1rem;
}

.nav-item {
  margin-bottom: 0.5rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--foreground);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
  /* เปลี่ยนสี hover เป็นสีฟ้าอ่อน */
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  transform: translateX(5px);
}

.nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

/* Cards */
.card {
  /* เปลี่ยนพื้นหลังการ์ดเป็นสีขาวโปร่งใส */
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.card-header {
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.card-description {
  color: var(--foreground);
  opacity: 0.8;
  font-size: 0.875rem;
}

/* Search Section */
.search-section {
  max-width: 600px;
  margin: 0 auto 3rem;
}

.search-box {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.search-input {
  flex: 1;
  padding: 1rem;
  /* เปลี่ยนพื้นหลัง input เป็นสีขาวพร้อม hint สีฟ้า */
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--ring);
  /* เปลี่ยนสี shadow focus เป็นสีฟ้า */
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-input::placeholder {
  color: var(--foreground);
  opacity: 0.7;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  transform: translateY(-2px);
  /* เปลี่ยนสี shadow hover เป็นสีน้ำเงิน */
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.35);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(147, 197, 253, 0.4);
}

.btn-success {
  background: var(--success);
  color: var(--foreground);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-destructive:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3);
}

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

/* Coupon Display */
.coupon-card {
  /* เปลี่ยนพื้นหลังเป็นสีขาวพร้อม hint สีฟ้า */
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);
}

.coupon-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.shop-logo {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(59, 130, 246, 0.25);
}

.coupon-info h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.coupon-info p {
  color: var(--foreground);
  opacity: 0.8;
}

.coupon-image {
  width: 100%;
  max-width: 300px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.code-display {
  /* เปลี่ยนพื้นหลังและขอบเป็นโทนฟ้า */
  background: rgba(219, 234, 254, 0.6);
  border: 2px dashed rgba(59, 130, 246, 0.4);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.1em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  margin: 1rem 0;
}

.status.available {
  background: rgba(39, 174, 96, 0.1);
  color: var(--success);
  border: 1px solid rgba(39, 174, 96, 0.3);
}

.status.used {
  background: rgba(231, 76, 60, 0.2);
  color: var(--destructive);
  border: 1px solid rgba(231, 76, 60, 0.4);
}

/* QR Section */
.qr-section {
  margin-top: 2rem;
  padding: 2rem;
  background: rgba(219, 234, 254, 0.4);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.qr-section h4 {
  margin-bottom: 1.5rem;
  color: var(--foreground);
}

.qr-code,
.barcode {
  margin: 1rem 0;
}

.qr-code img,
.barcode img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

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

.stat-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.stat-label {
  color: var(--foreground);
  opacity: 0.8;
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--foreground);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius);
  color: var(--foreground);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

/* Tables */
.table-container {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
}

.table th {
  background: rgba(219, 234, 254, 0.5);
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.875rem;
}

.table td {
  color: var(--foreground);
  opacity: 0.9;
  font-size: 0.875rem;
}

.table tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

.table tr:last-child td {
  border-bottom: none;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.category-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
}

.category-card:hover {
  border-color: var(--ring);
  transform: translateY(-5px);
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.2);
}

.category-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.category-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.category-info h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}

.category-info p {
  color: var(--foreground);
  opacity: 0.8;
  font-size: 0.875rem;
}

.category-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid rgba(59, 130, 246, 0.15);
}

.category-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Error and Success Messages */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
  backdrop-filter: blur(10px);
}

.alert-error {
  background: rgba(231, 76, 60, 0.1);
  color: var(--destructive);
  border-color: rgba(231, 76, 60, 0.3);
}

.alert-success {
  background: rgba(39, 174, 96, 0.1);
  color: var(--success);
  border-color: rgba(39, 174, 96, 0.3);
}

.alert-info {
  background: rgba(52, 152, 219, 0.1);
  color: var(--info);
  border-color: rgba(52, 152, 219, 0.3);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--foreground);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(59, 130, 246, 0.25);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Page Sections */
.page-section {
  display: none;
}

.page-section.active {
  display: block;
}

.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.5rem;
}

.page-description {
  color: var(--foreground);
  opacity: 0.8;
  font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    max-width: 100vw;
    padding: 1rem;
  }

  .search-box {
    flex-direction: column;
  }

  .coupon-header {
    flex-direction: column;
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .table-container {
    overflow-x: auto;
  }
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 101;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius);
  padding: 0.5rem;
  color: var(--foreground);
  cursor: pointer;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }
}

/* Utilities */
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.mb-4 {
  margin-bottom: 1rem;
}
.mb-6 {
  margin-bottom: 1.5rem;
}
.mt-4 {
  margin-top: 1rem;
}
.mt-6 {
  margin-top: 1.5rem;
}
.hidden {
  display: none;
}
.flex {
  display: flex;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-4 {
  gap: 1rem;
}
