/* ==========================================================================
   ConstruTec - Tema visual (Bootstrap 5.3)
   Moderniza a aparência e a responsividade sem exigir mudanças nas telas.
   ========================================================================== */

:root {
    --ct-primary: #2563eb;
    --ct-primary-rgb: 37, 99, 235;
    --ct-primary-dark: #1d4ed8;
    --ct-accent: #f59e0b;
    --ct-bg: #f4f6fa;
    --ct-surface: #ffffff;
    --ct-border: #e5e7eb;
    --ct-text: #1f2937;
    --ct-muted: #6b7280;
    --ct-nav-bg: #0f172a;
    --ct-radius: .75rem;
    --ct-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 12px rgba(15, 23, 42, .06);
    --ct-nav-height: 64px;

    --bs-primary: var(--ct-primary);
    --bs-primary-rgb: var(--ct-primary-rgb);
    --bs-body-font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-bg: var(--ct-bg);
    --bs-body-color: var(--ct-text);
    --bs-border-color: var(--ct-border);
    --bs-link-color: var(--ct-primary);
    --bs-link-color-rgb: var(--ct-primary-rgb);
    --bs-link-hover-color: var(--ct-primary-dark);
    --bs-border-radius: .5rem;
}

html, body {
    min-height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--ct-bg);
    color: var(--ct-text);
    font-feature-settings: "cv03", "cv04", "cv11";
    -webkit-font-smoothing: antialiased;
}

/* O conteúdo começa abaixo da barra fixa e o rodapé fica no fim da página */
main {
    flex: 1 0 auto;
    margin-top: var(--ct-nav-height);
    padding: 1.5rem 0 2.5rem;
}

main > h5 {
    max-width: 720px;
    margin: 2rem auto;
    padding: 1.25rem 1.5rem;
    background: var(--ct-surface);
    border: 1px solid var(--ct-border);
    border-left: 4px solid var(--ct-accent);
    border-radius: var(--ct-radius);
    box-shadow: var(--ct-shadow);
    font-size: 1rem;
    font-weight: 500;
}

a {
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   Barra de navegação
   -------------------------------------------------------------------------- */
.ct-navbar {
    min-height: var(--ct-nav-height);
    background: var(--ct-nav-bg) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
    padding: .5rem 1rem;
}

.ct-navbar .navbar-brand img {
    height: 38px;
    width: auto;
}

.ct-navbar .nav-link {
    color: rgba(255, 255, 255, .78);
    font-weight: 500;
    font-size: .95rem;
    padding: .5rem .85rem !important;
    border-radius: .5rem;
    transition: background-color .15s, color .15s;
}

.ct-navbar .nav-link:hover,
.ct-navbar .nav-link:focus,
.ct-navbar .nav-link.show,
.ct-navbar .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.ct-navbar .nav-link .bi {
    margin-right: .35rem;
    opacity: .85;
}

.ct-navbar .dropdown-menu {
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius);
    box-shadow: 0 10px 30px rgba(15, 23, 42, .15);
    padding: .4rem;
    min-width: 13rem;
}

.ct-navbar .dropdown-item {
    border-radius: .4rem;
    padding: .5rem .75rem;
    font-size: .925rem;
}

.ct-navbar .dropdown-item .bi {
    width: 1.25rem;
    margin-right: .4rem;
    color: var(--ct-muted);
}

.ct-navbar .dropdown-item:active {
    background: var(--ct-primary);
}

.ct-navbar .dropdown-item:active .bi {
    color: #fff;
}

.ct-obra-badge {
    display: flex;
    align-items: center;
    gap: .6rem;
    max-width: 340px;
    padding: .4rem .85rem;
    color: #fff;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    font-size: .85rem;
    line-height: 1.2;
}

.ct-obra-badge:hover {
    color: #fff;
    background: rgba(255, 255, 255, .14);
}

.ct-obra-badge .bi {
    color: var(--ct-accent);
    font-size: 1.1rem;
}

.ct-obra-badge small {
    display: block;
    color: rgba(255, 255, 255, .6);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.ct-obra-badge span {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (max-width: 991.98px) {
    .ct-navbar .navbar-collapse {
        max-height: calc(100vh - var(--ct-nav-height));
        overflow-y: auto;
        padding: .5rem 0 1rem;
    }
    .ct-navbar .dropdown-menu {
        background: transparent;
        border: 0;
        box-shadow: none;
        padding: 0 0 0 1.75rem;
    }
    .ct-navbar .dropdown-item {
        color: rgba(255, 255, 255, .75);
    }
    .ct-navbar .dropdown-item .bi {
        color: rgba(255, 255, 255, .5);
    }
    .ct-navbar .dropdown-item:hover,
    .ct-navbar .dropdown-item:focus {
        color: #fff;
        background: rgba(255, 255, 255, .08);
    }
    .ct-navbar .dropdown-divider {
        border-color: rgba(255, 255, 255, .12);
    }
    .ct-obra-badge {
        max-width: 100%;
        margin-top: .75rem;
        border-radius: var(--ct-radius);
    }
}

/* --------------------------------------------------------------------------
   Cabeçalho das páginas
   -------------------------------------------------------------------------- */
.cabecalhoInicio {
    padding: .5rem 0 1.25rem;
    background: transparent;
}

.cabecalhoInicio h2 {
    font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.85rem);
    font-weight: 700;
    letter-spacing: -.02em;
    margin-bottom: .25rem;
}

.cabecalhoInicio h6 {
    color: var(--ct-muted);
    font-weight: 400;
    font-size: .95rem;
    margin-bottom: 0;
}

.cabecalhoInicio h6:not(:empty)::before {
    content: "\F3E8";               /* bi-geo-alt */
    font-family: "bootstrap-icons";
    margin-right: .35rem;
    color: var(--ct-accent);
}

.cabecalhoInicio .alert {
    margin-top: 1rem;
    max-width: 720px;
}

.cabecalhoInicio .btn {
    padding: .55rem 1.25rem;
}

.cabecalhoInicio .btn-primary::before {
    content: "\F4FE";               /* bi-plus-lg */
    font-family: "bootstrap-icons";
    margin-right: .4rem;
    vertical-align: -.1em;
}

/* --------------------------------------------------------------------------
   Cartões, botões e alertas
   -------------------------------------------------------------------------- */
.card {
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius);
    box-shadow: var(--ct-shadow);
    overflow: hidden;
}

.btn {
    font-weight: 500;
    border-radius: .5rem;
}

.btn-primary {
    --bs-btn-bg: var(--ct-primary);
    --bs-btn-border-color: var(--ct-primary);
    --bs-btn-hover-bg: var(--ct-primary-dark);
    --bs-btn-hover-border-color: var(--ct-primary-dark);
    --bs-btn-active-bg: var(--ct-primary-dark);
    --bs-btn-active-border-color: var(--ct-primary-dark);
    --bs-btn-disabled-bg: var(--ct-primary);
    --bs-btn-disabled-border-color: var(--ct-primary);
    box-shadow: 0 1px 2px rgba(var(--ct-primary-rgb), .3);
}

.alert {
    border-radius: var(--ct-radius);
    border-width: 0 0 0 4px;
}

.alert-success {
    border-left-color: #16a34a;
}

/* --------------------------------------------------------------------------
   Tabelas
   -------------------------------------------------------------------------- */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table {
    --bs-table-hover-bg: rgba(var(--ct-primary-rgb), .04);
    margin-bottom: 0;
    font-size: .925rem;
}

.table > :not(caption) > * > * {
    padding: .7rem .75rem;
    border-color: var(--ct-border);
}

.table-sm > :not(caption) > * > * {
    padding: .5rem .6rem;
}

.table-bordered > :not(caption) > * > * {
    border-width: 0 0 1px 0;
}

.table-bordered > :not(caption) > * {
    border-width: 0;
}

tr {
    vertical-align: middle;
}

/* Valores (últimas colunas) nunca quebram linha: "R$ 1.532,50" */
@media (min-width: 768px) {
    .table td:nth-last-child(-n+2) {
        white-space: nowrap;
    }
}

thead,
.table thead.table-primary {
    font-size: .75rem;
}

.table > thead > tr > th,
.table thead.table-primary th {
    --bs-table-bg: #f8fafc;
    --bs-table-color: var(--ct-muted);
    background: #f8fafc;
    color: var(--ct-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    border-bottom: 1px solid var(--ct-border);
}

.table tbody tr:last-child > * {
    border-bottom: 0;
}

.table tfoot {
    font-weight: 600;
    background: #f8fafc;
}

/* Ícones de editar / excluir com área de toque confortável */
.table td a > .bi-pencil-square,
.table td a > .bi-trash3,
.table td a > .bi-person-rolodex {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: .45rem;
    font-size: 1rem;
    transition: background-color .15s;
}

.table td a > .bi-pencil-square:hover,
.table td a > .bi-person-rolodex:hover {
    background: rgba(var(--ct-primary-rgb), .1);
}

.table td a > .bi-trash3 {
    color: #dc2626;
}

.table td a > .bi-trash3:hover {
    background: rgba(220, 38, 38, .1);
}

.table td:first-child:has(> a > .bi-pencil-square) {
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    main {
        padding-top: 1rem;
    }
    main > .container-fluid,
    main > .container {
        padding-left: .75rem;
        padding-right: .75rem;
    }
    .table {
        font-size: .875rem;
    }
    /* Tabelas com muitas colunas ganham largura mínima e rolam na horizontal */
    .table:has(thead th:nth-child(5)) {
        min-width: 760px;
    }
    .table:has(thead th:nth-child(8)) {
        min-width: 1080px;
    }
    .table:has(thead th:nth-child(5)) td:nth-last-child(-n+2) {
        white-space: nowrap;
    }
}

/* --------------------------------------------------------------------------
   Formulários
   -------------------------------------------------------------------------- */
main form {
    background: var(--ct-surface);
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius);
    box-shadow: var(--ct-shadow);
    max-width: 1140px;
    margin: 0 auto;
    padding: 1rem 1.5rem 1.5rem;
}

main form .container,
main form .container-fluid {
    padding-left: 0;
    padding-right: 0;
}

.form-label,
.form-label p,
.form-label .h6 {
    font-size: .875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .35rem;
}

.form-control,
.form-select {
    background-color: #fff;
    border-radius: .5rem;
    border-color: #d1d5db;
    padding-top: .55rem;
    padding-bottom: .55rem;
}

.form-select-lg {
    font-size: 1rem;
    padding: .55rem 2.25rem .55rem .75rem;
    border-radius: .5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ct-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--ct-primary-rgb), .18);
}

/* Larguras fixas dos campos (w-25, w-50, w-75) viram 100% em telas pequenas */
@media (max-width: 767.98px) {
    main form {
        margin: 0 .75rem;
        padding: .75rem 1rem 1.25rem;
        border-radius: .6rem;
    }
    main form .w-25,
    main form .w-50,
    main form .w-75 {
        width: 100% !important;
    }
    main form .btn {
        width: 100%;
        margin-bottom: .5rem;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    main form .w-25 {
        width: 40% !important;
    }
    main form .w-50 {
        width: 70% !important;
    }
    main form .w-75 {
        width: 100% !important;
    }
}

/* --------------------------------------------------------------------------
   Rodapé
   -------------------------------------------------------------------------- */
.ct-footer {
    flex-shrink: 0;
    background: var(--ct-surface);
    border-top: 1px solid var(--ct-border);
    color: var(--ct-muted);
    font-size: .85rem;
    padding: 1rem 0;
}

.ct-footer a {
    color: var(--ct-muted);
}

.ct-footer a:hover {
    color: var(--ct-primary);
}

/* --------------------------------------------------------------------------
   Recibos / fotos (X para remover imagens)
   -------------------------------------------------------------------------- */
.container-delete {
    display: inline-block;
    position: relative;
}

.container-delete img {
    border-radius: .5rem;
}

.icon-delete {
    position: absolute;
    top: 6px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    color: #dc2626;
    background: rgba(255, 255, 255, .92);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
    font-size: 1rem;
    font-weight: 900;
}

/* --------------------------------------------------------------------------
   Diversos
   -------------------------------------------------------------------------- */
.nav-scroller {
    position: relative;
    z-index: 2;
    height: 2.75rem;
    overflow-y: hidden;
}

.nav-scroller .nav {
    display: flex;
    flex-wrap: nowrap;
    padding-bottom: 1rem;
    margin-top: -1px;
    overflow-x: auto;
    text-align: center;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.tooltip-inner {
    white-space: pre-line;
    text-align: left;
}

@media print {
    .ct-navbar, .ct-footer, .cabecalhoInicio .btn {
        display: none !important;
    }
    main {
        margin-top: 0;
    }
    .card, main form {
        box-shadow: none;
    }
}
