/* Define main colors and basic styles using CSS Variables for a modern look */
:root {
  --primary-color: #5d3fd3;
  /* Medium Slate Blue - a bit brighter */
  --secondary-color: #8a2be2;
  /* Blue Violet */
  --accent-color: #ffd700;
  /* Gold */
  --background-color: #f8f9fa;
  /* Off-white */
  --card-background: #ffffff;
  --text-color: #212529;
  --white: #fff;
  --light-gray: #e9ecef;
  --border-radius: 12px;
  --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --pending-color: #ffc107;
  /* Yellow for pending */
  --approved-color: #28a745;
  /* Green for approved */
  --rejected-color: #dc3545;
  /* 
  Red for rejected */
}
#datetime-group { display: none !important; }

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

body {
  font-family: "Sarabun", sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

/* Styles for the new navigation bar */
.navbar {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--box-shadow);
  z-index: 100;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--white);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--white);
  text-decoration: none;
  position: relative;
  padding: 0.5rem 0;
  transition: color 0.3s;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: width 0.3s;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link.active {
  color: var(--accent-color);
}

.main-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  min-height: calc(100vh - 72px);
  /* Adjust based on navbar height */
}

.container {
  display: flex;
  width: 100%;
  max-width: 1200px;
  background-color: var(--card-background);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  overflow: hidden;
}

/* Styles for the sidebar */
.sidebar {
  width: 300px;
  padding: 2rem;
  background-color: var(--primary-color);
  color: var(--white);
  display: flex;
  flex-direction: column;
  gap: 2rem;
  border-top-left-radius: var(--border-radius);
  border-bottom-left-radius: var(--border-radius);
}

.sidebar h2 {
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding-bottom: 0.5rem;
}

.sidebar ol {
  list-style: none;
  padding-left: 0;
}

.sidebar li {
  counter-increment: list-counter;
  margin-bottom: 1rem;
  position: relative;
  padding-left: 2rem;
}

.sidebar li::before {
  content: counter(list-counter);
  background-color: var(--white);
  color: var(--primary-color);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
}

.tip-box {
  background-color: rgba(255, 255, 255, 0.1);
  border-left: 5px solid var(--accent-color);
  padding: 1rem;
  border-radius: 8px;
}

.tip-box h3 {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
}

.tip-box h3::before {
  content: "💡";
}

.tip-box p {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Styles for the main content sections */
.main-content {
  flex-grow: 1;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section {
  display: none;
  /* Initially hide all sections */
  flex-direction: column;
  width: 100%;
}

.section.active {
  display: flex;
}

.header-section {
  background-image: linear-gradient(
    135deg,
    var(--secondary-color),
    var(--primary-color)
  );
  color: var(--white);
  padding: 2.5rem 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  text-align: center;
}

.header-section h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.header-section h1::before {
  content: "🚀";
  font-size: 2rem;
}

.header-section p {
  font-size: 1rem;
  opacity: 0.9;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  /* Increased gap for better spacing */
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  background: var(--white);
}

/* Styles for creation modes */
.mode-selection-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* Gap between the heading and the cards */
}

.mode-selection-container h2 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
}

.mode-selection {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  /* Center the mode cards */
}

.mode-card {
  padding: 2rem 1.5rem;
  background-color: var(--light-gray);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-basis: 220px;
  /* Use a fixed width basis to make them narrower */
  max-width: 250px;
  /* Ensure they don't get too wide on larger screens */
}

.mode-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.mode-card.selected {
  border-color: var(--primary-color);
  background-color: rgba(93, 63, 211, 0.1);
  box-shadow: 0 0 10px rgba(93, 63, 211, 0.2);
}

.mode-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.mode-card p {
  font-size: 0.9rem;
  color: #666;
}

.mode-card .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.mode-card.ai-mode .icon {
  content: "🤖";
}

.mode-card.hybrid-mode .icon {
  content: "⚡️";
}

/* Styles for input fields */
input[type="text"],
input[type="datetime-local"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: "Sarabun", sans-serif;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input[type="datetime-local"] {
  appearance: none;
  -webkit-appearance: none;
}

/* Add styling for disabled inputs */
input:disabled {
  background-color: var(--light-gray);
  cursor: not-allowed;
  color: #888;
}

input[type="text"]:focus,
input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 5px rgba(93, 63, 211, 0.2);
}

.input-group {
  display: flex;
  gap: 1.5rem;
}

.input-group > .form-group {
  flex: 1;
}

/* Styles for date input with icon */
.datetime-input-container {
  position: relative;
}

.datetime-input-container .date-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #888;
}

/* Styles for the button group */
.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* Styles for the buttons */
.button-group button {
  flex: 1;
  /* This makes all buttons inside the group take equal width */
  padding: 1rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.submit-button {
  background-color: var(--primary-color);
  color: var(--white);
}

.submit-button:hover:not(:disabled) {
  background-color: var(--secondary-color);
  transform: translateY(-2px);
}

.clear-button {
  background-color: #ddd;
  color: #666;
}

.clear-button:hover:not(:disabled) {
  background-color: #ccc;
  transform: translateY(-2px);
}

.try-again-button {
  background-color: var(--accent-color);
  color: var(--primary-color);
}

.try-again-button:hover:not(:disabled) {
  background-color: #ffea8d;
  transform: translateY(-1px);
}

/* Styles for a disabled button */
.button-group button:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  color: #888;
}

.submit-button::before {
  content: "🚀";
}

.clear-button::before {
  content: "🗑️";
}

.footer-message {
  text-align: center;
  font-size: 0.9rem;
  color: #666;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.footer-message::before {
  content: "💡";
}

/* Styles for the progress bar section */
.progress-section {
  display: none;
  /* Initially hide the progress section */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  margin-top: 1.5rem;
  background-color: var(--light-gray);
  text-align: center;
}

.progress-section.visible {
  display: flex;
  /* Show the progress section */
}

.progress-bar-container {
  width: 80%;
  height: 10px;
  background-color: #ddd;
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  /* Start with 0 width */
  background-image: linear-gradient(
    to right,
    var(--secondary-color),
    var(--primary-color)
  );
  transition: width 0.5s ease;
}

.progress-text {
  font-weight: 600;
  color: var(--primary-color);
}

/* Modal styles for confirmation dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s, opacity 0.3s;
  z-index: 1000;
}

.modal-overlay.visible {
  visibility: visible;
  opacity: 1;
}

.modal-content {
  background-color: var(--white);
  padding: 2rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  width: 90%;
  max-width: 400px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.visible .modal-content {
  transform: scale(1);
}

.modal-content h3 {
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.modal-content .modal-buttons {
  display: flex;
  justify-content: space-around;
  margin-top: 1.5rem;
}

.modal-buttons button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.3s;
}

.modal-buttons .ok-button {
  background-color: var(--accent-color);
  color: var(--primary-color);
}

.modal-buttons .ok-button:hover {
  background-color: #ffea8d;
  transform: translateY(-1px);
}

.modal-buttons .cancel-button {
  background-color: #ddd;
  color: #666;
}

.modal-buttons .cancel-button:hover {
  background-color: #ccc;
  transform: translateY(-1px);
}

/* Styles for the Post List section and History section, now they share a similar layout */
.post-list-section,
.history-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-list-table,
.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.post-list-table th,
.history-table th,
.post-list-table td,
.history-table td {
  text-align: left;
  padding: 1rem;
  border-bottom: 1px solid #ddd;
}



.post-list-table th,
.history-table th {
  background-color: var(--light-gray);
  font-weight: 700;
  color: var(--primary-color);
}

.post-list-table tr:hover,
.history-table tr:hover {
  background-color: #f5f5f5;
}

/* Styles for the status dropdown */
.status-dropdown {
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-family: "Sarabun", sans-serif;
  font-size: 0.9rem;
  background-color: var(--white);
  appearance: none;
  cursor: pointer;
  width: 150px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16"><path d="M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592c.859 0 1.319 1.013.753 1.658l-4.796 5.482a1 1 0 0 1-1.506 0z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

/* Styles for the non-editable status badge */
.status-badge {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-block;
  text-align: center;
}

/* Set color for options based on value */
.status-dropdown option[value="pending"],
.status-badge.status-pending {
  color: var(--pending-color);
  font-weight: 600;
}

.status-dropdown option[value="approved"],
.status-badge.status-approved {
  color: var(--approved-color);
  font-weight: 600;
}

.status-dropdown option[value="rejected"],
.status-badge.status-rejected {
  color: var(--rejected-color);
  font-weight: 600;
}

/* Styles for filter buttons */
.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.filter-btn.active {
  background-color: var(--primary-color);
  color: var(--white);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Styles for action buttons */
.action-btn {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 0 0.2rem;
}

.edit-btn {
  background-color: #007bff;
  color: white;
}

.edit-btn:hover {
  background-color: #0056b3;
  transform: translateY(-1px);
}

.delete-btn {
  background-color: #dc3545;
  color: white;
}

.delete-btn:hover {
  background-color: #c82333;
  transform: translateY(-1px);
}

/* Styles for cancel edit button */
.cancel-edit-button {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cancel-edit-button:hover {
  background-color: #545b62;
  transform: translateY(-1px);
}

/* Web management styles */
.web-management-section {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.web-management-section h3 {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--accent-color);
}

.web-list {
  margin-bottom: 1rem;
}

.web-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.web-item:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.web-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.web-name {
  font-weight: 600;
  color: var(--white);
}

.web-description {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.web-actions {
  display: flex !important;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.web-edit-btn,
.web-delete-btn {
  background: none;
  border: none;
  color: var(--white);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-size: 14px;
}

.web-edit-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--accent-color);
}

.web-delete-btn:hover {
  background-color: rgba(220, 53, 69, 0.3);
  color: #ff6b6b;
}

.add-web-btn {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
}

.add-web-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: var(--accent-color);
}

.add-web-btn i {
  margin-right: 0.5rem;
}

/* Web modal styles */
#web-modal .modal-content {
  max-width: 500px;
}

#web-modal .form-group {
  margin-bottom: 1rem;
}

#web-modal label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-color);
}

#web-modal input,
#web-modal textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--light-gray);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

#web-modal input:focus,
#web-modal textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

#web-modal textarea {
  resize: vertical;
  min-height: 80px;
}

/* Filter container styles */
.filter-container {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* === Post List Table Style === */

/* ปรับสไตล์โดยรวมของตาราง */
.table {
    border-collapse: collapse; /* ทำให้เส้นขอบรวมเป็นเส้นเดียว */
    width: 100%;
    background-color: #fff;
    border: 1px solid #dee2e6; /* เปลี่ยนสีเส้นขอบให้อ่อนลง */
    font-family: 'Sarabun', sans-serif; /* ใช้ฟอนต์ Sarabun */
}

/* สไตล์หัวตาราง (Header) */
.table thead th {
    background-color: #f8f9fa; /* สีพื้นหลังหัวตาราง */
    text-align: left; /* จัดข้อความชิดซ้าย */
    padding: 12px 10px; /* เพิ่มระยะห่างภายในช่อง */
    border-bottom: 2px solid #dee2e6;
    font-weight: 700; /* ทำให้ตัวหนาขึ้น */
}

/* สไตล์ข้อมูลในตาราง (Body) */
.table tbody th {
    padding: 12px 10px;
    border-top: 1px solid #e9ecef; /* ปรับสีเส้นคั่นแถวให้อ่อนลง */
    font-weight: 400; /* ทำให้ตัวอักษรเป็นน้ำหนักปกติ */
    text-align: left;
    vertical-align: middle; /* จัดให้อยู่กึ่งกลางแนวตั้ง */
}

/* ทำให้ตารางมีสีสลับแถว (Zebra Striping) */
.table tbody tr:nth-child(even) {
    background-color: #f8f9fa; /* สีพื้นหลังสำหรับแถวคู่ */
}

/* สไตล์เมื่อนำเมาส์ไปชี้ที่แถว */
.table tbody tr:hover {
    background-color: #e9ecef; /* สีพื้นหลังเมื่อเมาส์ชี้ */
}

/* สไตล์สำหรับลิงก์ในตาราง */
.table a {
    color: #007bff;
    text-decoration: none;
    font-weight: 600;
}

.table a:hover {
    text-decoration: underline;
}

/* Responsive styles */
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .navbar {
    flex-direction: column;
    gap: 1rem;
  }

  .container {
    flex-direction: column;
    border-radius: var(--border-radius);
  }

  .sidebar {
    width: 100%;
    border-bottom-left-radius: 0;
    border-top-right-radius: var(--border-radius);
    text-align: center;
  }

  .sidebar h2 {
    border-bottom: none;
  }

  .sidebar ol {
    text-align: left;
  }

  .sidebar li {
    padding-left: 0;
  }

  .sidebar li::before {
    position: static;
    margin-right: 0.5rem;
  }

  .main-content {
    padding: 1.5rem;
  }

  .header-section h1 {
    font-size: 1.8rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  .mode-selection {
    flex-direction: column;
  }

  .input-group {
    flex-direction: column;
  }

  .button-group button {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .post-list-table,
  .history-table {
    font-size: 0.9rem;
  }
}
