/* RotaCerta — App shell (sidebar + área principal, estilo Zeo) */

:root {
    --shell-blue: #2563eb;
    --shell-blue-dark: #1d4ed8;
    --shell-blue-light: #eff6ff;
    --shell-sidebar-w: 72px;
    --shell-text: #111827;
    --shell-muted: #6b7280;
    --shell-border: #e5e7eb;
    --shell-radius: 10px;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    background: #f8fafc;
    color: var(--shell-text);
}

.app-shell-map {
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
.shell-sidebar {
    width: var(--shell-sidebar-w);
    min-width: var(--shell-sidebar-w);
    background: var(--shell-blue);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    z-index: 200;
    flex-shrink: 0;
}

.shell-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    text-decoration: none;
    line-height: 0;
    padding: 0 0.35rem;
    flex-shrink: 0;
}

.shell-logo-img {
    display: block;
    width: 52px;
    height: auto;
    max-height: 52px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 3px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.shell-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    width: 100%;
}

.shell-nav-top {
    padding-top: 0.75rem;
}

.shell-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

.shell-nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.shell-nav-item.active {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.shell-nav-item svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.shell-nav-add {
    background: #fff !important;
    color: var(--shell-blue) !important;
    margin: 0.5rem 0;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
}

.shell-nav-add:hover {
    background: #f0f9ff !important;
    transform: scale(1.04);
}

.shell-nav-add svg { stroke-width: 2.5; }

.shell-nav-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding-top: 0.5rem;
}

.shell-nav-tooltip {
    position: relative;
}

.shell-nav-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 300;
}

.shell-nav-tooltip:hover::after { opacity: 1; }

/* ── Main area ── */
.shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: auto;
}

.shell-main-fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

.shell-main-fill > .shell-map-layout,
.shell-map-layout {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.app-shell-map .shell-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#app-sidebar {
    width: var(--shell-sidebar-w);
    min-width: var(--shell-sidebar-w);
    flex-shrink: 0;
    background: var(--shell-blue);
}

.shell-page {
    padding: 1.75rem 2rem 2rem;
    flex: 1;
}

/* ── Page header ── */
.shell-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.shell-header h1 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--shell-text);
    letter-spacing: -0.02em;
}

.shell-header p {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--shell-muted);
}

.shell-header-brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    max-width: 100%;
}

.shell-header-brand-text {
    min-width: 0;
    padding-left: 1.5rem;
    border-left: 1px solid var(--shell-border, #e5e7eb);
}

.shell-header-brand .shell-header-brand-text h1 {
    font-size: clamp(1.35rem, 2.5vw, 2rem);
    line-height: 1.15;
}

.shell-header-brand .shell-header-brand-text p {
    margin-top: 0.35rem;
    max-width: 36ch;
}

.shell-header-logo {
    display: block;
    height: 240px;
    width: auto;
    max-width: 380px;
    flex-shrink: 0;
    object-fit: contain;
    object-position: left center;
}

.shell-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.shell-link-help {
    font-size: 0.875rem;
    color: var(--shell-muted);
    text-decoration: none;
}

.shell-link-help:hover { color: var(--shell-blue); text-decoration: underline; }

.shell-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.shell-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.shell-btn-primary {
    background: var(--shell-blue);
    color: #fff;
}

.shell-btn-primary:hover { background: var(--shell-blue-dark); }

.shell-btn-outline {
    background: #fff;
    color: var(--shell-blue);
    border: 1.5px solid var(--shell-blue);
}

.shell-btn-outline:hover { background: var(--shell-blue-light); }

.shell-btn-danger-outline {
    background: #fff;
    color: #dc2626;
    border: 1.5px solid #fecaca;
}

.shell-btn-danger-outline:hover { background: #fef2f2; }

.shell-btn-danger-outline:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.shell-btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8125rem;
}

.shell-btn-outline:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.shell-link-btn {
    background: none;
    border: none;
    padding: 0;
    margin-right: 0.75rem;
    color: var(--shell-blue);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
}

.shell-link-btn:hover {
    text-decoration: underline;
}

.shell-actions-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* ── Toolbar / filtros ── */
.shell-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.shell-search {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.shell-search-wide {
    max-width: 520px;
}

.shell-search svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: #9ca3af;
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.shell-search input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.25rem;
    border: 1px solid var(--shell-border);
    border-radius: 9999px;
    font-size: 0.875rem;
    background: #fff;
}

.shell-search input:focus {
    outline: none;
    border-color: var(--shell-blue);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.shell-select {
    padding: 0.5rem 2rem 0.5rem 0.85rem;
    border: 1px solid var(--shell-border);
    border-radius: 9999px;
    font-size: 0.8rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
    appearance: none;
    cursor: pointer;
    color: var(--shell-text);
}

.shell-select:focus {
    outline: none;
    border-color: var(--shell-blue);
}

/* ── Card + tabela ── */
.shell-card {
    background: #fff;
    border-radius: var(--shell-radius);
    border: 1px solid var(--shell-border);
    overflow: hidden;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.shell-table-wrap { overflow-x: auto; }

.shell-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.shell-table th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    background: var(--shell-blue-light);
    border-bottom: 1px solid #dbeafe;
    white-space: nowrap;
}

.shell-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.shell-table tbody tr:hover { background: #fafbfc; }

.shell-table tbody tr:last-child td { border-bottom: none; }

.shell-table .col-check { width: 40px; }

.shell-empty {
    text-align: center;
    color: var(--shell-muted);
    padding: 3rem 1rem !important;
}

/* Células especiais */
.shell-user-cell {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.shell-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--shell-blue-light);
    color: var(--shell-blue);
    font-weight: 700;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shell-user-name {
    font-weight: 600;
    color: var(--shell-blue);
}

.shell-user-name:hover { text-decoration: underline; }

.shell-phone-link {
    color: var(--shell-blue);
    text-decoration: underline;
    font-size: 0.8rem;
}

.shell-skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.shell-skill-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    background: #f3f4f6;
    border-radius: 4px;
    color: #4b5563;
}

.shell-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
}

.shell-badge-active { background: #dbeafe; color: #1d4ed8; }
.shell-badge-inactive { background: #fee2e2; color: #991b1b; }
.shell-badge-suspended { background: #fef3c7; color: #92400e; }
.shell-badge-success { background: #dcfce7; color: #166534; }
.shell-badge-warning { background: #fef3c7; color: #92400e; }
.shell-badge-danger { background: #fee2e2; color: #991b1b; }

/* Menu de ações (⋮) */
.shell-actions { position: relative; }

.shell-actions-btn {
    background: transparent;
    border: none;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    font-size: 1.1rem;
    line-height: 1;
}

.shell-actions-btn:hover { background: #f3f4f6; color: #111; }

.shell-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--shell-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.12);
    z-index: 500;
    padding: 0.35rem 0;
    display: none;
}

.shell-dropdown.open { display: block; }

.shell-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    color: var(--shell-text);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
}

.shell-dropdown-item:hover { background: #f9fafb; }

.shell-dropdown-item.danger { color: #dc2626; }

.shell-dropdown-item svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    flex-shrink: 0;
}

/* Stats cards (portal / admin) */
.shell-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.shell-stat {
    background: #fff;
    border: 1px solid var(--shell-border);
    border-radius: var(--shell-radius);
    padding: 1.1rem 1.25rem;
}

.shell-stat-label {
    font-size: 0.75rem;
    color: var(--shell-muted);
    margin: 0;
}

.shell-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--shell-blue);
    margin: 0.2rem 0 0;
}

.shell-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.shell-quick-card {
    display: block;
    background: #fff;
    border: 1px solid var(--shell-border);
    border-radius: var(--shell-radius);
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.shell-quick-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgb(37 99 235 / 0.08);
}

.shell-quick-card h2 {
    margin: 0;
    font-size: 1rem;
    color: var(--shell-blue-dark);
}

.shell-quick-card p {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--shell-muted);
}

.shell-quick-card span {
    display: inline-block;
    margin-top: 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--shell-blue);
}

/* Map pages: painel interno */
.shell-panel {
    width: 20rem;
    background: #fff;
    border-right: 1px solid var(--shell-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 20;
}

.shell-panel-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--shell-border);
}

.shell-panel-head h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--shell-blue-dark);
}

.shell-panel-head p {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    color: var(--shell-muted);
}

.shell-panel-body {
    padding: 1rem 1.25rem;
    flex: 1;
    overflow-y: auto;
}

.route-dispatch-setup {
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #f8fbff;
}

.shell-map-area {
    flex: 1;
    position: relative;
    min-width: 0;
    min-height: 0;
    background: #e5e7eb;
}

.shell-map-area #route-map,
.shell-map-area #fleet-map {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
    z-index: 10;
}

.shell-panel.w-96 { width: 24rem; }

/* ── Dados cadastrais (tenant) ── */
.profile-card {
    max-width: 42rem;
    padding: 1.5rem;
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--shell-border);
}

.profile-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.profile-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--shell-muted, #6b7280);
    margin: 0;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.profile-readonly {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--shell-text);
}

.profile-hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--shell-muted, #6b7280);
    line-height: 1.45;
}

.profile-coords {
    margin: 0;
    font-size: 0.75rem;
    color: var(--shell-muted, #6b7280);
}

.profile-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 0.25rem;
}

.profile-address-saved {
    margin: 0 0 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #1e3a8a;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
}

.profile-address-view .profile-coords {
    margin-bottom: 0.75rem;
}

.profile-address-view .shell-btn-outline {
    margin-top: 0.25rem;
}

input.admin-search-input[readonly] {
    background: #f9fafb;
    color: #374151;
    cursor: default;
}

.address-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.address-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.address-form-row-cep {
    grid-template-columns: 1fr;
    max-width: 12rem;
}

.address-field-uf {
    max-width: 5rem;
}

.address-cep-status {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
}

.address-auto-field[readonly] {
    background: #f3f4f6;
}

.audit-filter-form {
    display: grid;
    grid-template-columns: minmax(160px, 200px) minmax(200px, 1fr) auto;
    gap: 1rem;
    align-items: end;
}

.audit-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.audit-filter-actions {
    display: flex;
    align-items: end;
}

@media (max-width: 640px) {
    .address-form-row {
        grid-template-columns: 1fr;
    }
    .address-field-uf {
        max-width: none;
    }
    .audit-filter-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .shell-sidebar { width: 56px; min-width: 56px; }
    .shell-nav-item { width: 38px; height: 38px; }
    .shell-page { padding: 1rem; }
    .shell-header h1 { font-size: 1.25rem; }
    .shell-header-brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .shell-header-brand-text {
        padding-left: 0;
        border-left: none;
        padding-top: 0.25rem;
    }
    .shell-header-logo {
        height: 168px;
        max-width: 100%;
    }
}
