﻿/* =============================
   Traxly App (tokens + base)
   ============================= */

.traxly-app {
    --bg: #0b1220;
    --panel: rgba(255,255,255,.03);
    --panel-2: rgba(255,255,255,.04);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: rgba(148,163,184,.20);
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    display: grid;
    grid-template-columns: 260px 1fr;
    min-width: 0; /* important for grid children */
}

/* Prevent accidental horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
}

.traxly-main,
.traxly-content {
    min-width: 0; /* prevent tables forcing width */
}

/* =============================
   App Shell (sidebar + topbar)
   ============================= */

/* Sidebar (desktop) */
.traxly-sidebar {
    background: linear-gradient(180deg, #0b1530 0%, #101a33 55%, #0b1220 100%);
    border-right: 1px solid var(--border);
    padding: 14px;
}

.traxly-brand {
    font-weight: 700;
    letter-spacing: .3px;
    padding: 12px 10px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.03);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 84px;
    overflow: hidden;
}

.traxly-wordmark {
    height: 100% !important;
    width: auto !important;
    transform: scale(6) !important;
    transform-origin: center;
    display: block;
}

/* Main shell */
.traxly-main {
    display: grid;
    grid-template-rows: 56px 1fr;
}

.traxly-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.02);
}

.traxly-hamburger {
    display: none;
    border: 1px solid rgba(148,163,184,.22);
    background: rgba(255,255,255,.04);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    line-height: 1;
}

.traxly-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    border: 0;
    padding: 0;
    margin: 0;
    z-index: 1150;
}

.traxly-content {
    padding: 18px;
}

/* Surface / card container */
.traxly-surface {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(148,163,184,.20);
    border-radius: 14px;
    padding: 18px;
    box-shadow: var(--shadow);
}

/* =============================
   Nav (sidebar)
   ============================= */

.traxly-nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 6px 4px;
}

.traxly-nav-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.traxly-nav-title {
    color: rgba(229,231,235,.75);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 6px 10px;
}

.traxly-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    color: rgba(229,231,235,.90);
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
}

    .traxly-nav-link:hover {
        background: rgba(255,255,255,.04);
        border-color: rgba(148,163,184,.20);
        color: #fff;
    }

    .traxly-nav-link.active {
        background: rgba(147,197,253,.12);
        border-color: rgba(147,197,253,.35);
        color: #fff;
    }

.traxly-nav-icon {
    width: 22px;
    text-align: center;
    opacity: .9;
}

/* =============================
   Links + Buttons (shared)
   ============================= */

.traxly-link {
    color: #93c5fd;
    text-decoration: none;
}

    .traxly-link:hover:not(.traxly-btn) {
        color: #bfdbfe;
        text-decoration: underline;
    }

.traxly-btn {
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(148,163,184,.22);
    background: rgba(255,255,255,.04);
    color: var(--text);
    text-decoration: none;
}

a.traxly-btn,
a.traxly-btn:hover,
a.traxly-btn:visited,
a.traxly-btn:active,
a.traxly-btn:focus {
    text-decoration: none;
}

.traxly-btn:hover {
    background: rgba(255,255,255,.07);
}

.traxly-btn-primary {
    border-color: rgba(59,130,246,.50);
    background: rgba(59,130,246,.22);
}

    .traxly-btn-primary:hover {
        background: rgba(59,130,246,.28);
    }

.traxly-btn-block {
    width: 100%;
}

/* =============================
   Bootstrap tweaks (dark)
   ============================= */

.traxly-app .table {
    color: var(--text);
}

    .traxly-app .table thead th {
        color: var(--muted);
        border-bottom-color: rgba(148,163,184,.20);
    }

    .traxly-app .table td,
    .traxly-app .table th {
        border-top-color: rgba(148,163,184,.20);
    }

.traxly-app .text-muted {
    color: var(--muted) !important;
}

.traxly-app .badge.text-bg-secondary {
    background: rgba(148,163,184,.18) !important;
    color: var(--text) !important;
    border: 1px solid rgba(148,163,184,.20);
}

.traxly-app .btn-outline-secondary {
    color: var(--text);
    border-color: rgba(148,163,184,.20);
}

    .traxly-app .btn-outline-secondary:hover {
        background: rgba(148,163,184,.12);
    }

.traxly-app .btn-outline-warning {
    border-color: rgba(251,191,36,.55);
    color: #fbbf24;
}

.traxly-app .btn-outline-danger {
    border-color: rgba(248,113,113,.55);
    color: #f87171;
}

/* =============================
   Modals (general + image viewer)
   ============================= */

.traxly-modal-backdrop,
.traxly-img-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(0,0,0,.55);
    -webkit-overflow-scrolling: touch;
}

.traxly-modal-backdrop {
    z-index: 1050;
    max-height: calc(100svh - 32px);
    overflow-y: auto;
}

.traxly-img-overlay {
    z-index: 2000;
}

.traxly-modal,
.traxly-img-modal {
    background: #0f172a;
    color: var(--text);
    border: 1px solid rgba(148,163,184,.20);
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0,0,0,.55);
    overflow: hidden;
}

.traxly-modal {
    width: min(520px, 92vw);
    padding: 16px;
    box-shadow: var(--shadow);
}

    .traxly-modal .traxly-modal-header,
    .traxly-modal .traxly-modal-footer {
        position: sticky;
        background: #0f172a;
        z-index: 1;
    }

    .traxly-modal .traxly-modal-header {
        top: 0;
    }

    .traxly-modal .traxly-modal-footer {
        bottom: 0;
    }

    .traxly-modal .traxly-modal-body {
        background: rgba(255,255,255,.03);
        border: 1px solid rgba(148,163,184,.20);
        border-radius: 10px;
        padding: 12px;
    }

    .traxly-modal h1,
    .traxly-modal h2,
    .traxly-modal h3,
    .traxly-modal h4,
    .traxly-modal h5,
    .traxly-modal h6 {
        color: #f8fafc;
    }

    .traxly-modal .text-muted,
    .traxly-modal small,
    .traxly-modal .small {
        color: #cbd5e1 !important;
    }

    .traxly-modal .btn-close {
        filter: invert(1);
        opacity: .8;
    }

        .traxly-modal .btn-close:hover {
            opacity: 1;
        }

/* Image modal specifics */
.traxly-img-modal {
    width: min(960px, 96vw);
    height: min(90svh, 720px);
    display: flex;
    flex-direction: column;
}

.traxly-img-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid rgba(148,163,184,.18);
    flex: 0 0 auto;
}

.traxly-img-modal-body {
    padding: 12px;
    overflow: auto;
    flex: 1 1 auto;
    display: grid;
    place-items: center;
}

.traxly-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
}

/* =============================
   Auth (Login / Logout / Change Password)
   ============================= */

.traxly-auth {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 20px 16px;
    background: radial-gradient(900px 500px at 15% 10%, rgba(59,130,246,.18), transparent 55%), radial-gradient(900px 500px at 85% 20%, rgba(168,85,247,.16), transparent 60%), var(--bg);
    color: var(--text);
}

.traxly-auth-card {
    width: min(420px, 92vw);
    border-radius: 16px;
    padding: 18px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(148,163,184,.22);
    box-shadow: 0 18px 50px rgba(0,0,0,.45);
    backdrop-filter: blur(8px);
}

.traxly-auth-header {
    margin-bottom: 14px;
}

.traxly-auth-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .2px;
}

.traxly-auth-subtitle {
    color: rgba(203,213,225,.85);
    font-size: 13px;
    margin-top: 4px;
}

.traxly-auth-form {
    display: grid;
    gap: 12px;
}

.traxly-field {
    display: grid;
    gap: 6px;
}

.traxly-label {
    font-size: 13px;
    color: rgba(203,213,225,.9);
}

.traxly-input {
    width: 100%;
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(148,163,184,.22);
    color: var(--text);
}

    .traxly-input:focus {
        outline: none;
        border-color: rgba(147,197,253,.55);
        box-shadow: 0 0 0 4px rgba(59,130,246,.15);
    }

.traxly-row,
.traxly-row-split {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.traxly-row-split {
    gap: 12px;
}

.traxly-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.traxly-check-input {
    width: 16px;
    height: 16px;
}

.traxly-check-text {
    font-size: 13px;
    color: rgba(203,213,225,.9);
}

.traxly-link-muted {
    opacity: .85;
    text-decoration: none;
}

    .traxly-link-muted:hover {
        opacity: 1;
    }

.traxly-auth-footer {
    margin-top: 12px;
    font-size: 13px;
}

.traxly-alert {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    border: 1px solid rgba(148,163,184,.22);
    background: rgba(255,255,255,.03);
}

.traxly-alert-info {
    border-color: rgba(147,197,253,.35);
    background: rgba(147,197,253,.10);
    color: #dbeafe;
}

.traxly-alert-ok {
    border-color: rgba(34,197,94,.35);
    background: rgba(34,197,94,.10);
    color: #bbf7d0;
}

.traxly-alert-warn {
    border-color: rgba(251,191,36,.35);
    background: rgba(251,191,36,.10);
    color: #fde68a;
}

/* NOTE: :has() can be iffy. If it causes trouble, replace with a class on body/app shell. */
.traxly-content:has(.traxly-auth) {
    padding: 0;
    overflow-x: hidden;
}

@media (max-width: 420px) {
    .traxly-auth {
        padding: 16px 12px;
    }

    .traxly-auth-card {
        padding: 16px;
        width: min(420px, 94vw);
    }
}

/* =============================
   Page helpers / utilities
   ============================= */

.traxly-pagehead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.traxly-title {
    margin: 0;
}

.traxly-code,
.traxly-kv-item,
.traxly-metric,
.traxly-card {
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(148,163,184,.22);
    border-radius: 12px;
}

.traxly-card {
    padding: 12px;
}

.traxly-code {
    display: inline-block;
    padding: 6px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    color: var(--text);
}

.traxly-table tbody tr:hover {
    background: rgba(255,255,255,.02);
}

.traxly-actions .btn {
    white-space: nowrap;
}

.traxly-kv {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 900px) {
    .traxly-kv {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .traxly-kv {
        grid-template-columns: 1fr;
    }
}

.traxly-kv-item {
    padding: 10px 12px;
}

.traxly-k {
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(203,213,225,.85);
    margin-bottom: 4px;
}

.traxly-v {
    color: rgba(229,231,235,.95);
}

.traxly-section-title {
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(203,213,225,.85);
    margin-bottom: 6px;
}

.traxly-section-body {
    background: rgba(255,255,255,.02);
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 12px;
    padding: 12px;
}

.traxly-pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    color: rgba(229,231,235,.95);
}

.traxly-divider {
    height: 1px;
    background: rgba(148,163,184,.18);
    margin: 18px 0;
}

.traxly-ellipsis {
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.traxly-input textarea,
textarea.traxly-input {
    resize: vertical;
    min-height: 140px;
}

/* Dashboard grids */
.traxly-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 900px) {
    .traxly-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .traxly-grid-3 {
        grid-template-columns: 1fr;
    }
}

.traxly-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

@media (max-width: 1100px) {
    .traxly-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .traxly-grid-4 {
        grid-template-columns: 1fr;
    }
}

.traxly-metric {
    padding: 12px 14px;
    border-radius: 14px;
}

.traxly-metric-k {
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(203,213,225,.85);
}

.traxly-metric-v {
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
    line-height: 1.1;
}

.traxly-metric-h {
    color: rgba(203,213,225,.75);
    font-size: 13px;
    margin-top: 6px;
}

.traxly-metric-click {
    color: inherit;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(148,163,184,.22);
}

    .traxly-metric-click * {
        color: inherit;
    }

    .traxly-metric-click:hover {
        background: rgba(255,255,255,.05);
    }

    .traxly-metric-click:focus {
        outline: none;
        border-color: rgba(147,197,253,.55);
        box-shadow: 0 0 0 4px rgba(59,130,246,.15);
    }

/* chips */
.traxly-chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* show/hide by breakpoint */
@media (max-width: 700px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }
}

@media (min-width: 701px) {
    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }
}

/* Mobile layout (sidebar drawer) */
@media (max-width: 900px) {
    .traxly-app {
        grid-template-columns: 1fr;
    }

    .traxly-hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .traxly-app.sidebar-open .traxly-backdrop {
        display: block;
    }

    .traxly-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: min(86vw, 320px);
        z-index: 1200;
        transform: translateX(-105%);
        transition: transform 160ms ease;
        box-shadow: 0 20px 50px rgba(0,0,0,.55);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }

    .traxly-app.sidebar-open .traxly-sidebar {
        transform: translateX(0);
    }

    .traxly-topbar {
        position: sticky;
        top: 0;
        z-index: 1100;
    }

    .traxly-main {
        position: relative;
        z-index: 1000;
    }
}

/* Mobile tables -> cards */
@media (max-width: 700px) {
    .traxly-table thead {
        display: none;
    }

    .traxly-table,
    .traxly-table tbody,
    .traxly-table tr,
    .traxly-table td {
        display: block;
        width: 100%;
    }

        .traxly-table tr {
            background: rgba(255,255,255,.03);
            border: 1px solid rgba(148,163,184,.22);
            border-radius: 12px;
            padding: 10px 12px;
            margin-bottom: 10px;
        }

        .traxly-table td {
            border: 0 !important;
            padding: 6px 0 !important;
        }

            .traxly-table td[data-label]::before {
                content: attr(data-label);
                display: block;
                font-size: 12px;
                letter-spacing: .06em;
                text-transform: uppercase;
                color: rgba(203,213,225,.75);
                margin-bottom: 2px;
            }

            .traxly-table td.text-end {
                text-align: left !important;
            }
}

/* wordmark */
.traxly-wordmark {
    display: block;
    height: 22px;
    width: auto;
}

@media (max-width: 900px) {
    .traxly-wordmark {
        height: 20px;
    }
}

/* =============================
   Mobile layout improvements
   (added)
   ============================= */

/* Topbar title (was missing) */
.traxly-topbar-title {
    font-weight: 600;
}

@media (max-width: 700px) {
    /* Mobile: make topbar tighter + safe-area aware */
    .traxly-topbar {
        padding-left: calc(10px + env(safe-area-inset-left));
        padding-right: calc(10px + env(safe-area-inset-right));
        gap: 10px;
    }

    .traxly-topbar-title {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* logout link shouldn't stretch */
    .traxly-topbar .traxly-link {
        white-space: nowrap;
        font-size: 14px;
    }

    /* Reduce double-padding on small screens */
    .traxly-content {
        padding: 12px;
    }

    .traxly-surface {
        padding: 14px;
        border-radius: 12px;
    }

    /* Mobile-friendly form sizing (prevents iOS zoom-on-focus) */
    .traxly-input,
    select.traxly-input,
    textarea.traxly-input,
    .traxly-check-text {
        font-size: 16px;
    }

    .traxly-label {
        font-size: 12px;
    }

    /* Keep headings from dominating */
    .traxly-title {
        font-size: 24px;
        line-height: 1.15;
    }

    .text-muted.small {
        font-size: 12px;
    }
}

/* Generic action row that wraps cleanly on mobile */
.traxly-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

@media (max-width: 700px) {
    .traxly-actions-row {
        justify-content: flex-start;
    }

        .traxly-actions-row .traxly-btn,
        .traxly-actions-row .btn {
            flex: 1 1 140px; /* 2-per-row feel */
            min-width: 140px;
        }
}

/* Grid for day/week selector pill buttons */
.traxly-pill-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 420px) {
    .traxly-pill-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
