﻿:root {
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 72px;
    --bg-page: #f3f4f6;
    --brand-green: #2f6b48;
    --brand-brown: #7a4d2b;
}

body {
    background: linear-gradient(160deg, #f8f5f2 0%, #f2f6f3 45%, #eef2f6 100%);
    min-height: 100vh;
    margin: 0;
}

.app-shell {
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: linear-gradient(180deg, #1f2f2a 0%, #223d33 55%, #2f6b48 100%);
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.2s ease, transform 0.2s ease;
    z-index: 6;
}

.sidebar-close,
.sidebar-backdrop {
    display: none;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar .sidebar-link {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.55rem 0.7rem;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.sidebar .sidebar-link:hover,
.sidebar .sidebar-link:focus {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.12);
}

.sidebar .sidebar-link.active {
    color: #1f2f2a;
    background-color: #e9ecef;
    font-weight: 600;
}

.sidebar .sidebar-link.active:hover,
.sidebar .sidebar-link.active:focus {
    color: #1f2f2a;
    background-color: #dde2e7;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease;
}

.brand-text {
    transition: opacity 0.2s ease;
}

.content {
    min-width: 0;
    background: transparent;
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
}

.card {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07);
}

.dashboard-kpi {
    --dashboard-kpi-accent: var(--brand-green);
    --dashboard-kpi-tint: rgba(47, 107, 72, 0.12);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top: 4px solid var(--dashboard-kpi-accent);
}

.dashboard-kpi::after {
    content: '';
    position: absolute;
    top: -2.75rem;
    right: -2.75rem;
    width: 8rem;
    height: 8rem;
    border-radius: 50%;
    background: var(--dashboard-kpi-tint);
    pointer-events: none;
}

.dashboard-kpi--month {
    --dashboard-kpi-accent: #2563a6;
    --dashboard-kpi-tint: rgba(37, 99, 166, 0.12);
}

.dashboard-kpi--ticket {
    --dashboard-kpi-accent: var(--brand-brown);
    --dashboard-kpi-tint: rgba(122, 77, 43, 0.12);
}

.dashboard-kpi--reservations {
    --dashboard-kpi-accent: #a16207;
    --dashboard-kpi-tint: rgba(161, 98, 7, 0.13);
}

.dashboard-kpi__header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.dashboard-kpi__label {
    margin: 0 0 0.35rem;
    color: #667078;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.dashboard-kpi__value {
    color: #1f2933;
    font-size: clamp(1.35rem, 2.1vw, 1.75rem);
    font-weight: 700;
    line-height: 1.15;
}

.dashboard-kpi__icon {
    display: inline-flex;
    flex: 0 0 2.5rem;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    color: var(--dashboard-kpi-accent);
    background: var(--dashboard-kpi-tint);
    font-size: 1.15rem;
}

.dashboard-kpi__caption {
    position: relative;
    z-index: 1;
    margin-top: 0.35rem;
    color: #6c757d;
    font-size: 0.8rem;
}

.dashboard-kpi__meta {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 0.75rem;
    color: #495057;
    font-size: 0.85rem;
}

.dashboard-kpi__impact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.65rem;
}

.dashboard-kpi__meta-label {
    flex-basis: 100%;
    color: #6c757d;
    font-size: 0.75rem;
}

/* Avisos flutuantes não alteram o espaço ocupado pelos formulários. */
.app-notifications {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1090;
    width: min(380px, calc(100% - 2rem));
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    pointer-events: none;
}

.app-notifications .toast {
    width: 100%;
    margin-bottom: 0.75rem;
    background: #fff;
    border-left: 4px solid var(--notification-color, #087990);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.16);
    pointer-events: auto;
}

.app-toast--success { --notification-color: #24663f; }
.app-toast--warning { --notification-color: #8a5707; }
.app-toast--danger { --notification-color: #b02a37; }
.app-toast--info { --notification-color: #087990; }

.app-notifications .toast-header {
    color: var(--notification-color);
    background: transparent;
}

.app-notifications .toast-body {
    color: #212529;
    overflow-wrap: anywhere;
}

@media print {
    .app-notifications { display: none; }
}

.table thead th {
    white-space: nowrap;
}

.orcamentos-scroll,
.vendas-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.orcamentos-scroll table,
.vendas-scroll table {
    width: max-content;
    min-width: 100%;
}

.orcamentos-scroll th,
.orcamentos-scroll td,
.vendas-scroll th,
.vendas-scroll td {
    white-space: nowrap;
}

.nfe-actions {
    overflow-x: auto;
    padding-bottom: 4px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.nfe-actions .btn,
.nfe-actions .badge {
    white-space: nowrap;
}

.nfe-actions::-webkit-scrollbar {
    height: 6px;
}

.nfe-actions::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 999px;
}

/* Editor de itens: mantém a tabela no desktop e transforma cada linha em cartão no celular. */
.item-lines-table .linha-total {
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .item-lines-editor {
        overflow-x: visible;
    }

    .item-lines-table,
    .item-lines-table thead,
    .item-lines-table tbody,
    .item-lines-table tr,
    .item-lines-table td {
        display: block;
        width: 100%;
    }

    .item-lines-table {
        border: 0;
    }

    .item-lines-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .item-lines-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .item-lines-table tbody tr {
        padding: 0.75rem;
        border: 1px solid #dfe4e8;
        border-radius: 0.75rem;
        background: #fff;
        box-shadow: 0 2px 8px rgba(31, 47, 42, 0.07);
    }

    .item-lines-table > :not(caption) > * > * {
        border: 0;
    }

    .item-lines-table tbody td {
        display: grid;
        grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: center;
        padding: 0.45rem 0;
        white-space: normal;
    }

    .item-lines-table tbody td::before {
        content: attr(data-label);
        color: #5c6770;
        font-size: 0.75rem;
        font-weight: 600;
    }

    .item-lines-table tbody td:first-child {
        padding-top: 0;
    }

    .item-lines-table tbody td:last-child {
        display: flex;
        justify-content: flex-end;
        padding-bottom: 0;
    }

    .item-lines-table tbody td:last-child::before {
        display: none;
    }

    .item-lines-table tbody .linha-total {
        color: var(--brand-green);
        font-weight: 700;
    }
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background:
        radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.1), transparent 28rem),
        radial-gradient(circle at 85% 85%, rgba(122, 77, 43, 0.3), transparent 24rem),
        linear-gradient(145deg, #172821 0%, #223d33 52%, #2f6b48 100%);
}

.auth-card {
    width: min(440px, 100%);
    overflow: hidden;
    border-top: 5px solid var(--brand-brown);
    box-shadow: 0 24px 60px rgba(8, 20, 15, 0.3);
}

.auth-logo-frame {
    display: flex;
    width: 5.5rem;
    height: 5.5rem;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    border: 1px solid rgba(47, 107, 72, 0.18);
    border-radius: 1.25rem;
    background: #f8f5f2;
    box-shadow: 0 8px 20px rgba(31, 47, 42, 0.13);
}

.auth-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0.85rem;
}

.auth-brand h1 {
    color: #1f2f2a;
    font-weight: 700;
}

.auth-subtitle {
    color: #5f6d67;
}

.password-toggle {
    min-width: 3rem;
    color: var(--brand-green);
    border-color: #ced4da;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: #fff;
    background: var(--brand-green);
    border-color: var(--brand-green);
}

/* Sidebar colapsado */
.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
    flex: 0 0 var(--sidebar-width-collapsed);
}

.sidebar-collapsed .sidebar .brand-text,
.sidebar-collapsed .sidebar .nav-link .label {
    display: none;
}

.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
}

.sidebar-collapsed .brand-logo {
    transform: scale(0.9);
}

.sidebar-collapsed .content {
    margin-left: var(--sidebar-width-collapsed);
    width: calc(100% - var(--sidebar-width-collapsed));
}

@media (max-width: 992px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .app-shell {
        display: block !important;
    }

    .sidebar,
    .sidebar-collapsed .sidebar {
        width: min(280px, calc(100vw - 48px));
        max-width: 100%;
        position: fixed;
        inset: 0 auto 0 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1045;
        box-shadow: 12px 0 30px rgba(0, 0, 0, 0.24);
    }

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

    .sidebar-collapsed .sidebar .brand-text,
    .sidebar-collapsed .sidebar .nav-link .label {
        display: block;
    }

    .sidebar-collapsed .sidebar .nav-link {
        justify-content: flex-start;
    }

    .sidebar-collapsed .brand-logo {
        transform: none;
    }

    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        background: rgba(15, 23, 42, 0.52);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 1040;
    }

    .sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .content,
    .sidebar-collapsed .content {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .topbar {
        gap: 0.75rem;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .topbar-title {
        flex: 1 1 auto;
        min-width: 0;
    }

    .topbar-title h1 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-title .breadcrumb,
    .topbar-user .user-summary {
        display: none;
    }

    .content > section {
        padding: 1rem !important;
    }
}

@media (max-width: 480px) {
    .topbar-user {
        gap: 0.5rem !important;
    }

    .logout-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-backdrop {
        transition: none;
    }
}
