/* ==========================================================================
   CSS Layer 5: Page-Specific Styles
   Start View, Landing, Herb Table, Detail View, Tastes 10, Supplemental Pages
   ========================================================================== */

/* ===== หน้าเริ่มต้น (Start View) ===== */
.start-view {
    min-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.st-card {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
    background: linear-gradient(135deg, rgba(61, 107, 79, 0.96), rgba(46, 84, 61, 0.96));
    color: #fff;
    border-radius: 20px;
    padding: 3rem 1.75rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.st-leaf {
    font-size: 2.4rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.st-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    opacity: 0.85;
}

.st-title {
    color: #fff;
    font-size: 2.8rem;
    line-height: 1.2;
    margin: 0 0 1rem;
}

.st-lead {
    max-width: 460px;
    margin: 0 auto 1rem;
    font-size: 1.1rem;
    opacity: 0.95;
}

.st-facts {
    margin: 0 0 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.st-btn {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    background: var(--accent-gold);
    color: var(--accent-gold-text);
    border: 0;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.st-btn:hover {
    background: var(--accent-gold-hover);
}

.st-btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.st-note {
    margin: 1.75rem auto 0;
    max-width: 480px;
    font-size: 0.9rem;
    opacity: 0.85;
}

/* ===== หน้า Landing ===== */
.landing {
    margin-bottom: 2rem;
}

.lp-hero {
    position: relative;
    background: linear-gradient(135deg, rgba(61, 107, 79, 0.95), rgba(46, 84, 61, 0.95));
    color: #fff;
    border-radius: var(--radius-xl);
    padding: 3.2rem 1.5rem 2.5rem;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.lp-start-link {
    position: absolute;
    top: 0.9rem;
    left: 1.1rem;
    color: #fff;
    opacity: 0.85;
    font-size: 0.9rem;
    text-decoration: none;
}

.lp-start-link:hover {
    text-decoration: underline;
    opacity: 1;
}

.lp-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    opacity: 0.85;
}

.lp-title {
    color: #fff;
    font-size: 2.4rem;
    line-height: 1.2;
    margin: 0 0 0.75rem;
}

.lp-lead {
    max-width: 560px;
    margin: 0 auto 1.5rem;
    font-size: 1.1rem;
    opacity: 0.95;
}

.lp-search {
    display: flex;
    gap: 0.5rem;
    max-width: 600px;
    margin: 0 auto 1rem;
}

.lp-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.lp-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.9rem 2.75rem 0.9rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--text-color);
}

.lp-search-input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.lp-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: #e8e5dc;
    color: var(--text-color);
    font-size: 1.3rem;
    line-height: 1;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.lp-clear:hover {
    background: #d6d2c6;
}

.lp-search-btn {
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    background: var(--accent-gold);
    color: var(--accent-gold-text);
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.lp-search-btn:hover {
    background: var(--accent-gold-hover);
}

.lp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 1rem;
}

.lp-chips-label {
    font-size: 0.95rem;
    opacity: 0.85;
}

.lp-chip {
    padding: 0.35rem 0.9rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: var(--radius-pill);
}

.lp-chip:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lp-browse {
    background: none;
    border: 0;
    color: #fff;
    text-decoration: underline;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    opacity: 0.9;
}

.lp-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.lp-stat {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    text-align: center;
}

.lp-stat strong {
    display: block;
    font-size: 1.8rem;
    color: var(--primary-color);
    line-height: 1.2;
}

.lp-stat span {
    font-size: 0.95rem;
    opacity: 0.85;
}

.lp-h2 {
    font-size: 1.3rem;
    margin: 1.75rem 0 0.75rem;
    background: rgba(250, 248, 240, 0.9);
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: var(--radius-sm);
}

.lp-cats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.lp-cat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--secondary-color);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
}

.lp-cat:hover {
    border-left-color: var(--primary-color);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.lp-cat-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-color);
}

.lp-cat-count {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

.lp-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.lp-steps li {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.9rem 1rem;
}

.lp-steps p {
    margin: 0.15rem 0 0;
}

.lp-step-no {
    flex: 0 0 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    font-weight: 700;
}

.lp-note {
    margin-top: 1.25rem;
    padding: 0.8rem 1rem;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning-text);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
}

/* ===== มุมมองตารางสมุนไพร (Herb Table) ===== */
.table-wrap {
    margin-top: 0.5rem;
}

.table-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}

.table-scroll {
    overflow: auto;
    max-height: 75vh;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
}

.herb-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: 1700px;
    font-size: 0.92rem;
}

.herb-table th,
.herb-table td {
    padding: 0.6rem 0.7rem;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid #f0ede4;
}

.herb-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--primary-color);
    color: #fff;
    white-space: nowrap;
}

.herb-table tbody tr.herb-start td {
    border-top: 2px solid var(--secondary-color);
}

.herb-table tbody tr.alt td {
    background: var(--row-alt-bg);
}

.herb-table td.col-name {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--card-bg);
    font-weight: 600;
}

.herb-table tbody tr.alt td.col-name {
    background: var(--row-alt-bg);
}

.herb-table thead th.col-name {
    left: 0;
    z-index: 4;
}

.herb-table td.col-other {
    color: var(--text-subtle);
}

.herb-table td.col-name .equiv-note {
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    min-width: 150px;
}

.herb-table .col-name { min-width: 130px; }
.herb-table .col-other { min-width: 130px; }
.herb-table .col-cat { min-width: 90px; }
.herb-table .col-plant { min-width: 200px; }
.herb-table .col-part { min-width: 100px; }
.herb-table .col-classic { min-width: 110px; }
.herb-table .col-main { min-width: 90px; }
.herb-table .col-nine { min-width: 130px; }
.herb-table .col-principle { min-width: 220px; }
.herb-table .col-props { min-width: 300px; }
.herb-table .col-caution { min-width: 220px; }

.table-herb-link {
    color: var(--primary-color);
    text-decoration: none;
}

.table-herb-link:hover {
    text-decoration: underline;
}

/* ===== หน้ารายละเอียดตัวยา (Detail View) ===== */
.detail-view {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.use-part-card {
    background: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0 8px 8px 0;
}

.part-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #2c5238;
}

.field-row {
    margin-bottom: 0.6rem;
}

.field-label {
    font-weight: 600;
    margin-right: 0.5rem;
}

#herb-detail-container > .equiv-note {
    margin-top: 1.25rem;
}

/* ===== หน้ารสยา 10 รส ===== */
.tastes-view {
    padding-bottom: 2rem;
}

.t-hero {
    padding-top: 2.5rem;
    margin-bottom: 0.5rem;
}

.t-groups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.t-group {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--secondary-color);
    border-radius: var(--radius-lg);
    padding: 0.9rem 1rem;
}

.t-group-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.t-group-members {
    margin: 0.25rem 0;
    font-weight: 600;
}

.t-group-note {
    font-size: 0.95rem;
    opacity: 0.85;
}

.t-hint {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    opacity: 0.8;
    background: rgba(250, 248, 240, 0.9);
    display: inline-block;
    padding: 0 0.4rem;
    border-radius: 4px;
}

.t-table-wrap {
    overflow-x: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.t-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.97rem;
}

.t-table th {
    background: var(--primary-color);
    color: #fff;
    text-align: left;
    padding: 0.6rem 0.75rem;
    white-space: nowrap;
}

.t-table td {
    padding: 0.55rem 0.75rem;
    border-top: 1px solid var(--border-color);
    vertical-align: top;
}

.t-table tbody tr:nth-child(even) {
    background: var(--bg-color);
}

.t-table .t-no {
    text-align: center;
    white-space: nowrap;
}

.t-table .t-name {
    font-weight: 600;
    color: var(--primary-color);
}

.t-click {
    cursor: pointer;
}

.t-summary tbody tr.t-click:hover {
    background: #e9f1ec;
}

.t-click:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

.t-search {
    margin: 0.5rem 0 0.75rem;
}

.t-empty {
    padding: 1rem;
    text-align: center;
    background: var(--card-bg);
    border-radius: var(--radius-md);
}

.t-count {
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.8;
}

.t-cards {
    display: none;
}

/* ===== หน้าเสริม (ยาสามัญ / น้ำกระสายยา / สสม. / อาการ) ===== */
.pg-search {
    margin: 1rem 0 0.5rem;
}

.pg-input {
    width: 100%;
    font: inherit;
    font-size: 1.05rem;
    padding: 0.75rem 2.6rem 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    box-sizing: border-box;
}

.pg-input:focus {
    outline: 3px solid var(--secondary-color);
    outline-offset: 1px;
    border-color: var(--primary-color);
}

.pg-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.6rem 0;
}

.pg-pill {
    font: inherit;
    font-size: 0.92rem;
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--primary-color);
    cursor: pointer;
}

.pg-pill:hover {
    border-color: var(--primary-color);
}

.pg-pill.on {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.pg-count {
    margin: 0.4rem 0;
    color: var(--text-muted);
    font-weight: 600;
}

.pg-empty {
    padding: 1.5rem;
    text-align: center;
    background: var(--card-bg);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}

.pg-seg {
    display: inline-flex;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 0.5rem 0;
    max-width: 100%;
}

.pg-seg-btn {
    font: inherit;
    padding: 0.5rem 1rem;
    border: 0;
    background: #fff;
    color: var(--primary-color);
    cursor: pointer;
}

.pg-seg-btn.on {
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
}

.pg-table .pg-more,
.pg-table .pg-th-more {
    width: 2rem;
    text-align: center;
    color: var(--primary-color);
}

.pg-row.pg-has-detail {
    cursor: pointer;
}

.pg-row.pg-has-detail:hover {
    background: #f1efe2 !important;
}

.pg-row.pg-has-detail:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: -3px;
}

.pg-chev {
    display: inline-block;
    transition: transform 0.15s;
}

.pg-row[aria-expanded="true"] .pg-chev {
    transform: rotate(180deg);
}

.pg-detail-row,
.pg-detail-row:nth-child(even) {
    background: #fffdf3 !important;
}

.pg-detail-row[hidden] {
    display: none;
}

.pg-dl {
    margin: 0;
    display: grid;
    gap: 0.6rem;
}

.pg-dl dt {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.92rem;
}

.pg-dl dd {
    margin: 0.1rem 0 0;
    line-height: 1.6;
}

.pg-ul {
    margin: 0;
    padding-left: 1.2rem;
}

.pg-herblink {
    color: #1b6b3a;
    font-weight: 700;
    text-decoration: underline;
}

.pg-line {
    margin: 0.3rem 0;
}

.pg-lab {
    display: inline-block;
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 0.3rem;
}

.pg-more-d {
    margin-top: 0.5rem;
}

.pg-more-d summary {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 600;
    padding: 0.3rem 0;
}

.pg-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

.pg-info-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-top: 5px solid var(--secondary-color);
    border-radius: var(--radius-lg);
    padding: 0.8rem 1rem;
}

.pg-info-h {
    font-weight: 700;
    color: var(--primary-color);
}

.pg-info-sub {
    font-weight: 600;
    margin: 0.2rem 0;
}

.pg-info-card p {
    margin: 0.3rem 0 0;
    line-height: 1.55;
}

.pg-info-ex {
    font-size: 0.92rem;
    color: var(--text-muted);
}

.pg-callout,
.pg-note {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    background: #fff8dc;
    border: 1px solid #e8d98a;
    border-radius: var(--radius-md);
}

.pg-src {
    margin: 1rem 0;
}

.pg-src-h {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin: 0 0 0.4rem;
}

.pg-reslist {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.pg-reslist li {
    padding: 0.6rem 0.9rem;
    border-top: 1px solid var(--border-color);
}

.pg-reslist li:first-child {
    border-top: 0;
}

.pg-res-sub {
    display: block;
    color: #444;
    font-size: 0.95rem;
    margin-top: 0.15rem;
}

.pg-more-line {
    margin: 0.4rem 0 0;
    color: var(--text-muted);
}

.pg-all {
    font: inherit;
    background: none;
    border: 0;
    padding: 0;
    color: #1b6b3a;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* ===== Page Responsive Breakpoints ===== */
@media (max-width: 768px) {
    .t-groups {
        grid-template-columns: 1fr;
    }

    .t-table-wrap {
        display: none;
    }

    .t-cards {
        display: block;
    }

    .t-cards .m-herb {
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 600px) {
    .lp-hero {
        padding: 3rem 1rem 1.75rem;
    }

    .lp-title {
        font-size: 1.9rem;
    }

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

    .lp-stats {
        gap: 0.5rem;
    }

    .lp-stat strong {
        font-size: 1.4rem;
    }

    .st-card {
        padding: 2.25rem 1.25rem;
    }

    .st-title {
        font-size: 2.2rem;
    }
}
