/* components.css — page-level components */

/* =========================================
   POS
   ========================================= */
.pos-layout { min-height: 60vh; }

/* The item card takes the rest of the page and grows down the screen, so more
   than one row of items is visible without scrolling inside the card. */
.pos-items-pane {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--topbar-height) - 110px);
}

.pos-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.scan-status {
    font-size: 13px;
    min-height: 16px;
    margin-bottom: 12px;
}

.cart-pane {
    display: flex;
    flex-direction: column;
    min-height: 420px;
}

.scan-input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--button-bg) !important;
    background: var(--card-solid) !important;
    font-weight: 500;
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 14px;
    align-content: start;
    flex: 1;
}

.pos-item {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 13px;
    padding: 13px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

body.dark-mode .pos-item { border-color: var(--border); }

.pos-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(8, 36, 32, 0.12);
    border-color: var(--teal-300);
}

.item-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
    color: var(--text);
}

.item-price {
    color: var(--button-bg);
    font-weight: 800;
    font-size: 15px;
}

body.dark-mode .item-price { color: var(--teal-300); }

.cart-list { margin-bottom: 16px; max-height: 46vh; overflow-y: auto; }

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.qty-controls { display: flex; align-items: center; gap: 10px; }

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border) !important;
    background: transparent !important;
    color: var(--text) !important;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
}

.qty-btn:hover { background: rgba(14, 93, 82, 0.09) !important; }

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 19px;
    font-weight: 800;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    color: var(--text);
}

.checkout-btn {
    width: 100%;
    padding: 14px;
    font-size: 15.5px;
    margin-top: 14px;
    box-shadow: 0 10px 26px rgba(8, 36, 32, 0.2);
}

.checkout-btn:disabled {
    background-color: #93a5a0 !important;
    cursor: not-allowed;
    box-shadow: none;
}

.mop-select { margin-top: 2px; }

/* =========================================
   Tabs & filters
   ========================================= */
.pos-tabs { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

.tab-btn {
    padding: 9px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-weight: 500;
    text-transform: capitalize;
    color: var(--text);
    transition: background 0.18s;
}

.tab-btn.active {
    background: var(--button-bg);
    color: #fff;
    border-color: transparent;
}

.seg-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 5px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    backdrop-filter: blur(18px);
    width: fit-content;
    max-width: 100%;
}

body.dark-mode .seg-tabs { border-color: var(--border); }

.seg-btn {
    padding: 9px 16px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s;
}

.seg-btn:hover { color: var(--text); background: rgba(14, 93, 82, 0.06); }

.seg-btn.active {
    background: var(--button-bg);
    color: #fff;
    box-shadow: 0 6px 16px rgba(8, 36, 32, 0.18);
}

/* The console keeps its tab strip hidden — its sidebar switches panels instead,
   and display:flex would otherwise win over the hidden attribute. */
.seg-tabs[hidden] { display: none; }

.filter-btn {
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
}

.filter-btn.active {
    background: var(--button-bg);
    color: #fff;
    border-color: transparent;
}

/* Analytics: the date, member and export controls stay on one line */
.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-row .filter-btn {
    flex: 0 1 auto;
    width: auto;
    min-width: 0;
}

.filter-row #date-filter { max-width: 165px; }
.filter-row #attendant-filter { max-width: 190px; }
.filter-row #export-csv { margin-left: auto; flex: 0 0 auto; }

/* Usage page: the running bill */
.bill-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 18px 28px;
}

.bill-amount {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--button-bg);
    line-height: 1.1;
}

.bill-action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: 340px;
}

.bill-action .small { color: var(--text-muted); }
.bill-action .small.urgent { color: var(--danger); }

/* Usage page: add-on picker */
.addon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.addon-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--card-solid);
}

.addon-card p {
    margin: 0;
    line-height: 1.5;
}

.addon-card .btn { margin-top: auto; align-self: flex-start; }

/* Phones and tablets: keep the add-ons in one row and let the card scroll
   sideways instead of stacking into a long page. */
@media (max-width: 900px) {
    .addon-grid {
        display: flex;
        gap: 14px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .addon-card {
        flex: 0 0 min(78%, 340px);
        scroll-snap-align: start;
    }
}

/* Bill breakdown (Terms of Usage page) */
.bill-lines {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.bill-lines td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.bill-lines td:last-child {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
}

.bill-lines tr:last-child td { border-bottom: none; }

/* Terms of Usage: billing rules listed under the rates */
.rule-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin: 0;
    padding-left: 20px;
}

.rule-list li {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

/* Support page: admin contacts and hours sit under the chat card as plain text */
.support-note-card {
    max-width: 860px;
    padding-top: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.support-note {
    line-height: 1.7;
    margin: 0;
}

.pos-filter-dropdown { position: relative; display: inline-block; }

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 46px;
    background: var(--glass-strong);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 40;
    width: 165px;
    overflow: hidden;
}

body.dark-mode .dropdown-menu { border-color: var(--border); }

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(14, 93, 82, 0.07); }
.dropdown-item.active { background: var(--button-bg); color: #fff; }

/* =========================================
   Analytics
   ========================================= */
.stat-strip {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.stat { text-align: center; min-width: 120px; }

.stat h3 {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--button-bg);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

body.dark-mode .stat-value { color: var(--teal-300); }

.stat-divider {
    width: 1px;
    height: 48px;
    background: var(--border);
}

.tx-row { transition: background-color 0.18s ease; cursor: pointer; }
.tx-row:hover { background-color: rgba(14, 93, 82, 0.04); }
body.dark-mode .tx-row:hover { background-color: rgba(255, 255, 255, 0.04); }

/* =========================================
   Login & signup
   ========================================= */
.login-container {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    z-index: 0;
}

.login-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(760px 460px at 16% 10%, rgba(31, 138, 122, 0.18), transparent 62%),
        radial-gradient(720px 500px at 88% 90%, rgba(14, 93, 82, 0.16), transparent 64%);
    z-index: -1;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 44px 38px;
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 430px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    z-index: 2;
    position: relative;
    margin: auto;
}

body.dark-mode .login-card {
    background: rgba(31, 42, 39, 0.9);
    border: 1px solid rgba(190, 214, 208, 0.14);
}

.login-header { text-align: center; margin-bottom: 30px; }

.login-header img {
    display: block;
    height: 54px;
    margin: 0 auto 14px;
    border-radius: 12px;
}

.login-header h1 {
    color: var(--text);
    font-size: 27px;
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.login-header p {
    color: var(--text-muted);
    margin-top: 7px;
    font-size: 13.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.login-form { display: flex; flex-direction: column; gap: 17px; }

.input-group label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 7px;
    display: block;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.login-input {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
    transition: all 0.18s ease;
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 93, 82, 0.12);
    background: var(--card-solid);
}

body.dark-mode .login-input { background: rgba(0, 0, 0, 0.24); }

.login-form button[type="submit"] {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 11px;
    font-size: 15px;
    margin-top: 6px;
    box-shadow: 0 10px 26px rgba(8, 36, 32, 0.22);
}

.login-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* One button scale inside forms: matched height, width follows the label.
   Colours and the transition come from global.css so every submit button
   darkens on hover the same way. */
form button[type="submit"] {
    width: auto;
    align-self: flex-start;
    min-height: 40px;
    padding: 9px 18px;
    border: none;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 700;
    margin-top: 4px;
}

form button[type="submit"]:hover { background-color: var(--primary-hover); }

body.dark-mode form button[type="submit"]:hover { background-color: #106557; }

.login-form button[type="submit"] {
    width: 100%;
    align-self: stretch;
    box-shadow: 0 10px 26px rgba(8, 36, 32, 0.22);
}

/* =========================================
   Dialog buttons built inline (modals, confirmations)
   ========================================= */
.dialog-btn {
    transition: background-color 0.18s ease, filter 0.18s ease, transform 0.1s ease;
}

.dialog-btn:hover { filter: brightness(0.92); }
.dialog-btn:active { transform: scale(0.985); }
.dialog-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.dialog-btn--ghost:hover { background-color: rgba(14, 93, 82, 0.08) !important; }

.dialog-close {
    border-radius: 9px;
    transition: background-color 0.18s ease;
}

.dialog-close:hover { background-color: rgba(14, 93, 82, 0.1) !important; }

/* =========================================
   Support chat
   ========================================= */
.chat-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 380px;
    min-height: 120px;
    overflow-y: auto;
    padding: 6px 2px;
}

.chat-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 78%;
}

.chat-row.mine { align-self: flex-end; align-items: flex-end; }

.chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-row.mine .chat-bubble {
    background: var(--button-bg);
    border-color: transparent;
    color: #fff;
}

.chat-meta { font-size: 11px; color: var(--text-muted); }

.chat-compose {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 14px;
}

.chat-compose textarea { flex: 1; min-height: 46px; max-height: 150px; }

body.dark-mode .chat-bubble { background: rgba(255, 255, 255, 0.05); }

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
}

button.thread-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 11px 12px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.5);
    color: var(--text);
    font-weight: 400;
    text-align: left;
    cursor: pointer;
}

button.thread-item:hover { background: rgba(14, 93, 82, 0.06); }

button.thread-item.active {
    background: var(--teal-100);
    border-color: var(--teal-200);
}

body.dark-mode button.thread-item { background: rgba(255, 255, 255, 0.03); }
body.dark-mode button.thread-item:hover { background: rgba(255, 255, 255, 0.06); }
body.dark-mode button.thread-item.active {
    background: rgba(95, 192, 175, 0.12);
    border-color: rgba(95, 192, 175, 0.3);
}

.thread-unread {
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 800;
    padding: 1px 7px;
}

/* =========================================
   Platform admin console
   ========================================= */
.admin-panel { animation: fade-in 0.22s ease; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.member-name {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.avatar-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--teal-100);
    color: var(--teal-700);
    font-size: 12.5px;
    font-weight: 700;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

body.dark-mode .avatar-dot {
    background: rgba(185, 223, 216, 0.12);
    color: var(--teal-200);
}

.query-list { display: flex; flex-direction: column; gap: 12px; }

.query {
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 15px 16px;
    background: rgba(255, 255, 255, 0.55);
    transition: border-color 0.18s;
}

body.dark-mode .query { background: rgba(255, 255, 255, 0.03); }

.query.unread { border-left: 3px solid var(--button-bg); }
.query.read { opacity: 0.72; }

.query-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 14px;
}

.query-body {
    color: var(--text);
    font-size: 14px;
    white-space: pre-wrap;
    margin-bottom: 10px;
}

/* =========================================
   Content pages
   ========================================= */
.prose-card { max-width: 860px; }

.prose {
    color: var(--text);
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
}

/* =========================================
   Small screens
   ========================================= */
@media (max-width: 640px) {
    .login-card { padding: 32px 22px; border-radius: 18px; }
    .login-header h1 { font-size: 24px; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
    .pos-items-pane { min-height: 0; padding: 14px; }
    .filter-row { flex-wrap: wrap; }
    .filter-row .filter-btn { flex: 1 1 140px; }
    .filter-row #date-filter, .filter-row #attendant-filter { max-width: none; }
    .filter-row #export-csv { margin-left: 0; width: 100%; }
    .stat-strip { gap: 14px; }
    .stat-value { font-size: 25px; }
    .stat-divider { display: none; }
    .seg-tabs { width: 100%; justify-content: space-between; }
    .seg-btn { flex: 1; text-align: center; padding: 9px 8px; font-size: 12.5px; }
    .cart-list { max-height: none; }
    .cart-pane { min-height: 0; }
}

/* Profile page: identity header and training lessons */
.profile-header {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.profile-avatar {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg);
    border: 1px solid var(--border);
}

.profile-avatar.fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--button-bg);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
}

.training-bar {
    height: 8px;
    margin-top: 12px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.training-bar span {
    display: block;
    height: 100%;
    background: var(--button-bg);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.lesson {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    background: var(--card-bg);
}

.lesson summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
}

.lesson summary::-webkit-details-marker { display: none; }

.lesson[open] summary { border-bottom: 1px solid var(--border); }

.lesson-body { padding: 14px 16px 16px; }

.lesson-body ol {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    line-height: 1.6;
}

.lesson-points {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.lesson.done .lesson-points { color: var(--success); }
