/* ==========================================================================
   Lamduan shared theme -- loaded by every plugin in the suite.
   Keep all color/spacing decisions here so every module stays visually
   identical without duplicating CSS.
   ========================================================================== */

:root {
    --ldc-red: #DF301C;
    --ldc-orange: #FF9100;
    --ldc-cream: #FFF1D1;
    --ldc-teal: #00B7CD;

    --ldc-text: #2b2b2b;
    --ldc-text-muted: #8a7a68;
    --ldc-bg: #FFF1D1;          /* page background -- cream, never white */
    --ldc-card-bg: #ffffff;      /* cards stay white so they lift off the cream */
    --ldc-border: #e9d2a8;

    --ldc-radius: 14px;
    --ldc-radius-sm: 8px;
    --ldc-shadow: 0 2px 10px rgba(223, 48, 28, 0.08);

    --ldc-font-body: 'IBM Plex Sans Thai', 'Poppins', -apple-system, BlinkMacSystemFont,
        'Segoe UI', 'Helvetica Neue', sans-serif;
    /* Poppins carries no Thai glyphs on purpose: Latin headings match the
       logo wordmark, Thai headings fall through to IBM Plex Sans Thai. */
    --ldc-font-display: 'Poppins', 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont,
        'Segoe UI', sans-serif;

    --ldc-topbar-h: 112px;       /* two rows: logo row + menu row */
    --ldc-bottomnav-h: 64px;
    --ldc-breakpoint: 1024px;
}

/* ---- reset-ish basics scoped to Lamduan content, not the whole theme ---- */
.ldc-page,
.ldc-card,
.ldc-form,
.ldc-table {
    box-sizing: border-box;
}
.ldc-page *,
.ldc-card *,
.ldc-form *,
.ldc-table * {
    box-sizing: inherit;
}

html,
body {
    background: var(--ldc-bg) !important;
    font-family: var(--ldc-font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    padding-top: var(--ldc-topbar-h);
}

/* keep content clear of the WP admin bar too */
body.admin-bar {
    padding-top: calc(var(--ldc-topbar-h) + 32px);
}
@media screen and (max-width: 782px) {
    body.admin-bar {
        padding-top: calc(var(--ldc-topbar-h) + 46px);
    }
}

@media (max-width: 1024px) {
    :root {
        --ldc-topbar-h: 72px; /* menu row hides on mobile, so topbar is shorter */
    }
    body {
        padding-bottom: var(--ldc-bottomnav-h);
    }
}

/* ==========================================================================
   TOP BAR -- row 1: logo (centered) / row 2: menu links
   ========================================================================== */
.ldc-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 2px solid var(--ldc-orange);
    z-index: 9999;
}

body.admin-bar .ldc-topbar {
    top: 32px;
}
@media screen and (max-width: 782px) {
    body.admin-bar .ldc-topbar {
        top: 46px;
    }
}

.ldc-topbar-logo-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px 6px;
}

.ldc-logo {
    display: inline-flex;
    align-items: center;
}
.ldc-logo img {
    height: 52px !important;
    max-height: 52px !important;
    width: auto !important;
    max-width: 300px !important;
    display: block;
    object-fit: contain;
}

/* ---- language switcher (TH / EN), pinned to the right of the logo row ---- */
.ldc-langswitch {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    background: var(--ldc-cream);
    border: 1px solid var(--ldc-border);
    border-radius: 999px;
    padding: 2px;
}
.ldc-lang-btn {
    font-family: var(--ldc-font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--ldc-text-muted);
    text-decoration: none;
    line-height: 1;
    transition: background .15s ease, color .15s ease;
}
.ldc-lang-btn:hover {
    color: var(--ldc-red);
}
.ldc-lang-btn.is-active {
    background: var(--ldc-red);
    color: #fff;
}

.ldc-topbar-menu-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 16px 8px;
    flex-wrap: wrap;
}

.ldc-topnav-link {
    font-family: var(--ldc-font-display);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    color: var(--ldc-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}
.ldc-topnav-link:hover {
    background: var(--ldc-cream);
    color: var(--ldc-red);
}
.ldc-topnav-link.is-active {
    background: var(--ldc-red);
    color: #fff;
}
.ldc-topnav-link .ldc-nav-icon {
    font-size: 16px;
    line-height: 1;
}

/* on phones/tablets the menu row hides; bottom nav takes over */
@media (max-width: 1024px) {
    .ldc-topbar-menu-row {
        display: none;
    }
    .ldc-logo img {
        height: 44px !important;
        max-height: 44px !important;
    }
}

/* ==========================================================================
   BOTTOM NAV -- sticky tab bar for phones & tablets
   ========================================================================== */
.ldc-bottomnav {
    display: none;
}

@media (max-width: 1024px) {
    .ldc-bottomnav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: var(--ldc-bottomnav-h);
        background: #ffffff;
        border-top: 1px solid var(--ldc-border);
        z-index: 9999;
        padding-bottom: env(safe-area-inset-bottom, 0);
        box-shadow: 0 -2px 10px rgba(223, 48, 28, 0.08);
    }

    .ldc-bottomnav-link {
        font-family: var(--ldc-font-display);
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        text-decoration: none;
        color: var(--ldc-text-muted);
        font-size: 11px;
        font-weight: 600;
        min-width: 0;
    }
    .ldc-bottomnav-link .ldc-nav-icon {
        font-size: 20px;
        line-height: 1;
    }
    .ldc-bottomnav-link .ldc-nav-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }
    .ldc-bottomnav-link.is-active {
        color: var(--ldc-red);
    }
    .ldc-bottomnav-link.is-active .ldc-nav-icon {
        transform: translateY(-1px);
    }
}

/* ==========================================================================
   SHARED COMPONENTS -- every module plugin can reuse these classes
   ========================================================================== */
.ldc-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
    color: var(--ldc-text);
    font-size: 15px;
    line-height: 1.5;
}

.ldc-page h1 {
    font-family: var(--ldc-font-display);
    letter-spacing: -0.01em;
    font-size: 22px;
    margin: 0 0 4px;
    color: var(--ldc-red);
}
.ldc-page .ldc-subtitle {
    color: var(--ldc-text-muted);
    margin: 0 0 20px;
    font-size: 14px;
}

.ldc-card {
    background: var(--ldc-card-bg);
    border: 1px solid var(--ldc-border);
    border-radius: var(--ldc-radius);
    box-shadow: var(--ldc-shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.ldc-card-title {
    font-family: var(--ldc-font-display);
    font-weight: 600;
    color: var(--ldc-red);
    margin: 0 0 12px;
    font-size: 15px;
}

.ldc-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}
.ldc-stat {
    background: var(--ldc-cream);
    border: 1px solid var(--ldc-border);
    border-radius: var(--ldc-radius-sm);
    padding: 10px 12px;
}
.ldc-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #a9793f;
    display: block;
    margin-bottom: 2px;
}
.ldc-stat-value {
    font-family: var(--ldc-font-display);
    font-variant-numeric: tabular-nums;
    font-size: 20px;
    font-weight: 700;
    color: var(--ldc-text);
}

.ldc-form label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #55483a;
    margin-bottom: 4px;
}
.ldc-form .ldc-field {
    margin-bottom: 14px;
}

/* Field help text -- every input in the suite explains what goes in it.
   Sits under the input, quiet enough not to compete with the label. */
.ldc-hint,
.ldm-field-hint,
.ldw-field-hint {
    display: block;
    margin: 5px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ldc-text-muted);
    font-weight: 400;
}
.ldc-hint strong {
    color: #a9793f;
    font-weight: 600;
}
.ldc-form label .ldc-optional {
    font-weight: 400;
    color: var(--ldc-text-muted);
    font-size: 12px;
}
.ldc-form input[type="text"],
.ldc-form input[type="email"],
.ldc-form input[type="password"],
.ldc-form input[type="number"],
.ldc-form input[type="date"],
.ldc-form input[type="time"],
.ldc-form select,
.ldc-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ldc-border);
    border-radius: var(--ldc-radius-sm);
    font-size: 15px;
    background: #fff;
    color: var(--ldc-text);
}
.ldc-form input:focus,
.ldc-form select:focus,
.ldc-form textarea:focus {
    outline: none;
    border-color: var(--ldc-teal);
    box-shadow: 0 0 0 3px rgba(0, 183, 205, 0.15);
}

.ldc-btn {
    font-family: var(--ldc-font-display);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s ease, transform 0.05s ease;
}
.ldc-btn:active {
    transform: scale(0.98);
}
.ldc-btn-primary {
    background: var(--ldc-red);
    color: #fff;
}
.ldc-btn-primary:hover { filter: brightness(1.08); }
.ldc-btn-secondary {
    background: var(--ldc-teal);
    color: #fff;
}
.ldc-btn-secondary:hover { filter: brightness(1.08); }
.ldc-btn-outline {
    background: transparent;
    color: var(--ldc-red);
    border: 1.5px solid var(--ldc-red);
}
.ldc-btn-block {
    width: 100%;
}

.ldc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.ldc-table th,
.ldc-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--ldc-border);
}
.ldc-table th {
    color: var(--ldc-text-muted);
    font-size: 11px;
    text-transform: uppercase;
}

.ldc-badge {
    font-family: var(--ldc-font-display);
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--ldc-cream);
    color: var(--ldc-red);
}

.ldc-alert {
    padding: 12px 14px;
    border-radius: var(--ldc-radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
}
.ldc-alert-success { background: #e6f7ee; color: #1c7a4d; }
.ldc-alert-error   { background: #fdeceb; color: var(--ldc-red); }
.ldc-alert-info    { background: #e5f7fa; color: #0d7f92; }

.ldc-guest-note {
    background: var(--ldc-cream);
    border: 1px dashed var(--ldc-orange);
    border-radius: var(--ldc-radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    color: #8a5a1a;
    margin-bottom: 16px;
}
.ldc-guest-note a {
    color: var(--ldc-red);
    font-weight: 700;
}

/* ==========================================================================
   USER MANUAL (rendered by [lamduan_manual])
   ========================================================================== */
.ldc-manual-toc ol {
    margin: 0;
    padding-left: 20px;
}
.ldc-manual-toc li {
    margin-bottom: 4px;
}
.ldc-manual-toc a {
    color: var(--ldc-text);
    text-decoration: none;
    font-weight: 600;
}
.ldc-manual-toc a:hover {
    color: var(--ldc-red);
    text-decoration: underline;
}

.ldc-manual-section {
    scroll-margin-top: calc(var(--ldc-topbar-h) + 12px);
}

.ldc-manual-body p {
    margin: 0 0 12px;
}
.ldc-manual-body ul,
.ldc-manual-body ol {
    margin: 0 0 12px;
    padding-left: 22px;
}
.ldc-manual-body li {
    margin-bottom: 6px;
}
.ldc-manual-body h4 {
    color: var(--ldc-red);
    font-size: 14px;
    margin: 16px 0 8px;
}

.ldc-tip {
    background: var(--ldc-cream);
    border: 1px dashed var(--ldc-orange);
    border-radius: var(--ldc-radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    color: #8a5a1a;
    margin: 4px 0 14px;
}
.ldc-tip strong {
    display: block;
    color: var(--ldc-red);
    margin-bottom: 4px;
}


/* ==========================================================================
   SHARED EXTRAS for module plugins (charts, segmented tabs, empty states)
   ========================================================================== */
.ldc-chart {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}
.ldc-chart-wrap {
    background: var(--ldc-cream);
    border: 1px solid var(--ldc-border);
    border-radius: var(--ldc-radius-sm);
    padding: 12px 10px 6px;
}

.ldc-segmented {
    display: flex;
    gap: 6px;
    background: var(--ldc-cream);
    border: 1px solid var(--ldc-border);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 14px;
}
.ldc-segmented button {
    font-family: var(--ldc-font-display);
    flex: 1;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ldc-text-muted);
    cursor: pointer;
}
.ldc-segmented button.is-active {
    background: var(--ldc-red);
    color: #fff;
}

.ldc-empty {
    text-align: center;
    color: var(--ldc-text-muted);
    font-size: 13px;
    padding: 22px 10px;
}

.ldc-inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ldc-linkbtn {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--ldc-teal);
    cursor: pointer;
    text-decoration: none;
}
.ldc-linkbtn.is-danger { color: var(--ldc-red); }

.ldc-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 420px) {
    .ldc-row-2 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   APP MODE + INSTALL PROMPT
   When the site runs as an installed app there is no browser chrome, so the
   layout has to respect the phone's own safe areas itself.
   ========================================================================== */
body.ldc-app .ldc-topbar {
    padding-top: env(safe-area-inset-top, 0);
}
body.ldc-app {
    padding-top: calc(var(--ldc-topbar-h) + env(safe-area-inset-top, 0));
}
body.ldc-app .ldc-bottomnav {
    padding-bottom: env(safe-area-inset-bottom, 0);
    height: calc(var(--ldc-bottomnav-h) + env(safe-area-inset-bottom, 0));
}
@media (max-width: 1024px) {
    body.ldc-app {
        padding-bottom: calc(var(--ldc-bottomnav-h) + env(safe-area-inset-bottom, 0));
    }
}
/* an installed app should not offer to install itself */
body.ldc-app .ldc-install-bar { display: none !important; }

.ldc-install-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--ldc-bottomnav-h) + 12px + env(safe-area-inset-bottom, 0));
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--ldc-border);
    border-left: 4px solid var(--ldc-red);
    border-radius: var(--ldc-radius);
    box-shadow: 0 6px 24px rgba(223, 48, 28, 0.18);
    padding: 12px 14px;
}
@media (min-width: 1025px) {
    .ldc-install-bar {
        left: auto;
        right: 20px;
        bottom: 20px;
        max-width: 380px;
    }
}
.ldc-install-text { flex: 1; min-width: 180px; }
.ldc-install-text strong {
    display: block;
    font-family: var(--ldc-font-display);
    font-size: 14px;
    color: var(--ldc-red);
    margin-bottom: 2px;
}
.ldc-install-text span {
    font-size: 12px;
    line-height: 1.45;
    color: var(--ldc-text-muted);
}
.ldc-install-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.ldc-install-go {
    font-family: var(--ldc-font-display);
    border: none;
    background: var(--ldc-red);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 999px;
    cursor: pointer;
}
.ldc-install-later {
    font-family: var(--ldc-font-display);
    border: none;
    background: none;
    color: var(--ldc-text-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 9px 6px;
    cursor: pointer;
}

/* ==========================================================================
   DASHBOARD  [lamduan_dashboard]
   ========================================================================== */
.ldc-dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 700px) {
    .ldc-dash-grid { grid-template-columns: 1fr; }
}
.ldc-dash-card { margin-bottom: 0; }

.ldc-dash-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--ldc-border);
}
.ldc-dash-title {
    font-family: var(--ldc-font-display);
    font-weight: 600;
    font-size: 15px;
    color: var(--ldc-red);
}
.ldc-dash-icon { margin-right: 6px; }

.ldc-dash-body .ldc-stat-grid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.ldc-dash-body .ldc-btn { margin-top: 12px; }
.ldc-dash-body p { margin: 0 0 8px; font-size: 13px; }

.ldc-dash-welcome p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ldc-text);
    margin: 0 0 14px;
}

.ldc-dash-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    padding: 4px 0;
}
.ldc-dash-line strong {
    font-family: var(--ldc-font-display);
    font-variant-numeric: tabular-nums;
    font-size: 15px;
}
.ldc-dash-empty {
    font-size: 13px;
    color: var(--ldc-text-muted);
    padding: 6px 0 2px;
}

/* ==========================================================================
   EXPORT PAGE
   ========================================================================== */
.ldc-export-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--ldc-border);
}
.ldc-export-row:last-of-type { border-bottom: none; }
.ldc-export-name {
    font-family: var(--ldc-font-display);
    font-weight: 600;
    font-size: 14px;
}
.ldc-export-name .ldw-muted {
    display: block;
    font-family: var(--ldc-font-body);
    font-weight: 400;
    font-size: 11px;
    color: var(--ldc-text-muted);
}
.ldc-btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    white-space: nowrap;
}
.ldc-export .ldc-card p { font-size: 14px; line-height: 1.6; margin: 0 0 12px; }
