/* style.css */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #f2994a; /* สีส้มทอง */
    --secondary-color: #3a2d21; /* สีน้ำตาลเข้ม */
    --background-color: #fdf6e3; /* สีพื้นหลังคล้ายกระดาษเก่า */
    --text-color: #4a3f35;
    --card-bg: #fffbf2;
    --border-color: #d1c0a8;
    --shadow-color: rgba(0, 0, 0, 0.15);
    --header-bg: #2c2118;

    /* Reward Tag Colors - Adjusted for more variety */
    --reward-exp-bg: #c3e6cb; /* Soft Green */
    --reward-exp-text: #1b5e20;
    --reward-int-bg: #a7d9f2; /* Sky Blue */
    --reward-int-text: #0d47a1;
    --reward-drachma-bg: #ffe082; /* Warm Gold */
    --reward-drachma-text: #e65100;
    --reward-honor-bg: #bdbdbd; /* Medium Grey */
    --reward-honor-text: #424242;
    --reward-item-bg: #d7ccc8; /* Light Brown/Stone for Items */
    --reward-item-text: #4e342e; /* Dark Brown for Items */
    --reward-default-bg: #f0f0f0; /* Very light grey for default */
    --reward-default-text: #616161; /* Medium grey for default */

    /* New: God Favor Specific Colors */
    --reward-favor-hades-bg: #212529; /* Darker, more imposing Black for Hades */
    --reward-favor-hades-text: #f8f9fa;
    --reward-favor-ares-bg: #dc3545; /* Red for Ares */
    --reward-favor-ares-text: #ffffff;
    --reward-favor-nike-bg: #ffc107; /* Yellow/Gold for Nike */
    --reward-favor-nike-text: #212529;
    --reward-favor-persephone-bg: #fd7e14; /* Orange for Persephone */
    --reward-favor-persephone-text: #ffffff;
    --reward-favor-artemis-bg: #6f42c1; /* Purple for Artemis */
    --reward-favor-artemis-text: #ffffff;
    --reward-favor-hephaestus-bg: #990000; /* Grey/Metallic for Hephaestus */
    --reward-favor-hephaestus-text: #ffffff;
    --reward-favor-apollo-bg: #ffc107; /* Bright Yellow for Apollo */
    --reward-favor-apollo-text: #212529;
    --reward-favor-athena-bg: #007bff; /* Blue for Athena */
    --reward-favor-athena-text: #ffffff;
    --reward-favor-dionysus-bg: #6610f2; /* Dark Purple for Dionysus */
    --reward-favor-dionysus-text: #ffffff;
    --reward-favor-aphrodite-bg: #f8bbd0; /* Soft Pink for Aphrodite */
    --reward-favor-aphrodite-text: #ad1457;
    --reward-favor-hecate-bg: #4a148c; /* Deep Purple for Hecate */
    --reward-favor-hecate-text: #ffffff;
    --reward-favor-default-bg: #ffab91; /* Light Coral/Peach for general Favor */
    --reward-favor-default-text: #bf360c; /* Deep Orange for general Favor */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    background-image: url('https://www.transparenttextures.com/patterns/old-wall.png');
    line-height: 1.7;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.main-header {
    background: var(--header-bg);
    color: var(--primary-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 5px solid var(--primary-color);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo {
    height: 60px;
    width: 60px;
    margin-right: 1rem;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.main-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

.main-nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
    padding-bottom: 5px;
}

.main-nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.main-nav a:hover {
    color: var(--primary-color);
}
.main-nav a:hover::after {
    width: 100%;
}


/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
    border-bottom: 2px solid var(--border-color);
}

.page-header h1 {
    font-size: 3rem;
    color: var(--secondary-color);
    font-weight: 700;
    text-shadow: 1px 1px 2px var(--shadow-color);
}
.page-header .btn {
    margin-top: 1rem;
}

/* Quest Board */
.quest-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2.5rem;
}

.quest-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    box-shadow: 0 10px 25px var(--shadow-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.quest-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.quest-card.expired {
    opacity: 0.6;
    background: #e0e0e0;
}
.quest-card.expired .quest-header {
    background: #888;
}

.quest-header {
    background: linear-gradient(135deg, var(--secondary-color), #5a4a3a);
    color: white;
    padding: 1.5rem;
    position: relative;
}
.quest-header h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}
.quest-header .quest-duration {
    font-size: 0.9rem;
    opacity: 0.9;
}
.quest-type-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary-color);
    color: var(--secondary-color);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.quest-taker-info {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
}
.quest-taker-info strong {
    color: var(--secondary-color);
}

.quest-body {
    padding: 1.5rem;
    flex-grow: 1;
}
.quest-body h3 {
    color: var(--secondary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

/* === START: Conditions Styling === */
.quest-conditions {
    margin-bottom: 1.5rem;
}
.quest-conditions ul {
    list-style: none;
    padding-left: 0;
    margin-top: 0.5rem;
}
.quest-conditions li {
    background-color: #f9f4e9;
    padding: 8px 15px;
    border-radius: 5px;
    margin-bottom: 5px;
    border-left: 4px solid var(--primary-color);
    font-size: 0.95rem;
    white-space: normal; /* ให้ข้อความขึ้นบรรทัดใหม่ได้ */
    word-wrap: break-word; /* ให้คำที่ยาวมากตัดคำลงมา */
}

.rewards-content li strong {
    color: var(--secondary-color);
    margin-right: 10px;
    /* white-space: nowrap; */ /* อาจจะต้องลบออก หากหัวข้อ 'เครดิต', 'ไอเท็ม' ยาวแล้วต้องการให้มันตัดคำ */
    white-space: normal; /* เพิ่มบรรทัดนี้หากต้องการให้ชื่อหัวข้อรางวัลตัดคำ */
    word-wrap: break-word; /* เพิ่มบรรทัดนี้หากต้องการให้ชื่อหัวข้อรางวัลตัดคำ */
}
/* === END: Conditions Styling === */

.quest-body .description {
    margin-bottom: 1.5rem;
}

.content-section ol {
    list-style: none;
    counter-reset: step-counter;
    padding-left: 0;
}
.content-section li {
    counter-increment: step-counter;
    margin-bottom: 1rem;
    position: relative;
    padding-left: 40px;
}
.content-section li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
}
.content-section .location-link {
    margin-top: 0.5rem;
}

.rewards-section {
    margin-top: 1.5rem;
}

.content-tabs, .rewards-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.content-tabs button, .rewards-tabs button {
    background: none;
    border: none;
    padding: 10px 20px;
    font-family: 'Kanit', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.7;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}
.content-tabs button.active, .rewards-tabs button.active {
    opacity: 1;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}
.content-display, .rewards-content {
    /* container for tab content */
}

.rewards-content ul {
    list-style: none;
    padding-left: 0;
}
.rewards-content li {
    padding: 5px 0;
    display: flex; /* Use flexbox for horizontal alignment of icon and tags */
    align-items: center; /* Vertically center items */
    flex-wrap: wrap; /* Allow items to wrap to the next line */
}
.rewards-content strong {
    color: var(--secondary-color);
    margin-right: 10px; /* Space between label and tags */
    white-space: nowrap; /* Prevent label from wrapping */
}

/* New styles for reward tags */
.reward-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Space between tags */
    margin-top: 5px; /* Space above tags if they wrap */
}

.reward-tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    /* white-space: nowrap; */ /* ลบคอมเมนต์ออกหรือลบทิ้งเพื่อให้ข้อความตัดคำได้ */
    white-space: normal; /* เพิ่มบรรทัดนี้เพื่อให้ข้อความขึ้นบรรทัดใหม่ได้ */
    overflow: hidden;
    text-overflow: ellipsis; /* ยังคง ellipsis เมื่อข้อความเกินขอบเขตที่กำหนด */
    max-width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
    word-wrap: break-word; /* เพิ่มบรรทัดนี้เพื่อให้คำที่ยาวมากตัดคำลงมา */
}

.reward-tag:hover {
    transform: translateY(-2px);
}

.reward-tag-exp {
    background-color: var(--reward-exp-bg);
    color: var(--reward-exp-text);
}

.reward-tag-int {
    background-color: var(--reward-int-bg);
    color: var(--reward-int-text);
}

.reward-tag-drachma {
    background-color: var(--reward-drachma-bg);
    color: var(--reward-drachma-text);
}

.reward-tag-honor {
    background-color: var(--reward-honor-bg);
    color: var(--reward-honor-text);
}

.reward-tag-item {
    background-color: var(--reward-item-bg);
    color: var(--reward-item-text);
    border: 1px solid var(--reward-default-text); /* Add a subtle border for items */
}

/* Specific God Favor Tags */
.reward-tag-favor-hades {
    background-color: var(--reward-favor-hades-bg);
    color: var(--reward-favor-hades-text);
}
.reward-tag-favor-ares {
    background-color: var(--reward-favor-ares-bg);
    color: var(--reward-favor-ares-text);
}
.reward-tag-favor-nike {
    background-color: var(--reward-favor-nike-bg);
    color: var(--reward-favor-nike-text);
}
.reward-tag-favor-persephone {
    background-color: var(--reward-favor-persephone-bg);
    color: var(--reward-favor-persephone-text);
}
.reward-tag-favor-artemis {
    background-color: var(--reward-favor-artemis-bg);
    color: var(--reward-favor-artemis-text);
}
.reward-tag-favor-hephaestus {
    background-color: var(--reward-favor-hephaestus-bg);
    color: var(--reward-favor-hephaestus-text);
}
.reward-tag-favor-apollo {
    background-color: var(--reward-favor-apollo-bg);
    color: var(--reward-favor-apollo-text);
}
.reward-tag-favor-athena {
    background-color: var(--reward-favor-athena-bg);
    color: var(--reward-favor-athena-text);
}
.reward-tag-favor-dionysus {
    background-color: var(--reward-favor-dionysus-bg);
    color: var(--reward-favor-dionysus-text);
}
.reward-tag-favor-aphrodite { /* Aphrodite specific tag */
    background-color: var(--reward-favor-aphrodite-bg);
    color: var(--reward-favor-aphrodite-text);
}
.reward-tag-favor-hecate { /* Hecate specific tag */
    background-color: var(--reward-favor-hecate-bg);
    color: var(--reward-favor-hecate-text);
}

/* General Favor Tag (fallback) */
.reward-tag-favor {
    background-color: var(--reward-favor-default-bg);
    color: var(--reward-favor-default-text);
}

.reward-tag-default { /* Fallback for unrecognized tags */
    background-color: var(--reward-default-bg);
    color: var(--reward-default-text);
}


/* Buttons */
.btn {
    display: inline-block;
    background: linear-gradient(145deg, var(--primary-color), #d47a32);
    color: #fff !important;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(242, 153, 74, 0.4);
}
.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(242, 153, 74, 0.6);
}
.btn-secondary {
    background: linear-gradient(145deg, #8c7a6b, #6b5b4d);
    box-shadow: 0 4px 15px rgba(107, 91, 77, 0.4);
}
.btn-secondary:hover {
    box-shadow: 0 7px 20px rgba(107, 91, 77, 0.6);
}
.btn-danger {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}
.btn-danger:hover {
    box-shadow: 0 7px 20px rgba(231, 76, 60, 0.6);
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}
.login-box {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow-color);
    width: 100%;
    max-width: 450px;
    text-align: center;
    border: 1px solid var(--border-color);
}
.logo-login {
    width: 100px;
    height: 100px;
    margin-bottom: 1.5rem;
    border-radius: 50%;
}
.login-box h1 {
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
}
.login-box p {
    margin-bottom: 2rem;
    color: #666;
}
.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}
.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--secondary-color);
}
.input-group input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-family: 'Kanit', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(242, 153, 74, 0.3);
}
.login-box .btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    margin-top: 1rem;
}
.error-banner {
    background-color: #e74c3c;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}


/* Admin Page */
.admin-section {
    background: var(--card-bg);
    padding: 2.5rem;
    margin-bottom: 2.5rem;
    border-radius: 15px;
    box-shadow: 0 5px 20px var(--shadow-color);
    border: 1px solid var(--border-color);
}
.admin-section h2 {
    font-size: 2rem;
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
}
.quest-list-table {
    width: 100%;
    border-collapse: collapse;
}
.quest-list-table th, .quest-list-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.quest-list-table th {
    font-weight: 600;
    color: var(--secondary-color);
}
.quest-list-table tr:last-child td {
    border-bottom: none;
}
.quest-list-table tr:hover {
    background-color: #f9f4e9;
}
.quest-list-table input[type="text"], .quest-list-table input[type="date"] {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}
.actions .btn {
    padding: 0.4rem 0.8rem;
    margin: 0 2px;
    font-size: 0.9rem;
}

/* === START: Fix for Choice Toggle === */
.choice-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 15px; /* ระยะห่างระหว่างข้อความกับสวิตช์ */
}
.choice-toggle-label {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--secondary-color);
}
/* === END: Fix for Choice Toggle === */


/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary-color);
}
input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}
input:checked + .slider:before {
  transform: translateX(26px);
}

/* Admin Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    font-family: 'Kanit', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: #fff;
}
.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

#content-rows-container .content-row,
#alt-content-rows-container .content-row {
    background: #f9f4e9;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid #e9e0d0;
}

.content-row textarea {
    min-height: 150px !important; /* Increased from 100px for better usability */
}

.content-row .links-container {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
}

.link-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#rewards-choice-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

#alt-rewards, #alt-content-section {
    display: none;
    background-color: #f7f1e4;
    padding: 1.5rem;
    border-radius: 10px;
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}
#alt-rewards h3, #alt-content-section h3 {
    color: var(--secondary-color);
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}
.full-width {
    grid-column: 1 / -1;
}

.success-message {
    background-color: #2ecc71;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    text-align: center;
}

@media (max-width: 992px) {
    .quest-board {
        grid-template-columns: 1fr;
    }
    .form-grid, #rewards-choice-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        text-align: center;
    }
    .main-header h1 {
        margin-bottom: 1rem;
    }
    .main-nav {
        margin-top: 1rem;
    }
    .main-nav a {
        margin: 0 0.5rem;
    }
}

