/*
 * Copyright (c) 2025-2026 1ai.dev
 * Developed with ❤️ by A.K.Mishra
 *
 * Travelling Buddies — Brand Design Tokens (v2.6)
 *
 * Single source of truth for spacing, radii, shadows, type scale,
 * motion and elevation. Component layers (custom_style.css,
 * components.css, page-specific CSS) MUST consume these tokens
 * instead of hard-coded values.
 *
 * Color tokens live in custom_style.css (kept for backwards
 * compatibility with pages that already import only that file).
 * This file augments — it does not redefine — the color set.
 */

:root {
    /* ─────────────── Spacing scale (4px base) ─────────────── */
    --tb-space-0:  0;
    --tb-space-1:  0.25rem;   /* 4  */
    --tb-space-2:  0.5rem;    /* 8  */
    --tb-space-3:  0.75rem;   /* 12 */
    --tb-space-4:  1rem;      /* 16 */
    --tb-space-5:  1.5rem;    /* 24 */
    --tb-space-6:  2rem;      /* 32 */
    --tb-space-7:  3rem;      /* 48 */
    --tb-space-8:  4rem;      /* 64 */

    /* ─────────────── Radii ─────────────── */
    --tb-radius-xs: 4px;
    --tb-radius-sm: 6px;
    --tb-radius-md: 10px;
    --tb-radius-lg: 16px;
    --tb-radius-xl: 24px;
    --tb-radius-pill: 999px;

    /* ─────────────── Shadows (warm, low-spread) ─────────────── */
    --tb-shadow-xs: 0 1px 2px rgba(38, 70, 83, 0.06);
    --tb-shadow-sm: 0 2px 6px rgba(38, 70, 83, 0.08);
    --tb-shadow-md: 0 6px 16px rgba(38, 70, 83, 0.10);
    --tb-shadow-lg: 0 14px 28px rgba(38, 70, 83, 0.14);
    --tb-shadow-focus: 0 0 0 3px rgba(42, 157, 143, 0.35);

    /* ─────────────── Neumorphism (soft UI) elevation ───────────────
       A consistent surface tone with dual light/dark shadows that make
       elements appear extruded (raised) or carved (inset). Semantic
       colours are preserved by component rules; only the surface and
       elevation change. */
    --tb-neu-bg:    #eceadf;                       /* shared soft surface */
    --tb-neu-bg-2:  #e6e3d6;                        /* slightly recessed */
    --tb-neu-light: rgba(255, 255, 255, 0.85);      /* top-left highlight */
    --tb-neu-dark:  rgba(38, 70, 83, 0.16);         /* bottom-right shade */
    --tb-shadow-neu-sm:     5px 5px 10px var(--tb-neu-dark), -5px -5px 10px var(--tb-neu-light);
    --tb-shadow-neu:        7px 7px 16px var(--tb-neu-dark), -7px -7px 16px var(--tb-neu-light);
    --tb-shadow-neu-lg:    11px 11px 24px var(--tb-neu-dark), -10px -10px 22px var(--tb-neu-light);
    --tb-shadow-neu-inset: inset 4px 4px 9px var(--tb-neu-dark), inset -4px -4px 9px var(--tb-neu-light);
    --tb-shadow-neu-pressed: inset 5px 5px 11px var(--tb-neu-dark), inset -5px -5px 11px var(--tb-neu-light);

    /* ─────────────── Type scale (modular ratio 1.2) ─────────────── */
    --tb-text-xs:   0.75rem;   /* 12 */
    --tb-text-sm:   0.875rem;  /* 14 */
    --tb-text-base: 1rem;      /* 16 */
    --tb-text-md:   1.125rem;  /* 18 */
    --tb-text-lg:   1.25rem;   /* 20 */
    --tb-text-xl:   1.5rem;    /* 24 */
    --tb-text-2xl:  1.875rem;  /* 30 */
    --tb-text-3xl:  2.25rem;   /* 36 */
    --tb-text-4xl:  3rem;      /* 48 */

    --tb-leading-tight:  1.2;
    --tb-leading-snug:   1.35;
    --tb-leading-normal: 1.55;
    --tb-leading-loose:  1.8;

    /* ─────────────── Motion ─────────────── */
    --tb-ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --tb-ease-in:     cubic-bezier(0.7, 0, 0.84, 0);
    --tb-ease-in-out: cubic-bezier(0.83, 0, 0.17, 1);
    --tb-dur-instant: 80ms;
    --tb-dur-fast:    160ms;
    --tb-dur-base:    240ms;
    --tb-dur-slow:    400ms;

    /* ─────────────── Z-index scale ─────────────── */
    --tb-z-base:    1;
    --tb-z-sticky:  100;
    --tb-z-overlay: 800;
    --tb-z-modal:   1000;
    --tb-z-toast:   1100;

    /* ─────────────── Surfaces (used by components) ─────────────── */
    --tb-surface-1: #FFFFFF;                  /* card */
    --tb-surface-2: #FBF8EE;                  /* slightly darker than parchment */
    --tb-surface-3: rgba(38, 70, 83, 0.04);   /* subtle wash */
    --tb-border:    rgba(38, 70, 83, 0.12);
    --tb-border-strong: rgba(38, 70, 83, 0.22);
    --tb-text-muted:    #5b6770;

    /* ─────────────── Brand-tinted state colors ─────────────── */
    --tb-primary-50:  #e9f0f1;
    --tb-primary-100: #c7d6da;
    --tb-primary-300: #6f8f99;
    --tb-primary-700: #1a3440;
    --tb-secondary-50:  #e7f5f3;
    --tb-secondary-100: #c1e6e1;
    --tb-secondary-700: #1f7167;
}

/* ─────────────── Accessibility primitives ─────────────── */

/* Visible focus ring on every interactive element. Bootstrap's default
   blue ring clashes with the brand palette; override globally. */
:where(a, button, [role="button"], input, select, textarea, [tabindex]):focus-visible {
    outline: none;
    box-shadow: var(--tb-shadow-focus);
    border-radius: var(--tb-radius-sm);
}

/* Honor user reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Skip-link helper, used by templates/header.php */
.tb-skip-link {
    position: absolute;
    top: -40px;
    left: var(--tb-space-4);
    background: var(--tb-primary);
    color: #fff;
    padding: var(--tb-space-2) var(--tb-space-4);
    border-radius: var(--tb-radius-sm);
    z-index: var(--tb-z-toast);
    transition: top var(--tb-dur-fast) var(--tb-ease-out);
}
.tb-skip-link:focus {
    top: var(--tb-space-3);
}

/* ============================================================
   Coordinator contact card
   ============================================================ */
.coordinator-card {
    display: block;
    background: var(--tb-card-bg, #fff);
    border-radius: var(--tb-radius-lg);
    box-shadow: var(--tb-shadow-md);
    overflow: hidden;
    border: 1px solid rgba(38, 70, 83, 0.08);
}
.coordinator-card__strip {
    height: 4px;
    width: 100%;
    background: var(--tb-secondary);
}
.coordinator-card__body {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--tb-space-4);
    align-items: center;
    padding: var(--tb-space-4) var(--tb-space-5);
}
@media (max-width: 575.98px) {
    .coordinator-card__body {
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "avatar meta"
            "actions actions";
        gap: var(--tb-space-3) var(--tb-space-4);
    }
    .coordinator-card__avatar { grid-area: avatar; }
    .coordinator-card__meta   { grid-area: meta; }
    .coordinator-card__actions{ grid-area: actions; justify-content: flex-end; }
}
.coordinator-card__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--tb-primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-family: var(--tb-font-heading, var(--tb-font-sans-serif));
    font-weight: 700;
    font-size: 1.5rem;
    overflow: hidden;
    flex-shrink: 0;
}
.coordinator-card__avatar img {
    width: 100%; height: 100%; object-fit: cover;
}
.coordinator-card__meta { min-width: 0; }
.coordinator-card__label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tb-body-color, #555);
    opacity: 0.75;
    margin-bottom: 2px;
}
.coordinator-card__team { font-weight: 600; opacity: 0.95; }
.coordinator-card__name {
    font-family: var(--tb-font-heading, var(--tb-font-sans-serif));
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--tb-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.coordinator-card__phone {
    font-size: 0.95rem;
    color: var(--tb-body-color);
    display: flex;
    align-items: center;
    gap: var(--tb-space-2);
}
.coordinator-card__phone-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed currentColor;
}
.coordinator-card__phone-link:hover,
.coordinator-card__phone-link:focus {
    color: var(--tb-secondary);
}
.coordinator-card__phone--none { opacity: 0.6; }
.coordinator-card__actions {
    display: flex;
    gap: var(--tb-space-2);
}

/* ============================================================
   Coordinator one-time flash toast
   ============================================================ */
.coordinator-toast {
    position: fixed;
    inset-inline: var(--tb-space-4);
    bottom: var(--tb-space-5);
    z-index: var(--tb-z-toast);
    display: flex;
    gap: var(--tb-space-3);
    align-items: center;
    background: var(--tb-primary);
    color: #fff;
    padding: var(--tb-space-3) var(--tb-space-4);
    border-radius: var(--tb-radius-lg);
    box-shadow: var(--tb-shadow-lg);
    transform: translateY(140%);
    opacity: 0;
    transition: transform var(--tb-dur-base) var(--tb-ease-out),
                opacity var(--tb-dur-base) var(--tb-ease-out);
    max-width: 420px;
    margin-inline: auto;
}
.coordinator-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}
.coordinator-toast__icon {
    width: 36px; height: 36px;
    background: var(--tb-secondary);
    border-radius: 50%;
    display: grid; place-items: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}
.coordinator-toast__body { flex: 1; min-width: 0; line-height: 1.3; }
.coordinator-toast__name { font-weight: 700; }
.coordinator-toast__phone { font-size: 0.85rem; opacity: 0.85; }
.coordinator-toast__close {
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 1.2rem;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: var(--tb-radius-sm);
}
.coordinator-toast__close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ============================================================
   Sub-team admin (manage_trip Sub-teams section)
   ============================================================ */
.subteam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--tb-space-4);
}
.subteam-card {
    background: var(--tb-card-bg, #fff);
    border-radius: var(--tb-radius-md);
    border: 1px solid rgba(38, 70, 83, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.subteam-card__header {
    padding: var(--tb-space-3) var(--tb-space-4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--tb-space-3);
}
.subteam-card__name { font-weight: 700; font-size: 1.05rem; }
.subteam-card__count {
    background: rgba(255,255,255,0.18);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.8rem;
}
.subteam-card__body {
    padding: var(--tb-space-3) var(--tb-space-4);
    flex: 1;
}
.subteam-card__coordinator {
    font-size: 0.9rem;
    color: var(--tb-primary);
}
.subteam-card__coordinator strong { font-weight: 700; }
.subteam-card__actions {
    border-top: 1px solid rgba(38,70,83,0.08);
    padding: var(--tb-space-2) var(--tb-space-3);
    display: flex;
    gap: var(--tb-space-2);
    justify-content: flex-end;
}
.subteam-color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    transition: transform 120ms ease, box-shadow 120ms ease;
}
.subteam-color-option { display: inline-flex; cursor: pointer; }
.subteam-color-option:hover .subteam-color-swatch { transform: scale(1.08); }
.subteam-color-option input[type="radio"]:checked + .subteam-color-swatch {
    transform: scale(1.15);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tb-secondary, #2A9D8F);
}
.subteam-color-option input[type="radio"]:focus-visible + .subteam-color-swatch {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tb-secondary, #2A9D8F);
}

/* ============================================================
   Trip Detail (view_trip.php) polish
   - Compact stats row: cleaner separators on desktop
   - Sticky in-page tab nav so users can jump while scrolling
   ============================================================ */
.tb-stats-row > [class*='col-'] > .card {
    border: 1px solid rgba(38, 70, 83, 0.08);
    transition: transform var(--tb-dur-fast, 150ms) var(--tb-ease-out, ease),
                box-shadow var(--tb-dur-fast, 150ms) var(--tb-ease-out, ease);
}
.tb-stats-row > [class*='col-'] > .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tb-shadow-md);
}
.tb-stats-row .card-body p.h3 {
    color: var(--tb-primary);
    font-weight: 700;
    line-height: 1;
}

@media (min-width: 992px) {
    .tb-trip-tabs-card .tb-trip-tabs-header {
        position: sticky;
        top: 0;
        z-index: 5;
        background: var(--tb-card-bg, #fff);
        border-bottom: 1px solid rgba(38, 70, 83, 0.08);
        backdrop-filter: saturate(1.2);
    }
}
.tb-trip-tabs-header .nav-tabs .nav-link {
    color: var(--tb-body-color, #333);
    font-weight: 500;
}
.tb-trip-tabs-header .nav-tabs .nav-link.active {
    color: var(--tb-primary);
    font-weight: 700;
    border-bottom-color: var(--tb-secondary);
}

/* ============================================================
   My Trips (my_trips.php) polish — consistent trip cards
   ============================================================ */
.trip-card {
    border: 1px solid rgba(38, 70, 83, 0.08);
    border-radius: var(--tb-radius-lg);
    overflow: hidden;
    transition: transform var(--tb-dur-fast, 150ms) var(--tb-ease-out, ease),
                box-shadow var(--tb-dur-fast, 150ms) var(--tb-ease-out, ease);
}
.trip-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--tb-shadow-lg);
}
.trip-card .card-title {
    color: var(--tb-primary);
    font-weight: 700;
}
/* Harden the cover image so a broken / missing cover_image_url
   never lets alt-text or absolutely-positioned children explode the layout. */
.trip-card .trip-card-image {
    height: 180px;
    background: linear-gradient(135deg, var(--tb-primary, #264653), var(--tb-secondary, #2A9D8F));
    overflow: hidden;
    position: relative;
}
.trip-card .trip-card-image img.card-img-top {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}
.trip-card .role-badge {
    position: absolute;
    top: var(--tb-space-3);
    right: var(--tb-space-3);
    /* Explicitly clear bottom/left from base .role-badge to avoid stretching */
    bottom: auto;
    left: auto;
    width: auto;
    padding: 4px 10px;
    border-radius: var(--tb-radius-pill);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

/* ============================================================
   Generic accessibility & motion
   ============================================================ */
:focus-visible {
    outline: 3px solid var(--tb-secondary);
    outline-offset: 2px;
    border-radius: var(--tb-radius-xs);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
    }
}
