/**
 * Spryze — App Shell Stylesheet
 * Home Assistant-inspired theme with CSS custom properties.
 */

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
    --spryze-blue:         #1E88E5;
    --spryze-blue-hover:   #1976D2;
    --header-bg:           #1C1E21;
    --sidebar-bg:          #111315;
    --sidebar-width:       250px;
    --sidebar-hover-bg:    rgba(255, 255, 255, 0.08);
    --sidebar-active-bg:   rgba(30, 136, 229, 0.18);
    --canvas-bg:           #F4F6F8;
    --text-primary:        #E1E3E6;
    --text-secondary:      #9DA0A5;
}

/* ── Base ──────────────────────────────────────────────── */
body {
    background-color: var(--canvas-bg);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

#app-content {
    overflow-x: hidden;
    max-width: 100%;
}

/* ── Header ────────────────────────────────────────────── */
.app-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1030;
}

.app-header .header-logo {
    height: 30px;
}

.app-header .btn-icon {
    color: var(--text-primary);
    background: transparent;
    border: none;
    padding: 0.25rem;
    line-height: 1;
    transition: background 0.2s ease;
}

.app-header .btn-icon:hover {
    color: #fff;
    background: var(--sidebar-hover-bg);
}

/* Pill-style header buttons */
.header-pill {
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.3rem 0.85rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.header-pill:hover,
.header-pill:focus-visible,
.header-pill.show {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.header-pill::after {
    border-top-color: var(--text-secondary);
    vertical-align: middle;
    margin-left: 0.35rem;
}

/* Mobile: truncate long division names */
.division-pill {
    max-width: 180px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.division-pill .division-pill-text {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.app-header .dropdown-menu {
    z-index: 1040;
}

@media (max-width: 575.98px) {
    .division-pill {
        max-width: 130px;
    }
}

/* ── Sidebar (Desktop) ─────────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow-y: auto;
    flex-shrink: 0;
}

.app-sidebar .nav-link {
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 2px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 450;
    transition: all 0.2s ease;
}

.app-sidebar .nav-link:hover {
    color: var(--text-primary);
    background-color: var(--sidebar-hover-bg);
}

.app-sidebar .nav-link.active {
    color: var(--spryze-blue);
    background-color: var(--sidebar-active-bg);
    font-weight: 500;
}

/* ── Offcanvas Sidebar (Mobile) ────────────────────────── */
.offcanvas.app-sidebar {
    background-color: var(--sidebar-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    width: 280px;
    max-width: 85vw;
}

.offcanvas.app-sidebar .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.offcanvas.app-sidebar .offcanvas-body .nav-link {
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    margin-bottom: 2px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 450;
    transition: all 0.2s ease;
}

.offcanvas.app-sidebar .offcanvas-body .nav-link:hover {
    color: var(--text-primary);
    background-color: var(--sidebar-hover-bg);
}

.offcanvas.app-sidebar .offcanvas-body .nav-link.active {
    color: var(--spryze-blue);
    background-color: var(--sidebar-active-bg);
    font-weight: 500;
}

/* ── Content Area ──────────────────────────────────────── */
.app-content {
    min-height: calc(100vh - 54px);
    background-color: var(--canvas-bg);
}

/* ── Loading Placeholder ───────────────────────────────── */
.view-loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
}

/* ── Spinner Sizes ─────────────────────────────────────── */
.spinner-lg {
    width: 2.5rem;
    height: 2.5rem;
}

/* ── Page Header Bar ───────────────────────────────────── */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header .page-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: #1a1c1e;
    letter-spacing: -0.01em;
}

.page-header .page-meta {
    font-size: 0.8125rem;
    color: #6c757d;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ── Stat Cards ────────────────────────────────────────── */
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ── Buttons: Focus Ring ───────────────────────────────── */
.btn:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(30, 136, 229, 0.35);
}

/* ── Form Focus Ring ───────────────────────────────────── */
.form-control:focus,
.form-floating > .form-control:focus,
.form-select:focus {
    border-color: var(--spryze-blue);
    box-shadow: 0 0 0 0.2rem rgba(30, 136, 229, 0.15);
}

/* ── Dropdown ──────────────────────────────────────────── */
.dropdown-item.active,
.dropdown-item:active {
    background-color: var(--spryze-blue);
    color: #fff;
}

.dropdown-item {
    padding: 0.45rem 1rem;
    font-size: 0.875rem;
    transition: background-color 0.15s ease;
}

.dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

/* ── Alert Transitions ─────────────────────────────────── */
.alert {
    transition: opacity 0.15s ease;
}

/* ── Login Card (Guest) ────────────────────────────────── */
.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* ── Spinner in Buttons ────────────────────────────────── */
.btn .spinner-border-sm {
    vertical-align: middle;
}

/* ── Responsive Tweaks ─────────────────────────────────── */
@media (min-width: 992px) {
    #sidebar {
        position: sticky;
        top: 54px;
        min-height: calc(100vh - 54px);
        align-self: flex-start;
    }
}

/* ── Client Onboard Drawer ─────────────────────────────── */
.offcanvas.client-onboard {
    width: min(560px, 90vw);
    display: flex;
    flex-direction: column;
}

.offcanvas.client-onboard .offcanvas-header {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 0.75rem;
}

.offcanvas.client-onboard .offcanvas-body {
    overflow-y: auto;
    flex: 1 1 auto;
}

/* ── Onboard Wizard Tabs ───────────────────────────────── */
.onboard-tabs {
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.onboard-tabs .nav-link {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.6rem 1rem;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.onboard-tabs .nav-link:hover {
    color: var(--spryze-blue);
}

.onboard-tabs .nav-link.active {
    color: var(--spryze-blue);
    border-bottom-color: var(--spryze-blue);
    background: transparent;
}

.onboard-tabs .tab-close {
    font-size: 0.7rem;
    margin-left: 0.4rem;
    opacity: 0.5;
    vertical-align: middle;
}

.onboard-tabs .tab-close:hover {
    opacity: 1;
    color: #dc3545;
}

/* ── Onboard Sticky Footer ─────────────────────────────── */
.onboard-footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.onboard-footer .onboard-footer-right {
    display: flex;
    gap: 0.5rem;
}

/* ── Address Autocomplete ──────────────────────────────── */
.address-autocomplete-wrap {
    position: relative;
}

.address-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.address-autocomplete-list.show {
    display: block;
}

.address-autocomplete-item {
    padding: 0.55rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background-color 0.1s ease;
}

.address-autocomplete-item:last-child {
    border-bottom: none;
}

.address-autocomplete-item:hover,
.address-autocomplete-item.active {
    background-color: rgba(30, 136, 229, 0.08);
}

.address-autocomplete-item .ac-street {
    font-weight: 500;
    color: #1a1c1e;
}

.address-autocomplete-item .ac-city-state {
    font-size: 0.8125rem;
    color: #6c757d;
}

/* ── Section Card inside Drawer ────────────────────────── */
.onboard-section {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
}

.onboard-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

/* ── Repeatable Row (gates, dogs, hazards) ─────────────── */
.repeatable-row {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    position: relative;
}

.repeatable-row .repeatable-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.5;
    cursor: pointer;
    background: none;
    border: none;
    color: #dc3545;
    padding: 0.1rem 0.3rem;
}

.repeatable-row .repeatable-remove:hover {
    opacity: 1;
}

/* ── Associate Onboarding Wizard ─────────────────────────── */
.step-indicator {
    gap: 0;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.step-item.active .step-circle {
    background: var(--spryze-blue);
    color: #fff;
}

.step-item.completed .step-circle {
    background: #198754;
    color: #fff;
}

.step-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: #6c757d;
    margin-top: 0.35rem;
    text-align: center;
    white-space: nowrap;
}

.step-item.active .step-label {
    color: var(--spryze-blue);
    font-weight: 600;
}

.step-item.completed .step-label {
    color: #198754;
}

.step-line {
    flex: 1;
    height: 2px;
    background: #e9ecef;
    min-width: 20px;
    margin-bottom: 1.2rem;
}

.wizard-step-panel {
    display: none;
}

.wizard-step-panel.active {
    display: block;
}

@media (max-width: 575.98px) {
    .step-label {
        display: none;
    }
    .step-circle {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    .step-line {
        min-width: 12px;
        margin-bottom: 1rem;
    }
}

/* ── Onboarding Wizard ─────────────────────────────── */
.onboarding-wizard {
    background: #f8f9fa;
    min-height: 100vh;
}
