/* =====================================================================
   Controle de Vegetal - estilos proprios + variaveis de tema
   ===================================================================== */

:root {
    --cv-sidebar-w: 256px;
    --cv-header-h: 60px;
    --cv-accent: #2f9e7e;
    --cv-accent-rgb: 47, 158, 126;
    --cv-radius: 14px;
}

/* Acento suave aplicado ao Bootstrap (claro) */
[data-bs-theme="light"] {
    --bs-primary: var(--cv-accent);
    --bs-primary-rgb: var(--cv-accent-rgb);
    --bs-body-bg: #f4f6f8;
    --bs-body-color: #2b3440;
    --cv-sidebar-bg: #ffffff;
    --cv-sidebar-color: #4a5563;
    --cv-card-bg: #ffffff;
    --cv-border: #e7ebf0;
    --cv-header-bg: rgba(255, 255, 255, 0.85);
}

[data-bs-theme="dark"] {
    --bs-primary: #38b893;
    --bs-primary-rgb: 56, 184, 147;
    --bs-body-bg: #11161c;
    --bs-body-color: #d7dee6;
    --cv-sidebar-bg: #161d26;
    --cv-sidebar-color: #aab4c0;
    --cv-card-bg: #1a222c;
    --cv-border: #2a333f;
    --cv-header-bg: rgba(22, 29, 38, 0.85);
}

body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: rgba(var(--bs-primary-rgb), 0.88);
    --bs-btn-hover-border-color: rgba(var(--bs-primary-rgb), 0.88);
    --bs-btn-active-bg: rgba(var(--bs-primary-rgb), 0.92);
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
    color: #fff;
}

/* ---------- Layout shell ---------- */
.app-shell { min-height: 100vh; }

.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--cv-sidebar-w);
    background: var(--cv-sidebar-bg);
    border-right: 1px solid var(--cv-border);
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: transform .25s ease;
    overflow-y: auto;
}

.sidebar-brand {
    height: var(--cv-header-h);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0 1.25rem;
    font-weight: 700;
    color: var(--bs-primary);
    border-bottom: 1px solid var(--cv-border);
    font-size: 1.05rem;
}
.sidebar-brand i { font-size: 1.4rem; }

.sidebar-nav { padding: .75rem .6rem; display: flex; flex-direction: column; gap: .15rem; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .8rem;
    border-radius: 10px;
    color: var(--cv-sidebar-color);
    font-weight: 500;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(var(--bs-primary-rgb), 0.08); color: var(--bs-primary); }
.sidebar-nav .nav-link.active { background: rgba(var(--bs-primary-rgb), 0.14); color: var(--bs-primary); }
.sidebar-nav .nav-link.sub { padding-left: 1.6rem; font-size: .9rem; }
.sidebar-nav .nav-link.sub i { font-size: .8rem; }

.app-main {
    margin-left: var(--cv-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--cv-header-h);
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    background: var(--cv-header-bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--cv-border);
    z-index: 1030;
}
.app-title { font-size: 1.15rem; font-weight: 600; margin: 0; }

.app-content { flex: 1; }
.app-footer {
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--cv-border);
    color: var(--bs-secondary-color);
    font-size: .85rem;
    text-align: center;
}

/* ---------- Botoes utilitarios ---------- */
.btn-icon {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--cv-border);
    background: var(--cv-card-bg);
    color: var(--bs-body-color);
    font-size: 1.1rem;
}
.btn-icon:hover { color: var(--bs-primary); border-color: var(--bs-primary); }

.btn-user {
    display: flex; align-items: center; gap: .55rem;
    background: transparent; border: none; color: var(--bs-body-color);
}
.btn-user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--bs-primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600;
}
.btn-user .user-name { display: block; font-weight: 600; font-size: .9rem; line-height: 1.1; }
.btn-user .user-role { display: block; font-size: .72rem; color: var(--bs-secondary-color); }

/* Icones de tema */
.theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: inline; }

/* ---------- Cards ---------- */
.card {
    background: var(--cv-card-bg);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--cv-border);
    font-weight: 600;
}

/* Stat cards do dashboard */
.stat-card .card-body { display: flex; flex-direction: column; gap: .2rem; }
.stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.35rem; margin-bottom: .4rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-value small { font-size: .9rem; font-weight: 500; color: var(--bs-secondary-color); }
.stat-label { color: var(--bs-secondary-color); font-size: .85rem; }

/* ---------- Tabelas ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--bs-secondary-color); font-weight: 600; border-bottom: 1px solid var(--cv-border);
}
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: " \2195"; opacity: .35; font-size: .8em; }
.table-search { max-width: 280px; }

/* ---------- Auth ---------- */
.auth-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), .12), var(--bs-body-bg) 60%);
    padding: 1rem;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { border-radius: 18px; }
.auth-logo {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto;
    background: rgba(var(--bs-primary-rgb), .14); color: var(--bs-primary);
    display: flex; align-items: center; justify-content: center; font-size: 2rem;
}

/* ---------- Erro ---------- */
.error-code { font-size: 5rem; font-weight: 800; color: var(--bs-primary); line-height: 1; }

/* ---------- Backdrop sidebar mobile ---------- */
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 1040; display: none;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* ---------- Responsivo ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
}

/* ---------- Custom Search Select (Autocomplete) ---------- */
.search-select-wrapper {
    position: relative;
    width: 100%;
}
.input-group > .search-select-wrapper {
    flex: 1 1 auto;
    width: 1%;
}
.input-group > .search-select-wrapper:first-child > .search-select-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.input-group > .search-select-wrapper:not(:first-child) > .search-select-input {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
.input-group > .search-select-wrapper:not(:last-child) > .search-select-input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 0;
}
.search-select-dropdown {
    background-color: var(--cv-card-bg);
    border: 1px solid var(--cv-border);
    border-radius: 8px;
    z-index: 1060 !important;
}
.search-select-dropdown .dropdown-item {
    color: var(--bs-body-color);
}
.search-select-dropdown .dropdown-item:hover,
.search-select-dropdown .dropdown-item:focus {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
}

/* ---------- SweetAlert2 Customizations ---------- */
.swal2-custom-popup {
    background-color: var(--cv-card-bg) !important;
    color: var(--bs-body-color) !important;
    border: 1px solid var(--cv-border) !important;
    border-radius: var(--cv-radius) !important;
    font-family: system-ui, -apple-system, sans-serif !important;
}
.swal2-custom-title {
    color: var(--bs-body-color) !important;
}
.swal2-custom-html {
    color: var(--bs-secondary-color) !important;
}
.swal2-custom-confirm {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: #fff !important;
    box-shadow: none !important;
}
.swal2-custom-confirm:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.88) !important;
    border-color: rgba(var(--bs-primary-rgb), 0.88) !important;
}
.swal2-custom-cancel {
    background-color: rgba(var(--bs-primary-rgb), 0.05) !important;
    border: 1px solid var(--cv-border) !important;
    color: var(--bs-body-color) !important;
    box-shadow: none !important;
}
.swal2-custom-cancel:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
    color: var(--bs-primary) !important;
}
