/* ==========================================================================
   Public Research Data Portal — theme
   Layered on top of Bootstrap 5. Soft blue/grey chrome, light surfaces,
   teal accent for primary actions.
   ========================================================================== */

:root {
    --portal-primary: #34699a;          /* soft professional blue */
    --portal-primary-dark: #1f4769;
    --portal-primary-soft: #e8f0f8;
    --portal-accent: #0d9488;           /* professional teal */
    --portal-accent-dark: #0f766e;
    --portal-bg: #f4f6f9;               /* very light grey page */
    --portal-surface: #ffffff;
    --portal-surface-alt: #f8fafc;      /* zebra stripe */
    --portal-border: #e2e8f0;
    --portal-text: #1f2933;
    --portal-muted: #64748b;
    --portal-row-hover: #eef5fb;        /* light blue row hover */
    --portal-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
    --portal-radius: 14px;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--portal-bg);
    color: var(--portal-text);
    font-family: "Segoe UI", "Sarabun", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}

/* ----- Header --------------------------------------------------------- */
.portal-header {
    background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .12);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.portal-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .85rem 1rem;
    flex-wrap: wrap;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    color: #fff;
    text-decoration: none;
}

.portal-brand:hover { color: #fff; opacity: .95; }

.portal-brand__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .15);
    flex: 0 0 auto;
}

.portal-brand__logo svg { width: 26px; height: 26px; }

.portal-brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.portal-brand__title { font-size: 1.2rem; font-weight: 700; }
.portal-brand__subtitle { font-size: .78rem; letter-spacing: .04em; opacity: .85; text-transform: uppercase; }

.portal-nav {
    display: flex;
    gap: .25rem;
    align-items: center;
}

.portal-nav a {
    color: rgba(255, 255, 255, .92);
    text-decoration: none;
    font-weight: 500;
    padding: .45rem .9rem;
    border-radius: 8px;
    transition: background-color .15s ease;
}

.portal-nav a:hover { background: rgba(255, 255, 255, .15); color: #fff; }

/* ----- Main / layout -------------------------------------------------- */
.portal-main {
    flex: 1 0 auto;
    padding: 1.75rem 0 3rem;
}

.portal-hero {
    border-radius: var(--portal-radius);
    overflow: hidden;
    box-shadow: var(--portal-shadow);
    margin-bottom: 1.75rem;
    background: #fff;
}

.portal-hero img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 240px;
    object-fit: cover;
}

.portal-page-title {
    text-align: center;
    margin-bottom: 1.5rem;
}

.portal-page-title h1 {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--portal-primary-dark);
    margin: 0;
}

.portal-page-title p {
    color: var(--portal-muted);
    margin: .35rem 0 0;
}

/* ----- Cards ---------------------------------------------------------- */
.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 1.5rem;
    margin-bottom: 1.75rem;
}

.portal-card__header {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.25rem;
    padding-bottom: .9rem;
    border-bottom: 1px solid var(--portal-border);
}

.portal-card__header svg { width: 22px; height: 22px; color: var(--portal-accent); }
.portal-card__header h2 { font-size: 1.2rem; font-weight: 700; margin: 0; color: var(--portal-text); }

/* ----- Form controls -------------------------------------------------- */
.portal-label {
    font-weight: 600;
    font-size: .9rem;
    color: var(--portal-text);
    margin-bottom: .35rem;
}

.portal-label small { font-weight: 400; color: var(--portal-muted); }

.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid var(--portal-border);
    padding: .6rem .85rem;
    background-color: var(--portal-surface-alt);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--portal-primary);
    background-color: #fff;
    box-shadow: 0 0 0 .2rem rgba(52, 105, 154, .18);
}

/* Search input group with leading magnifier */
.portal-search-input { position: relative; }
.portal-search-input .portal-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--portal-muted);
    pointer-events: none;
}
.portal-search-input .form-control { padding-left: 2.6rem; }

/* ----- Buttons -------------------------------------------------------- */
.btn-portal-primary {
    background: var(--portal-accent);
    border: 1px solid var(--portal-accent);
    color: #fff;
    font-weight: 600;
    padding: .65rem 1.6rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    transition: background-color .15s ease, transform .05s ease, box-shadow .15s ease;
    box-shadow: 0 4px 12px rgba(13, 148, 136, .25);
}

.btn-portal-primary:hover { background: var(--portal-accent-dark); border-color: var(--portal-accent-dark); color: #fff; }
.btn-portal-primary:active { transform: translateY(1px); }
.btn-portal-primary svg { width: 18px; height: 18px; }

.btn-portal-ghost {
    background: transparent;
    border: 1px solid var(--portal-border);
    color: var(--portal-muted);
    font-weight: 500;
    padding: .65rem 1.2rem;
    border-radius: 10px;
    transition: background-color .15s ease, color .15s ease;
}
.btn-portal-ghost:hover { background: var(--portal-surface-alt); color: var(--portal-text); }

/* ----- Results summary ------------------------------------------------ */
.portal-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .9rem;
}

.portal-count-badge {
    background: var(--portal-primary-soft);
    color: var(--portal-primary-dark);
    font-weight: 600;
    padding: .4rem .85rem;
    border-radius: 999px;
    font-size: .9rem;
}

.portal-page-indicator { color: var(--portal-muted); font-size: .9rem; }

/* ----- Data table ----------------------------------------------------- */
.portal-table-wrap {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    overflow: hidden;
}

.portal-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: .92rem;
}

.portal-table thead th {
    background: var(--portal-primary-soft);
    color: var(--portal-primary-dark);
    font-weight: 700;
    text-align: center;
    padding: .85rem .75rem;
    border-bottom: 2px solid var(--portal-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.portal-table tbody td {
    padding: .75rem;
    border-bottom: 1px solid var(--portal-border);
    vertical-align: top;
}

/* zebra stripes */
.portal-table tbody tr:nth-child(even) { background: var(--portal-surface-alt); }
/* hover */
.portal-table tbody tr:hover { background: var(--portal-row-hover); }

.portal-table .cell-center { text-align: center; white-space: nowrap; }
.portal-table .research-title { font-weight: 600; color: var(--portal-text); }
.portal-table .research-title-eng { color: var(--portal-muted); font-size: .86rem; }
.portal-keyword-chip {
    display: inline-block;
    background: var(--portal-surface-alt);
    border: 1px solid var(--portal-border);
    color: var(--portal-muted);
    border-radius: 6px;
    padding: .1rem .45rem;
    margin: .1rem .15rem 0 0;
    font-size: .78rem;
}

.btn-read {
    background: #fff;
    border: 1px solid var(--portal-accent);
    color: var(--portal-accent);
    border-radius: 8px;
    padding: .3rem .75rem;
    font-size: .82rem;
    font-weight: 600;
    transition: background-color .15s ease, color .15s ease;
}
.btn-read:hover { background: var(--portal-accent); color: #fff; }

/* ----- Empty / alert -------------------------------------------------- */
.portal-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    background: var(--portal-surface);
    border: 1px dashed var(--portal-border);
    border-radius: var(--portal-radius);
    color: var(--portal-muted);
}

/* ----- Pagination ----------------------------------------------------- */
.pagination { margin: 1.5rem 0 0; }
.pagination .page-link {
    color: var(--portal-primary);
    border: 1px solid var(--portal-border);
    margin: 0 2px;
    border-radius: 8px;
    min-width: 40px;
    text-align: center;
}
.pagination .page-link:hover { background: var(--portal-primary-soft); color: var(--portal-primary-dark); }
.pagination .page-item.active .page-link {
    background: var(--portal-primary);
    border-color: var(--portal-primary);
    color: #fff;
}
.pagination .page-item.disabled .page-link { color: #c0c8d2; }

/* ----- Footer --------------------------------------------------------- */
.portal-footer {
    flex-shrink: 0;
    background: #1f2933;
    color: #cbd5e1;
    padding: 1.4rem 0;
    margin-top: auto;
}

.portal-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: .9rem;
}

.portal-footer a { color: #7dd3c8; text-decoration: none; }
.portal-footer a:hover { color: #a7e8e0; text-decoration: underline; }

/* ----- Loading overlay ------------------------------------------------ */
.portal-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(244, 246, 249, .82);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity .2s ease;
}

.portal-loading-overlay.is-active {
    display: flex;
    opacity: 1;
}

.portal-loading-box {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 1.75rem 2.25rem;
    text-align: center;
    color: var(--portal-text);
}

.portal-loading-box .spinner-border { color: var(--portal-accent); width: 2.75rem; height: 2.75rem; }
.portal-loading-box .portal-loading-text { margin-top: .9rem; font-weight: 600; }
.portal-loading-box .portal-loading-sub { color: var(--portal-muted); font-size: .85rem; }

/* While loading, fade out any previously rendered results. */
.portal-results.is-loading { opacity: .35; transition: opacity .2s ease; pointer-events: none; }

/* ----- Modal ---------------------------------------------------------- */
.modal-content { border: none; border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }
.modal-header { background: var(--portal-primary-soft); border-bottom: 1px solid var(--portal-border); }
.modal-title { color: var(--portal-primary-dark); font-weight: 700; }

/* ----- Responsive ----------------------------------------------------- */
@media (max-width: 575.98px) {
    .portal-brand__subtitle { display: none; }
    .portal-page-title h1 { font-size: 1.35rem; }
    .portal-card { padding: 1.1rem; }
    .portal-footer__inner { flex-direction: column; text-align: center; }
}
