/* Mobile-first layout for tenant panel */

:root {
    --app-topbar-height: 56px;
    --app-bottomnav-height: 64px;
    --app-sidebar-width: 248px;
    --app-subscription-bar-height: 36px;
}

.app-shell {
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: #2563eb;
    --bs-link-hover-color: #1d4ed8;
    --app-bg: #f4f7fb;
    --app-sidebar: #0f172a;
    --app-text: #0f172a;
    --app-muted: #64748b;
    --app-card-radius: 16px;
    --app-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--app-topbar-height);
    background: var(--app-sidebar);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.app-topbar-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar-subtitle {
    font-size: 0.75rem;
    color: #adb5bd;
    margin: 0;
}

.app-workspace {
    min-width: 0;
}

.app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    min-height: 64px;
    padding: 0.85rem 1rem 0.25rem;
}

.app-header-center {
    min-width: 0;
    justify-self: center;
}

.app-header-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    min-width: 0;
    justify-self: end;
}

.app-main {
    padding: 0.5rem 1rem calc(var(--app-bottomnav-height) + 1rem);
}

.app-sidebar {
    width: var(--app-sidebar-width);
    background: var(--app-sidebar);
    color: #fff;
    padding: 1.15rem 0.85rem 1rem;
    flex-direction: column;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.55rem 1.15rem;
    min-width: 0;
}

.app-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.app-brand-text {
    min-width: 0;
}

.app-brand-name {
    display: block;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-brand-subtitle {
    display: block;
    color: #94a3b8;
    font-size: 0.75rem;
    margin-top: 0.1rem;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 100%;
}

.app-shell .app-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(226, 232, 240, 0.86);
    border-radius: 0.75rem;
    padding: 0.55rem 0.8rem;
    font-size: 0.92rem;
    font-weight: 500;
    text-align: left;
}

.app-shell .app-nav .nav-link i {
    width: 1.25rem;
    font-size: 1.05rem;
    text-align: center;
    flex-shrink: 0;
}

.app-shell .app-nav .nav-link:hover,
.app-shell .app-nav .nav-link:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.app-shell .app-nav .nav-link.active {
    color: #fff;
    background: #2563eb;
    font-weight: 600;
}

.app-shell .app-nav .nav-link.active:hover,
.app-shell .app-nav .nav-link.active:focus-visible {
    background: #1d4ed8;
}

.app-nav-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-logout-form {
    width: 100%;
}

.app-logout-form .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(226, 232, 240, 0.78);
    border-radius: 0.75rem;
    padding: 0.55rem 0.8rem;
}

.app-user-trigger,
.page-help-trigger,
.app-icon-btn {
    border: 0;
    background: transparent;
}

.app-user-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-radius: 999px;
    padding: 0.25rem 0.45rem 0.25rem 0.25rem;
    color: var(--app-text);
}

.app-user-trigger:hover,
.app-user-trigger:focus-visible,
.app-icon-btn:hover,
.app-icon-btn:focus-visible,
.page-help-trigger:hover,
.page-help-trigger:focus-visible {
    background: #fff;
}

.app-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #0f172a;
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.app-user-meta {
    display: none;
    min-width: 0;
}

.app-user-name,
.app-user-tenant {
    display: block;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 9.5rem;
}

.app-user-name {
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.15;
}

.app-user-tenant {
    color: var(--app-muted);
    font-size: 0.75rem;
}

.app-user-trigger .bi-chevron-down {
    color: var(--app-muted);
    font-size: 0.75rem;
}

.app-user-menu {
    border: 0;
    border-radius: 0.9rem;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    min-width: 180px;
}

.app-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    color: #334155;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

.app-alerts-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px var(--app-bg);
}

.app-alerts-menu {
    width: min(340px, calc(100vw - 2rem));
    padding: 0.75rem;
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.app-alerts-title {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--app-muted);
}

.app-alerts-empty {
    margin: 0;
    color: var(--app-muted);
    font-size: 0.875rem;
}

.app-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.55rem 0.35rem;
    border-radius: 0.7rem;
    font-size: 0.85rem;
    color: var(--app-text);
}

.app-alert + .app-alert {
    margin-top: 0.15rem;
}

.app-alert i {
    margin-top: 0.1rem;
    color: #2563eb;
}

.app-shell .btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: #2563eb;
    --bs-btn-border-color: #2563eb;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1d4ed8;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #1e40af;
    --bs-btn-active-border-color: #1e40af;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #2563eb;
    --bs-btn-disabled-border-color: #2563eb;
    --bs-btn-focus-shadow-rgb: 37, 99, 235;
    border-radius: 0.8rem;
    font-weight: 600;
}

.app-shell .btn-outline-primary {
    --bs-btn-color: #2563eb;
    --bs-btn-border-color: #2563eb;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #2563eb;
    --bs-btn-hover-border-color: #2563eb;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #1d4ed8;
    --bs-btn-active-border-color: #1d4ed8;
    --bs-btn-focus-shadow-rgb: 37, 99, 235;
    border-radius: 0.8rem;
    font-weight: 600;
}

.app-shell .btn:focus-visible,
.app-shell .nav-link:focus-visible,
.app-user-trigger:focus-visible,
.page-help-trigger:focus-visible,
.app-icon-btn:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.app-shell .card {
    border: 1px solid #e8eef6;
    border-radius: var(--app-card-radius);
    box-shadow: var(--app-shadow);
}

.app-shell .card-header {
    background: transparent;
    border-bottom-color: #eef2f7;
}

.app-subscription-bar {
    position: fixed;
    right: 0;
    bottom: var(--app-bottomnav-height);
    left: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--app-subscription-bar-height);
    padding: 0.35rem 1rem;
    background: #fff8e1;
    border-top: 1px solid #f1d48a;
    color: #6b4f00;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.app-shell--owner-subscription .app-main {
    padding-bottom: calc(var(--app-bottomnav-height) + var(--app-subscription-bar-height) + 0.75rem);
}

.app-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    height: var(--app-bottomnav-height);
    background: #fff;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.25rem 0.5rem calc(0.25rem + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}

.app-bottom-nav a {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: #6c757d;
    font-size: 0.7rem;
    padding: 0.35rem 0.15rem;
    border-radius: 0.5rem;
    min-width: 0;
}

.app-bottom-nav a i {
    display: block;
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
}

.app-bottom-nav a.active {
    color: #2563eb;
    font-weight: 600;
}

.app-bottom-nav a:hover,
.app-bottom-nav a:focus-visible {
    color: #2563eb;
}

.offcanvas.app-offcanvas {
    background: var(--app-sidebar);
    color: #fff;
    width: min(86vw, 300px);
}

.offcanvas.app-offcanvas .offcanvas-header {
    align-items: flex-start;
}

.offcanvas.app-offcanvas .app-brand {
    flex: 1;
    min-width: 0;
    padding-bottom: 0;
}

@media (min-width: 768px) {
    .app-shell {
        display: flex;
        align-items: stretch;
    }

    .app-topbar,
    .app-bottom-nav {
        display: none !important;
    }

    .app-sidebar {
        height: 100vh;
        position: sticky;
        top: 0;
        flex-shrink: 0;
    }

    .app-nav {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .app-nav-footer {
        margin-top: auto;
    }

    .app-workspace {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .app-header {
        padding: 0.85rem 1.75rem 0.15rem;
    }

    .app-main {
        flex: 1;
        padding: 0.35rem 1.75rem 2rem;
    }

    .app-subscription-bar {
        left: var(--app-sidebar-width);
        bottom: 0;
    }

    .app-shell--owner-subscription .app-main {
        padding-bottom: calc(var(--app-subscription-bar-height) + 1.25rem);
    }

    .app-user-meta {
        display: block;
    }
}

@media (max-width: 991.98px) {
    .app-header {
        grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    }

    .app-header-center {
        justify-self: start;
    }
}

@media (max-width: 767.98px) {
    .app-sidebar-desktop {
        display: none !important;
    }

    .pwa-install-banner:not(.pwa-install-banner--inline) {
        bottom: calc(var(--app-bottomnav-height) + 0.75rem);
    }

    .app-shell--owner-subscription .pwa-install-banner:not(.pwa-install-banner--inline) {
        bottom: calc(var(--app-bottomnav-height) + var(--app-subscription-bar-height) + 0.75rem);
    }

    .app-main .h3,
    .app-main h1 {
        font-size: 1.35rem;
    }

    .app-main .btn {
        min-height: 44px;
    }
}

.page-help-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: #fff;
    color: #2563eb;
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    max-width: 100%;
}

.page-help-chevron {
    font-size: 0.75rem;
}

.page-help-menu {
    width: min(380px, calc(100vw - 2rem));
    padding: 0.95rem 1rem 1rem;
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.page-help-intro {
    margin-bottom: 0.55rem;
    color: var(--app-muted, #64748b);
    font-size: 0.875rem;
}

.page-help-list {
    margin: 0;
    padding-left: 1.1rem;
    color: #334155;
    font-size: 0.875rem;
}

.page-help-list li + li {
    margin-top: 0.35rem;
}

details.page-help {
    background: #f8f9fa;
    border-left: 3px solid #2563eb;
}

.page-help-summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #2563eb;
    list-style: none;
    display: flex;
    align-items: center;
}

.page-help-summary::-webkit-details-marker {
    display: none;
}

.page-help-body {
    font-size: 0.875rem;
}

@media (max-width: 767.98px) {
    .page-help-trigger span,
    .page-help-chevron {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .page-help-trigger {
        width: 40px;
        height: 40px;
        justify-content: center;
        padding: 0;
    }
}

/* Agenda grid */
.agenda-grid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background: #fff;
}

.agenda-grid {
    min-width: 320px;
}

.agenda-grid-header {
    display: grid;
    grid-template-columns: 56px repeat(var(--agenda-cols, 1), minmax(120px, 1fr));
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.agenda-grid-time-col,
.agenda-grid-prof-col {
    padding: 0.5rem 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    border-right: 1px solid #eee;
}

.agenda-prof-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--prof-color, #0d6efd);
    margin-right: 0.25rem;
}

.agenda-grid-body {
    display: grid;
    grid-template-columns: 56px repeat(var(--agenda-cols, 1), minmax(120px, 1fr));
}

.agenda-grid-times {
    display: grid;
    grid-template-rows: repeat(var(--agenda-rows, 1), 40px);
    border-right: 1px solid #dee2e6;
}

.agenda-grid-time-slot {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0.15rem;
    font-size: 0.7rem;
    color: #6c757d;
    border-bottom: 1px solid #f0f0f0;
}

.agenda-grid-column {
    position: relative;
    border-right: 1px solid #eee;
    min-height: calc(var(--agenda-rows, 1) * var(--row-height, 40px));
}

.agenda-slot-hit {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    cursor: pointer;
}

.agenda-slot-hit:hover,
.agenda-slot-hit:focus-visible {
    background: rgba(13, 110, 253, 0.08);
    outline: none;
}

.agenda-slot-hit--blocked {
    background: rgba(108, 117, 125, 0.06);
}

.agenda-slot-hit--booked {
    pointer-events: none;
    cursor: default;
}

.agenda-grid-cell {
    border-bottom: 1px solid #f8f9fa;
}

.agenda-item {
    position: absolute;
    left: 2px;
    right: 2px;
    z-index: 1;
    margin: 1px 2px;
    padding: 0.25rem 0.35rem;
    border-radius: 0.35rem;
    font-size: 0.7rem;
    line-height: 1.25;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

.agenda-item--appointment {
    background: color-mix(in srgb, var(--event-color, #0d6efd) 18%, white);
    border-left: 3px solid var(--event-color, #0d6efd);
}

.agenda-item--block {
    background: repeating-linear-gradient(
        -45deg,
        #e9ecef,
        #e9ecef 4px,
        #f8f9fa 4px,
        #f8f9fa 8px
    );
    color: #6c757d;
    border: 1px dashed #adb5bd;
    pointer-events: none;
}

.agenda-item--encaixe {
    z-index: 2;
    border-style: dashed !important;
    border-width: 2px !important;
    background: #fff8e1 !important;
}

.agenda-item-time {
    font-weight: 700;
    font-size: 0.68rem;
}

.agenda-item-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-item-service,
.agenda-item-meta {
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-item-badge {
    display: inline-block;
    margin-top: 0.15rem;
    padding: 0 0.3rem;
    border-radius: 0.25rem;
    background: #ffc107;
    color: #212529;
    font-size: 0.6rem;
    font-weight: 700;
}

.agenda-encaixe-summary {
    font-size: 0.875rem;
}

.agenda-week-tabs .nav-link {
    font-size: 0.8rem;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .agenda-grid-prof-col {
        font-size: 0.65rem;
        padding: 0.4rem 0.2rem;
    }

    .agenda-grid-column {
        min-width: 110px;
    }

    .agenda-slot-hit {
        min-height: 44px;
    }
}
