/* Co-Localiser — colours from logo.jpeg */
:root {
    --purple: #5d478b;
    --purple-dark: #4a386f;
    --purple-light: #7b6ba8;
    --purple-bg: #f3f0f8;
    --white: #ffffff;
    --text: #2d2640;
    --text-muted: #6b6280;
    --border: #e0dae8;
    --error: #c0392b;
    --success: #27ae60;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(93, 71, 139, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--purple-bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--purple);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-decoration: none;
    color: var(--white);
}

.sidebar-guest {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.5;
    opacity: 0.9;
    padding: 0 0.25rem;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    transition: background 0.15s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1rem;
}

.user-info {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-bottom: 0.75rem;
}

.content-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mobile-header {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

.main {
    flex: 1;
    padding: 2rem;
    min-width: 0;
}

/* Login (standalone — no sidebar) */
.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
}

.login-page-standalone {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--white);
    border-radius: calc(var(--radius) + 4px);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    margin-bottom: 1rem;
}

.login-card h1 {
    color: var(--purple);
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.login-form {
    text-align: left;
}

.login-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    margin-top: 0.75rem;
}

.auth-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.auth-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.login-card .btn-outline {
    color: var(--purple);
    border-color: var(--purple);
}

.login-card .btn-outline:hover {
    background: var(--purple);
    color: var(--white);
}

.auth-switch {
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--purple);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.field-error {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-primary {
    background: var(--purple);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--purple-dark);
}

.btn-outline {
    background: transparent;
    color: var(--purple);
    border-color: var(--purple);
}

.btn-outline:hover {
    background: var(--purple);
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 1rem;
}

.sidebar .btn-outline {
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.5);
}

.sidebar .btn-outline:hover {
    background: var(--white);
    color: var(--purple);
}

/* Forms */
.form-input {
    width: 100%;
    padding: 0.65rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--purple-light);
}

.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-bar .form-input {
    flex: 1;
    min-width: 200px;
}

/* Page */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    color: var(--purple-dark);
    font-size: 1.75rem;
}

.page-header p {
    color: var(--text-muted);
}

.role-hint {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-left: 4px solid var(--purple);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.field-cta {
    display: block;
    background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
    color: var(--white);
    text-decoration: none;
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}

.field-cta:hover {
    transform: translateY(-2px);
}

.field-cta-title {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.field-cta-desc {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
}

.role-hint a {
    color: var(--purple);
    font-weight: 600;
}

.back-link {
    color: var(--purple);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--purple);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Cards */
.section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    color: var(--purple-dark);
    font-size: 1.2rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.pop-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

.pop-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(93, 71, 139, 0.18);
}

.pop-card h3 {
    color: var(--purple);
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.pop-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.2rem 0.6rem;
    background: var(--purple-bg);
    color: var(--purple);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Table */
.content-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .content-split {
        grid-template-columns: 1fr;
    }

    .content-split > .map,
    .content-split > [id$="-map"] {
        order: -1;
    }

    .map-list,
    .map-detail,
    .map {
        min-height: 280px;
        height: 40vh;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .detail-list {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .detail-list dt {
        margin-top: 0.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        background: var(--purple);
        color: var(--white);
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }

    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        padding: 10px;
        background: rgba(255, 255, 255, 0.12);
        border: none;
        border-radius: 10px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .menu-bar {
        display: block;
        width: 100%;
        height: 2px;
        background: var(--white);
        border-radius: 2px;
    }

    .mobile-header-title {
        font-weight: 600;
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-backdrop.is-visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(45, 38, 64, 0.55);
        z-index: 200;
    }

    body.nav-open {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 300;
        width: min(280px, 88vw);
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .main {
        padding: 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .nav-link {
        padding: 0.75rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar .form-input,
    .search-bar .btn {
        width: 100%;
        min-width: 0;
    }

    .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
    }

    .login-page-standalone .login-card {
        padding: 1.5rem;
    }

    .login-page-standalone .form-input,
    .login-page-standalone input[type="text"],
    .login-page-standalone input[type="password"] {
        font-size: 16px;
    }

    .data-table {
        font-size: 0.875rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.65rem 0.75rem;
        white-space: nowrap;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-input,
    .field-search-input,
    input[type="search"],
    input[type="text"],
    input[type="password"],
    select {
        font-size: 16px;
    }
}

.pop-table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--purple-bg);
    color: var(--purple-dark);
    font-size: 0.85rem;
    font-weight: 600;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.1s;
}

.clickable-row:hover {
    background: var(--purple-bg);
}

/* Map */
.map {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-height: 400px;
    z-index: 1;
}

.map-list {
    min-height: 500px;
}

.map-detail {
    min-height: 450px;
}

/* Detail */
.detail-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.detail-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.detail-card h2 {
    color: var(--purple-dark);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.detail-subheading {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0.75rem 0 0.35rem;
}

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1.5rem;
    margin-bottom: 0.5rem;
}

.detail-list dt {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.detail-list dd {
    font-size: 0.95rem;
}

.route-list {
    list-style: none;
    padding: 0;
}

.route-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.route-list li:last-child {
    border-bottom: none;
}

.link-list a {
    color: var(--purple);
    text-decoration: none;
    font-weight: 500;
}

.link-list a:hover {
    text-decoration: underline;
}

.link-distance {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.link-description {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: #fdecea;
    color: var(--error);
}

.empty-text {
    color: var(--text-muted);
    padding: 1.5rem;
    text-align: center;
}

code {
    background: var(--purple-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}
