/* ============================================================
   Vistoria – CESAN
   Paleta: Azul Claro #00AEEF · Azul Escuro #003B73 · Branco
   Sidebar layout com modo recolhido
   ============================================================ */

:root {
    --azul-claro: #00AEEF;
    --azul-escuro: #003B73;
    --azul-medio: #005DA4;
    --azul-hover: #004A85;
    --branco: #FFFFFF;
    --cinza-bg: #F2F5F9;
    --cinza-borda: #E0E4EA;
    --cinza-texto: #6B7280;
    --sombra-sm: 0 1px 3px rgba(0, 59, 115, .05);
    --sombra-md: 0 4px 14px rgba(0, 59, 115, .08);
    --sombra-lg: 0 8px 30px rgba(0, 59, 115, .12);
    --radius: 10px;
    --radius-lg: 14px;
    --transition: .25s cubic-bezier(.4,0,.2,1);
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 72px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--cinza-bg);
    color: #1F2937;
    margin: 0;
    min-height: 100vh;
}

a { text-decoration: none; }

/* ===========================================================
   MODAL LOADING CUSTOMIZADO
   =========================================================== */
/* Remove fundo padrão */
.loading-modal {
    background: transparent;
    border: none;
    box-shadow: none;
}

/* Container central */
.loading-container {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    padding: 40px 30px;
    border-radius: 16px;
    display: inline-block;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* Spinner moderno */
.custom-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(25, 135, 84, 0.2);
    border-top-color: #198754;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

/* Animação */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Texto principal */
.loading-text {
    font-weight: 600;
    margin-bottom: 5px;
}

/* Subtexto */
.loading-subtext {
    font-size: 0.9rem;
    color: #6c757d;
    margin: 0;
}
/* ===========================================================
   SIDEBAR
   =========================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--branco);
    border-right: 1px solid var(--cinza-borda);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--transition);
    overflow: hidden;
    box-shadow: 2px 0 12px rgba(0, 59, 115, .04);
}

/* -- Logo area -- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.15rem;
    border-bottom: 1px solid var(--cinza-borda);
    min-height: 72px;
    flex-shrink: 0;
}

.sidebar-brand img {
    height: 40px;
    width: auto;
    flex-shrink: 0;
}

.sidebar-brand span {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--azul-escuro);
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition);
}

/* -- Nav links -- */
.sidebar-nav {
    flex: 1;
    padding: .75rem .65rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .9rem;
    margin-bottom: 2px;
    border-radius: 8px;
    color: var(--cinza-texto);
    font-size: .9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
    text-decoration: none;
    position: relative;
}

/* Prevent visited link color changes */
.sidebar-link:link,
.sidebar-link:visited {
    color: var(--cinza-texto);
    text-decoration: none;
}

.sidebar-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    color: var(--azul-medio);
    transition: color var(--transition);
}

.sidebar-link:hover {
    background: rgba(0, 174, 239, .08);
    color: var(--azul-escuro);
    text-decoration: none;
}

.sidebar-link:hover i {
    color: var(--azul-escuro);
}

.sidebar-link.active {
    background: var(--azul-escuro);
    color: var(--branco);
}

.sidebar-link.active:link,
.sidebar-link.active:visited {
    color: var(--branco);
}

.sidebar-link.active i {
    color: var(--azul-claro);
}

.sidebar-link.active:hover {
    background: var(--azul-hover);
    color: var(--branco);
}

.sidebar-nav .nav-section {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--cinza-texto);
    padding: .9rem .9rem .35rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition);
}

/* -- Footer area (user + toggle) -- */
.sidebar-footer {
    border-top: 1px solid var(--cinza-borda);
    padding: .75rem .65rem;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .75rem;
    margin-bottom: .35rem;
    border-radius: 8px;
    background: var(--cinza-bg);
    overflow: hidden;
    position: relative;
}

.sidebar-user i {
    font-size: 1.3rem;
    color: var(--azul-medio);
    flex-shrink: 0;
}

.sidebar-user span {
    font-weight: 600;
    font-size: .82rem;
    color: var(--azul-escuro);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 1;
    transition: opacity var(--transition);
}

.sidebar-footer .sidebar-link:link,
.sidebar-footer .sidebar-link:visited {
    color: var(--cinza-texto);
}

/* -- Toggle button -- */
.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .9rem;
    border-radius: 8px;
    color: var(--cinza-texto);
    font-size: .88rem;
    font-weight: 500;
    white-space: nowrap;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.sidebar-toggle i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(0, 174, 239, .08);
    color: var(--azul-escuro);
}

.sidebar-toggle .toggle-label {
    opacity: 1;
    transition: opacity var(--transition);
}

/* ===========================================================
   SIDEBAR COLLAPSED STATE
   =========================================================== */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
    overflow: visible;
}

body.sidebar-collapsed .sidebar-brand span,
body.sidebar-collapsed .sidebar-link-text,
body.sidebar-collapsed .sidebar-nav .nav-section,
body.sidebar-collapsed .sidebar-toggle .toggle-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar-nav {
    overflow: visible;
}

body.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-w);
}

/* All sidebar items: center icons when collapsed */
body.sidebar-collapsed .sidebar-nav .sidebar-link,
body.sidebar-collapsed .sidebar-footer .sidebar-link,
body.sidebar-collapsed .sidebar-toggle {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    position: relative;
    overflow: visible;
}

/* Tooltips on hover for nav links */
body.sidebar-collapsed .sidebar-nav .sidebar-link:hover::after {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--azul-escuro);
    color: var(--branco);
    padding: .35rem .75rem;
    border-radius: 6px;
    font-size: .78rem;
    white-space: nowrap;
    z-index: 2000;
    box-shadow: var(--sombra-md);
    pointer-events: none;
}

/* Tooltips on hover for footer links */
body.sidebar-collapsed .sidebar-footer .sidebar-link:hover::after {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--azul-escuro);
    color: var(--branco);
    padding: .35rem .75rem;
    border-radius: 6px;
    font-size: .78rem;
    white-space: nowrap;
    z-index: 2000;
    box-shadow: var(--sombra-md);
    pointer-events: none;
}

/* User info: center icon, show tooltip */
body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: .5rem;
    position: relative;
    overflow: visible;
}

body.sidebar-collapsed .sidebar-user span {
    display: none;
}

body.sidebar-collapsed .sidebar-user:hover::after {
    content: attr(data-title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--azul-escuro);
    color: var(--branco);
    padding: .35rem .75rem;
    border-radius: 6px;
    font-size: .78rem;
    white-space: nowrap;
    z-index: 2000;
    box-shadow: var(--sombra-md);
    pointer-events: none;
}

/* ===========================================================
   MAIN CONTENT
   =========================================================== */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 1.75rem 2rem 2rem;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

/* -- Top bar (mobile) -- */
.topbar-mobile {
    display: none;
    background: var(--azul-escuro);
    border-bottom: 1px solid var(--cinza-borda);
    padding: .6rem 1rem;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--sombra-sm);
}

.topbar-mobile img { height: 32px; }

.topbar-mobile .topbar-title {
    font-weight: 700;
    color: var(--branco);
    font-size: 1rem;
}

.topbar-mobile .btn-menu {
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--branco);
    padding: .25rem;
    cursor: pointer;
    line-height: 1;
}

/* -- Overlay (mobile) -- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 1035;
}

/* ===========================================================
   CARDS
   =========================================================== */
.card {
    background: var(--branco);
    border: 1px solid var(--cinza-borda);
    border-radius: var(--radius);
    box-shadow: var(--sombra-sm);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--sombra-md);
}

.card .card-body {
    padding: 1.5rem;
}

/* ===========================================================
   TABLES
   =========================================================== */
.table {
    margin-bottom: 0;
    font-size: .88rem;
}

.table thead th {
    background: var(--azul-escuro);
    color: var(--branco);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    border: none;
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table thead th:first-child { border-radius: var(--radius) 0 0 0; }
.table thead th:last-child  { border-radius: 0 var(--radius) 0 0; }

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: rgba(0, 174, 239, .04);
}

.table tbody td {
    padding: .7rem 1rem;
    vertical-align: middle;
    border-color: var(--cinza-borda);
}

/* ===========================================================
   BUTTONS
   =========================================================== */
.btn-primary,
.btn-cesan {
    background: var(--azul-escuro);
    border-color: var(--azul-escuro);
    color: var(--branco);
    font-weight: 600;
    border-radius: 8px;
    padding: .5rem 1.25rem;
    font-size: .88rem;
    transition: background var(--transition), box-shadow var(--transition);
}

.btn-primary:hover,
.btn-cesan:hover {
    background: var(--azul-hover);
    border-color: var(--azul-hover);
    box-shadow: 0 2px 8px rgba(0, 59, 115, .18);
}

.btn-outline-primary {
    color: var(--azul-escuro);
    border-color: var(--azul-escuro);
    font-weight: 600;
    border-radius: 8px;
    font-size: .85rem;
}

.btn-outline-primary:hover {
    background: var(--azul-escuro);
    color: var(--branco);
}

.btn-success {
    background: var(--azul-claro);
    border-color: var(--azul-claro);
    color: var(--branco);
    font-weight: 600;
    border-radius: 8px;
}

.btn-success:hover {
    background: #009AD4;
    border-color: #009AD4;
    box-shadow: 0 2px 8px rgba(0, 174, 239, .22);
}

.btn-danger {
    border-radius: 8px;
    font-weight: 600;
}

.btn-outline-secondary {
    border-radius: 8px;
    font-weight: 500;
}

.btn-sm {
    padding: .35rem .85rem;
    font-size: .82rem;
}

/* ===========================================================
   FORM SECTIONS (Vistoria)
   =========================================================== */
.form-section {
    background: var(--branco);
    border: 1px solid var(--cinza-borda);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.15rem;
    box-shadow: var(--sombra-sm);
}

.form-section h5 {
    color: var(--azul-escuro);
    font-weight: 700;
    font-size: .95rem;
    border-bottom: 2px solid var(--azul-claro);
    padding-bottom: .45rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.form-section h5 i {
    color: var(--azul-claro);
    font-size: 1rem;
}

/* -- Collapsible sections -- */
.collapsible-section h5.section-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
    user-select: none;
    transition: margin-bottom var(--transition);
}

.collapsible-section h5.section-toggle .toggle-icon {
    font-size: .85rem;
    color: var(--cinza-texto);
    transition: transform var(--transition);
}

.collapsible-section .section-body {
    padding-top: 1rem;
}

/* ===========================================================
   FORM CONTROLS – Padronizados
   =========================================================== */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid var(--cinza-borda);
    font-size: .88rem;
    padding: .55rem .85rem;
    height: auto;
    min-height: 40px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

/* Dropdown destaque para alterar vistoriante */
.form-select.alterar-vistoriante {
    border: 2px solid var(--azul-claro);
    background: #f8fcff;
    box-shadow: 0 2px 8px rgba(0, 174, 239, 0.07);
    width: 260px; 
    min-width: 180px;
}

.form-select.alterar-vistoriante:focus,
.form-select.alterar-vistoriante:hover {
    border-color: var(--azul-escuro);
    background: #e6f4fa;
    box-shadow: 0 0 0 3px rgba(0, 174, 239, .13);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--azul-claro);
    box-shadow: 0 0 0 3px rgba(0, 174, 239, .12);
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-label {
    font-weight: 600;
    font-size: .82rem;
    color: #374151;
    margin-bottom: .3rem;
}

.input-group-text {
    background: var(--azul-escuro);
    color: var(--branco);
    border: 1px solid var(--azul-escuro);
    border-radius: 8px 0 0 8px;
    min-height: 40px;
}

/* Uniform row spacing inside form-section */
.form-section .row {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: .85rem;
}

.form-section .row > [class*="col"] {
    margin-bottom: .15rem;
}

/* ===========================================================
   PAGE HEADERS
   =========================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}

h2 {
    color: var(--azul-escuro);
    font-weight: 700;
    font-size: 1.35rem;
    margin: 0;
}

h2 i {
    color: var(--azul-claro);
}

/* ===========================================================
   ALERTS
   =========================================================== */
.alert {
    border-radius: 8px;
    font-size: .88rem;
    border: none;
}

/* ===========================================================
   DATA DISPLAY (Visualizar)
   =========================================================== */
.data-row {
    padding: .4rem 0;
}

.data-label {
    font-weight: 600;
    font-size: .82rem;
    color: var(--azul-escuro);
    display: block;
    margin-bottom: .1rem;
}

.data-value {
    font-size: .9rem;
    color: #374151;
    padding: .35rem .65rem;
    background: var(--cinza-bg);
    border-radius: 6px;
    min-height: 34px;
    display: flex;
    align-items: center;
}

/* ===========================================================
   LOGIN PAGE
   =========================================================== */
.login-page {
    background: linear-gradient(135deg, var(--azul-escuro) 0%, var(--azul-medio) 50%, var(--azul-claro) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    max-width: 420px;
    width: 100%;
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--sombra-lg);
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 2.5rem 2rem 1rem;
    background: var(--branco);
}

.login-header img {
    height: 72px;
    width: auto;
    margin-bottom: .75rem;
}

.login-header h3 {
    color: var(--azul-escuro);
    font-weight: 700;
    font-size: 1.3rem;
    margin-bottom: .25rem;
}

.login-header p {
    color: var(--cinza-texto);
    font-size: .88rem;
}

.login-card .card-body {
    padding: 1.5rem 2rem 2rem;
}

.login-card .btn-primary {
    background: var(--azul-escuro);
    border-color: var(--azul-escuro);
    padding: .6rem 1rem;
    font-size: .95rem;
}

.login-card .btn-primary:hover {
    background: var(--azul-hover);
}

/* ===========================================================
   MODAL
   =========================================================== */
.modal-content {
    border-radius: var(--radius);
    overflow: hidden;
    border: none;
}

/* ===========================================================
   SCROLLBAR
   =========================================================== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cinza-borda); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--azul-claro); }

/* ===========================================================
   RESPONSIVE
   =========================================================== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        width: var(--sidebar-w);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-w);
        transform: translateX(-100%);
    }

    body.sidebar-open.sidebar-collapsed .sidebar {
        transform: translateX(0);
    }

    .topbar-mobile {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem 1rem;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: none;
    }

    /* Page header: stack on mobile */
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
    }

    .page-header .btn {
        width: 100%;
        text-align: center;
    }

    /* Form row filters: stack */
    form.row.align-items-end > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Tables: compact on small screens */
    .table { font-size: .82rem; }
    .table thead th, .table tbody td { padding: .55rem .65rem; }
    .btn-sm { padding: .3rem .6rem; font-size: .78rem; }
}

@media (max-width: 575.98px) {
    .main-content { padding: 1rem .75rem; }
    .form-section { padding: 1rem; }
    h2 { font-size: 1.1rem; }
    .table { font-size: .78rem; }
    .table thead th, .table tbody td { padding: .45rem .5rem; }

    /* Cards: tighter padding */
    .card .card-body { padding: 1rem; }
    .card-header { font-size: .85rem; padding: .65rem 1rem; }
}

/* ---- Custom Modal (excluir / confirmar) ---- */
.custom-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}
.custom-modal-overlay.active { display: flex; }

.custom-modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.custom-modal-header {
    color: #fff;
    padding: 16px 20px;
    font-size: 1.1rem;
    font-weight: 600;
}

.custom-modal-body {
    text-align: center;
    padding: 28px 20px 16px;
}

.custom-modal-title {
    font-size: 1.15rem;
    margin: 14px 0 4px;
    color: #212529;
}

.custom-modal-subtitle {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0;
}

.custom-modal-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px 20px 22px;
}

.custom-btn {
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.15s;
}
.custom-btn:hover { opacity: 0.85; }

.custom-btn-cancel {
    background: #6c757d;
    color: #fff;
}

.custom-btn-danger {
    background: #dc3545;
    color: #fff;
}

.custom-btn-success {
    background: #198754;
    color: #fff;
}

.btn-excluir {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.btn-excluir:hover {
    background: #b02a37;
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.35);
}
.btn-excluir:active {
    background: #9a2530;
}

.btn-acao {
    background: var(--azul-escuro, #003B73);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-acao:hover {
    background: var(--azul-hover, #004A85);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 59, 115, 0.35);
}
.btn-acao:active {
    background: var(--azul-medio, #005DA4);
}
