/* ══════════════════════════════════════════════════════════════
   Radio Booking — Stylesheet
   ══════════════════════════════════════════════════════════════ */

:root {
    --primary: #3788d8;
    --primary-dark: #2563a8;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --success: #2ecc71;
    --bg: #f4f6f9;
    --card-bg: #fff;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #dfe6e9;
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); }

/* ── Login Page ───────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--card-bg);
    padding: 2rem 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    margin: 0 0 1.5rem;
    text-align: center;
    font-size: 1.4rem;
}

/* ── Alerts ───────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-danger { background: #fdecea; color: var(--danger-dark); border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar h1 { margin: 0; font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.user-name { color: var(--text-muted); font-size: .9rem; }

/* ── App shell / sidebar ─────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: calc(100vh - 62px);
}
.sidebar {
    background: linear-gradient(180deg, #162731 0%, #1f3441 100%);
    color: #eaf3f8;
    border-right: 1px solid rgba(255,255,255,.06);
    padding: 1rem .75rem;
    box-shadow: inset -1px 0 0 rgba(255,255,255,.04);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .35rem .5rem 1rem;
    margin-bottom: .5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #3788d8 0%, #66b3ff 100%);
    color: #fff;
    font-weight: 700;
    letter-spacing: .04em;
}
.sidebar-brand-title {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
}
.sidebar-brand-subtitle {
    color: rgba(234,243,248,.7);
    font-size: .78rem;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    position: sticky;
    top: 76px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem .9rem;
    border-radius: 10px;
    color: #eaf3f8;
    text-decoration: none;
    font-weight: 600;
    transition: background .15s, color .15s, transform .15s;
}
.sidebar-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    transform: translateX(2px);
}
.sidebar-link.active {
    background: rgba(55,136,216,.22);
    color: #fff;
    box-shadow: inset 3px 0 0 #66b3ff;
}
.sidebar-link.is-disabled {
    color: rgba(234,243,248,.68);
    cursor: default;
    pointer-events: none;
    background: transparent;
}
.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.main-content {
    min-width: 0;
}

/* ── Toolbar ──────────────────────────────────────────────────── */
.toolbar {
    padding: .75rem 1.5rem;
    display: flex;
    gap: .5rem;
    align-items: center;
}
.page-title { margin: 0; font-size: 1.2rem; }

/* ── Check-Out page ───────────────────────────────────────────── */
.checkout-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1rem;
    padding: 0 1.5rem 2rem;
}
.checkout-list-panel,
.checkout-details-panel { min-width: 0; }
.checkout-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.checkout-booking-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}
.checkout-booking-item {
    width: 100%;
    text-align: left;
    padding: .75rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
}
.checkout-booking-item:hover { border-color: var(--primary); background: #f7fbff; }
.checkout-booking-item.active {
    border-color: var(--primary);
    background: #eef5fc;
}
.checkout-booking-company { font-weight: 700; margin-bottom: .15rem; }
.checkout-booking-meta { color: var(--text-muted); font-size: .8rem; }
.checkout-placeholder {
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    color: var(--text-muted);
}
.checkout-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .5rem 1rem;
}
.checkout-meta-item strong { display: inline-block; min-width: 72px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, opacity .15s;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-warning { background: #f0ad4e; color: #fff; border: 1px solid #eea236; }
.btn-warning:hover { background: #ec971f; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: .35rem; font-size: 1rem; background: none; border: none; cursor: pointer; }
.btn-icon:hover { color: var(--primary); }

/* ── Form elements ────────────────────────────────────────────── */
.form-group { margin-bottom: .75rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: .8rem;
    margin-bottom: .25rem;
    color: var(--text);
}
.section-head-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .4rem;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(55,136,216,.15);
}
input[type="color"] {
    width: 100%;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

/* ── Calendar ─────────────────────────────────────────────────── */
#calendar {
    padding: 0 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}
.fc .fc-toolbar-title { font-size: 1.1rem; }
.fc .fc-button {
    padding: .3rem .7rem;
    font-size: .8rem;
}
.fc-event { cursor: pointer; }
.fc-event .fc-event-title { font-weight: 500; }
.fc .fc-daygrid-day-number { font-size: .8rem; }

/* Status stripes on events */
.fc-event.status-tentative { opacity: .7; border-style: dashed !important; }
.fc-event.status-returned  { opacity: .5; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal[hidden] { display: none; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
}
.modal-dialog {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    width: min(1200px, 96vw);
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 4rem);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    color: var(--text-muted);
}
.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.5rem;
    border-top: 1px solid var(--border);
}
.modal-footer-right { display: flex; gap: .5rem; }

/* ── Dropdown list (company search) ───────────────────────────── */
.dropdown-list {
    position: absolute;
    z-index: 10;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.dropdown-list[hidden] { display: none; }
.dropdown-item {
    padding: .5rem .75rem;
    cursor: pointer;
    font-size: .875rem;
}
.dropdown-item:hover { background: var(--bg); }
.form-group { position: relative; }

/* ── Tag selected (company chip) ──────────────────────────────── */
.tag-selected {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--bg);
    padding: .35rem .75rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-top: .25rem;
}
.tag-selected[hidden] { display: none; }
.tag-remove {
    cursor: pointer;
    font-weight: bold;
    color: var(--danger);
}

/* ── Asset scan / search row ──────────────────────────────────── */
.scan-input-wrap {
    display: flex;
    gap: .35rem;
}
.scan-input-wrap input { flex: 1; }
.scan-input-wrap .btn { flex-shrink: 0; padding: .4rem .75rem; }
#scanFeedback { font-size: .8rem; margin-top: .25rem; min-height: 1.2em; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}
.tab-btn {
    padding: .5rem 1.25rem;
    border: none;
    background: none;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.reservation-period-picker {
    margin-bottom: .6rem;
}
.reservation-period-picker label {
    display: block;
    margin-bottom: .25rem;
    font-weight: 700;
    font-size: .82rem;
}
.period-tab-bar {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
    margin-bottom: .35rem;
}
.period-tab-btn {
    padding: .45rem .8rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
.period-tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.period-tab-btn:hover { border-color: var(--primary); }

/* ── Quantity input inline ────────────────────────────────────── */
.qty-input {
    width: 88px;
    min-width: 88px;
    padding: .45rem .55rem;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    background: #fff;
    color: var(--text);
}

/* ── Asset tables ─────────────────────────────────────────────── */
.asset-table-wrap {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .75rem;
}
.asset-table { width: 100%; border-collapse: collapse; font-size: .825rem; }
.asset-table th, .asset-table td {
    padding: .4rem .6rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.asset-table th { background: var(--bg); font-weight: 600; position: sticky; top: 0; }
.asset-table tr:last-child td { border-bottom: none; }
.asset-table tr:hover td { background: #f0f7ff; }
.period-row input,
.period-row select {
    min-width: 100%;
    padding: .4rem .55rem;
    font-size: .84rem;
}

/* ── Log table ────────────────────────────────────────────────── */
.log-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.log-table th, .log-table td { padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
.log-table th { background: var(--bg); font-weight: 600; }

/* ── Utility ──────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); font-size: .8rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }

/* ── Toast notifications ──────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.toast {
    padding: .75rem 1.25rem;
    border-radius: var(--radius);
    color: #fff;
    font-size: .875rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    animation: toastIn .3s ease;
    max-width: 380px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Company page ──────────────────────────────────────────────── */
.company-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1rem;
    padding: 0 1.5rem 2rem;
}
.company-list-panel,
.company-detail-panel { min-width: 0; }
.company-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.company-list-body {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}
.company-list-item {
    width: 100%;
    text-align: left;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}
.company-list-item:hover { border-color: var(--primary); background: #f7fbff; }
.company-list-item.active { border-color: var(--primary); background: #eef5fc; }
.company-list-name { font-weight: 700; margin-bottom: .1rem; }
.company-list-meta { color: var(--text-muted); font-size: .8rem; }
.snipeit-link-row { position: relative; }
.input-with-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .5rem;
    align-items: center;
}
.input-with-action .btn {
    white-space: nowrap;
}
#cvrLookupStatus.is-error {
    color: var(--danger-dark);
}
.sub-form {
    margin-top: .75rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: .5rem 1rem;
    }
    .sidebar-nav {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .checkout-layout {
        grid-template-columns: 1fr;
        padding: 0 1rem 1rem;
    }
    .company-layout {
        grid-template-columns: 1fr;
        padding: 0 1rem 1rem;
    }
}

@media (max-width: 600px) {
    .topbar { padding: .5rem 1rem; }
    .toolbar { padding: .5rem 1rem; }
    #calendar { padding: 0 .5rem 1rem; }
    .modal-dialog { max-width: 100%; }
    .form-row { grid-template-columns: 1fr; }
    .sidebar-link { padding: .55rem .75rem; }
}
