/* ================================================================
   GuideXpresse Service — stylesheet
   Design system aligned with infotainment.guide
   ================================================================ */

/* --- Design tokens ------------------------------------------- */
:root {
    --ink:        #1C2B2D;
    --ink-soft:   #4A5B5D;
    --bg:         #FAF8F5;
    --sand:       #E8E1D6;
    --sand-line:  #D8CEBE;
    --teal:       #3D6B5C;
    --teal-deep:  #2A4B40;
    --teal-tint:  #E4ECE8;
    --radius:     12px;
}

/* --- Reset & base -------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background-color: var(--bg);
    min-height: 100vh;
}

a        { color: inherit; }
button   { font-family: inherit; }
img      { max-width: 100%; }

/* --- Topbar --------------------------------------------------- */
.topbar {
    background: var(--ink);
    color: #fff;
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(28,43,45,.35);
}

.topbar__inner {
    max-width: 1152px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar__brand {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -.01em;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar__logout {
    font-size: .875rem;
    color: #fff;
    text-decoration: underline;
    opacity: .65;
}
.topbar__logout:hover { opacity: 1; }

/* Role badge (button inside topbar) */
.role-badge {
    display: inline-block;
    padding: .25rem .75rem;
    border-radius: 9999px;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: filter .15s;
    line-height: 1.5;
}
.role-badge:hover            { filter: brightness(1.15); }
.role-badge--superuser       { background: #2563eb; color: #fff; }
.role-badge--admin           { background: #f97316; color: #fff; }
.role-badge--user            { background: var(--teal); color: #fff; }

/* --- Page layout --------------------------------------------- */
.page {
    max-width: 1152px;
    margin: 0 auto;
    padding: 1.5rem;
}
.page--md  { max-width:  896px; margin: 0 auto; padding: 1.5rem; }
.page--sm  { max-width:  672px; margin: 0 auto; padding: 1.5rem; }
.page--xs  { max-width:  448px; margin: 0 auto; padding: 1.5rem; }

/* --- Cards ---------------------------------------------------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(28,43,45,.07);
    padding: 1.5rem;
    border: 1px solid var(--sand-line);
}
.card--padded { padding: 2rem; }

.card--link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: box-shadow .15s;
}
.card--link:hover {
    box-shadow: 0 4px 24px rgba(28,43,45,.12);
}

/* --- Buttons -------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .625rem 1.25rem;
    font-size: .875rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s, opacity .15s, transform .1s;
    font-family: inherit;
    line-height: 1.5;
}
.btn:active  { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary    { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-deep); }

.btn--danger     { background: #b91c1c; color: #fff; }
.btn--danger:hover  { background: #991b1b; }

.btn--success    { background: #15803d; color: #fff; }
.btn--success:hover { background: #166534; }

.btn--secondary  { background: var(--sand); color: var(--ink); border-color: var(--sand-line); }
.btn--secondary:hover { background: var(--sand-line); }

.btn--outline    { background: transparent; color: var(--ink); border-color: var(--sand-line); }
.btn--outline:hover  { background: var(--sand); }

.btn--blue       { background: #2563eb; color: #fff; }
.btn--blue:hover { background: #1d4ed8; }

.btn--ghost      { background: transparent; color: var(--ink-soft); border: none; }
.btn--ghost:hover { background: var(--sand); }

.btn--lg    { padding: .875rem 1.5rem; font-size: 1rem; border-radius: var(--radius); }
.btn--sm    { padding: .3125rem .75rem; font-size: .8125rem; }
.btn--full  { width: 100%; }

/* Icon-only button used in tables */
.btn--icon {
    padding: .375rem .5rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    font-size: 1.125rem;
    color: var(--ink-soft);
    line-height: 1;
}
.btn--icon:hover { color: var(--ink); background: var(--sand); }

/* --- Forms ---------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: .375rem; }

.form-label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--ink);
}

.form-control {
    width: 100%;
    border: 1px solid var(--sand-line);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-tint);
}
.form-control--lg   { font-size: 1.125rem; padding: .875rem 1rem; }
.form-control[readonly],
.form-control--readonly {
    background: var(--sand);
    color: var(--ink-soft);
    cursor: not-allowed;
}

textarea.form-control { resize: vertical; min-height: 6rem; }

.form-hint { font-size: .75rem; color: var(--ink-soft); }

/* Code-style input (login code) */
.form-control--code {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: .5rem;
    font-family: 'Courier New', monospace;
}

/* --- Alerts --------------------------------------------------- */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 1.5rem;
}
.alert--success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.alert--error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.alert--warning { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.alert--info    { background: var(--teal-tint); border-color: var(--teal); color: var(--teal-deep); }

/* --- Badges --------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .1875rem .625rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 500;
}
.badge--gray   { background: var(--sand); color: var(--ink-soft); }
.badge--green  { background: #dcfce7; color: #166534; }
.badge--orange { background: #fed7aa; color: #9a3412; }
.badge--blue   { background: #dbeafe; color: #1e40af; }
.badge--amber  { background: #fef3c7; color: #92400e; }

/* --- Grid ---------------------------------------------------- */
.grid    { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .grid--3 { grid-template-columns: repeat(2, 1fr); }
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .grid--2,
    .grid--3,
    .grid--4 { grid-template-columns: 1fr; }
}

/* --- Form rows (inline groups) ------------------------------- */
.form-row    { display: grid; gap: 1rem; }
.form-row--2 { grid-template-columns: repeat(2, 1fr); }
.form-row--3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 600px) {
    .form-row--2, .form-row--3 { grid-template-columns: 1fr; }
}

/* --- Flex helpers -------------------------------------------- */
.flex         { display: flex; }
.flex--center { align-items: center; }
.flex--between { justify-content: space-between; }
.flex--end    { justify-content: flex-end; }
.flex--gap    { gap: .75rem; }
.flex--wrap   { flex-wrap: wrap; }

/* --- Spacing -------------------------------------------------- */
.mt-1 { margin-top: .25rem; }
.mb-1 { margin-bottom: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* --- Typography ---------------------------------------------- */
.page-title     { font-size: 1.875rem; font-weight: 700; margin-bottom: .375rem; color: var(--ink); }
.page-subtitle  { color: var(--ink-soft); margin-bottom: 2rem; }
.section-title  { font-size: 1.5rem; font-weight: 600; }
.text-sm        { font-size: .875rem; }
.text-xs        { font-size: .75rem; }
.text-muted     { color: var(--ink-soft); }
.text-semibold  { font-weight: 600; }
.text-bold      { font-weight: 700; }
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-green     { color: #16a34a; }
.text-red       { color: #dc2626; }
.text-blue      { color: var(--teal); }

/* --- Divider -------------------------------------------------- */
.divider { border: none; border-top: 1px solid var(--sand-line); margin: 1.5rem 0; }

/* --- Back link ----------------------------------------------- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    font-size: .875rem;
    color: var(--ink);
    text-decoration: none;
    margin-bottom: 1.5rem;
    opacity: .7;
}
.back-link:hover { opacity: 1; text-decoration: underline; }

/* --- Section with inset background --------------------------- */
.section-inset {
    background: var(--sand);
    border: 1px solid var(--sand-line);
    border-radius: var(--radius);
    padding: 1.5rem;
}

/* --- Tab navigation (large icon cards) ----------------------- */
.tab-nav {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.tab-nav--1 { grid-template-columns: 1fr; }
.tab-nav--2 { grid-template-columns: repeat(2, 1fr); }
.tab-nav--3 { grid-template-columns: repeat(3, 1fr); }
.tab-nav--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 640px) {
    .tab-nav--3 { grid-template-columns: repeat(2, 1fr); }
    .tab-nav--4 { grid-template-columns: repeat(2, 1fr); }
}

.tab-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(28,43,45,.06);
    border: 1px solid var(--sand-line);
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s;
    display: block;
}
.tab-card:hover         { box-shadow: 0 4px 24px rgba(28,43,45,.1); border-color: var(--teal); }
.tab-card.is-active     { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); }
.tab-card__icon         { font-size: 2rem; margin-bottom: .5rem; }
.tab-card__label        { font-size: 1.125rem; font-weight: 600; }

/* --- Item cards (batch, client overview) --------------------- */
.item-card {
    display: block;
    border: 1px solid var(--sand-line);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    position: relative;
    transition: box-shadow .15s, border-color .15s;
    background: #fff;
}
.item-card:hover { box-shadow: 0 4px 20px rgba(28,43,45,.09); border-color: var(--teal); }

.item-card__title  { font-weight: 600; font-size: 1rem; }
.item-card__meta   { font-size: .875rem; color: var(--ink-soft); margin-top: .125rem; }
.item-card__badges { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.item-card__check  { color: #16a34a; font-size: 1.25rem; font-weight: 700; }

/* Small note indicator dot in top-right of item card */
.item-card__note {
    position: absolute;
    top: .625rem;
    right: .625rem;
    width: 1.375rem;
    height: 1.375rem;
    background: #fef3c7;
    color: #b45309;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    box-shadow: 0 1px 2px rgba(28,43,45,.1);
}

/* Delete form overlaid on item card (positioned; button inside is static) */
.item-card__delete-form {
    position: absolute;
    top: .5rem;
    right: 2rem;
    z-index: 5;
}

/* Delete button inside the above form */
.item-card__delete {
    background: none;
    border: none;
    cursor: pointer;
    color: #b91c1c;
    font-size: 1.25rem;
    padding: .25rem;
    line-height: 1;
}
.item-card__delete:hover { color: #991b1b; }

/* --- User list items ----------------------------------------- */
.user-item {
    display: block;
    border: 1px solid var(--sand-line);
    border-radius: var(--radius);
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    transition: background-color .15s;
    background: #fff;
}
.user-item:hover       { background: var(--sand); }
.user-item__row        { display: flex; justify-content: space-between; align-items: center; }
.user-item__name       { font-weight: 600; }
.user-item__email      { font-size: .875rem; color: var(--ink-soft); margin-top: .125rem; }

/* --- Amber note block (batch remark display) ----------------- */
.note-block {
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: .75rem;
    background: #fffbeb;
    border: 1px solid #fcd34d;
}
.note-block__icon   { flex-shrink: 0; color: #b45309; margin-top: .1rem; }
.note-block__inner  { flex: 1; }
.note-block__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .375rem;
}
.note-block__title  { font-weight: 600; color: #92400e; font-size: .875rem; }
.note-block__body   { font-size: .875rem; color: #92400e; white-space: pre-wrap; }

/* --- Tables -------------------------------------------------- */
.table-wrap  { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.table thead tr         { background: var(--sand); }
.table th {
    text-align: left;
    padding: .75rem;
    font-weight: 600;
    font-size: .8125rem;
    color: var(--ink-soft);
}
.table th.th--right,
.table td.td--right    { text-align: right; }
.table td {
    padding: .75rem;
    border-bottom: 1px solid var(--sand-line);
    vertical-align: middle;
}
.table tbody tr:hover   { background: var(--sand); }
.table td a             { color: var(--teal); text-decoration: none; }
.table td a:hover       { text-decoration: underline; color: var(--teal-deep); }

/* --- Action row (form button groups) ------------------------- */
.action-row {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
}
.action-row--between { justify-content: space-between; }
.action-row--end     { justify-content: flex-end; }

@media (max-width: 600px) {
    .action-row             { flex-direction: column; }
    .action-row .btn        { width: 100%; }
}

/* Stack of list items */
.stack > * + * { margin-top: .75rem; }

/* --- Status done bar ----------------------------------------- */
.status-done {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: #f0fdf4;
    color: #166534;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-top: 1.5rem;
    font-weight: 500;
}

/* --- Empty state --------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-soft);
    font-style: italic;
}

/* --- Login page ---------------------------------------------- */
.login-wrap {
    min-height: calc(100vh - 5rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-box {
    width: 100%;
    max-width: 26rem;
}

.login-message {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--sand-line);
    padding: 1rem;
    text-align: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 12px rgba(28,43,45,.07);
}

.login-resend {
    display: block;
    text-align: center;
    font-size: .875rem;
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--ink);
    margin-top: .5rem;
}
.login-resend:hover { color: var(--teal); }

/* --- Modals -------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28,43,45,.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.is-open { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 25px 50px rgba(28,43,45,.25);
    padding: 2rem;
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.modal__title    { font-size: 1.5rem; font-weight: 600; color: var(--ink); }
.modal__subtitle { font-size: .875rem; color: var(--ink-soft); margin-top: .25rem; }

.modal__close {
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--ink-soft);
    cursor: pointer;
    padding: .125rem .25rem;
    flex-shrink: 0;
}
.modal__close:hover { color: var(--ink); }

/* Footer stripe inside modal */
.modal__footer {
    background: var(--sand);
    margin: 1.5rem -2rem -2rem;
    padding: 1rem 2rem;
    border-radius: 0 0 var(--radius) var(--radius);
    border-top: 1px solid var(--sand-line);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

.modal__scrollable { max-height: 22rem; overflow-y: auto; }

/* History entries */
.history-entry {
    border: 1px solid var(--sand-line);
    border-radius: var(--radius);
    padding: 1rem;
    background: #fff;
}
.history-entry + .history-entry { margin-top: .75rem; }
.history-entry__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .875rem;
    gap: .5rem;
}
.history-entry__meta { font-size: .75rem; color: var(--ink-soft); margin-top: .5rem; }

/* Account info block inside user modal */
.account-block {
    background: var(--sand);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.account-block__label  { color: var(--ink-soft); font-size: .875rem; }
.account-block__role   { font-size: 1.5rem; font-weight: 700; margin-top: .25rem; color: var(--ink); }
.account-block__desc {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px solid var(--sand-line);
    font-size: .875rem;
    color: var(--ink-soft);
    line-height: 1.6;
}

/* --- Utility ------------------------------------------------- */
.hidden  { display: none; }
.w-full  { width: 100%; }
.flex-1  { flex: 1; }
.form--inline { display: inline; }

/* Stacked form (flex column with gap) */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Inline button group */
.btn-group {
    display: flex;
    gap: .75rem;
}
.btn-group--end {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    align-items: center;
}

/* Form-row align-items variant */
.form-row--end { align-items: flex-end; }

/* Narrow card (user/form column ~42 rem) */
.card--narrow { max-width: 42rem; }

/* Admin nav cards on index.php */
.card--nav {
    text-align: center;
    padding: 2rem 1rem;
}

/* --- Client cards (superuser dashboard) ---------------------- */
.client-card {
    display: block;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(28,43,45,.06);
    border: 1px solid var(--sand-line);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .15s, border-color .15s;
}
.client-card:hover { box-shadow: 0 4px 24px rgba(28,43,45,.1); border-color: var(--teal); }

.client-card__name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .5rem;
}
.client-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
}

/* --- Vervanging expand section ------------------------------- */
.vervanging-section {
    display: none;
    flex-direction: column;
    gap: 1rem;
}
.vervanging-section.is-open { display: flex; }
