/* VARIÁVEIS E RESET */
:root {
    --primary-color: #0f172a;
    /* Azul Marinho Profundo */
    --secondary-color: #334155;
    /* Cinza Azulado */
    --accent-color: #2563eb;
    /* Azul Vibrante para Ações */
    --accent-hover: #1d4ed8;
    --bg-color: #f1f5f9;
    /* Fundo Cinza Claro */
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* LAYOUT */
.container {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.025em;
}

.sidebar-menu {
    padding: 20px 10px;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: var(--radius);
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s ease;
    font-weight: 500;
    text-decoration: none;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.menu-item.active {
    background-color: var(--accent-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.menu-item i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* HEADER */
.header {
    background: var(--card-bg);
    padding: 0 30px;
    height: var(--header-height);
    border-radius: var(--radius);
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-badge {
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* DASHBOARD CARDS */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--accent-color);
}

.card h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.card .number {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary-color);
}

.card.alert::before {
    background: var(--danger-color);
}

.card.alert .number {
    color: var(--danger-color);
}

.card.success::before {
    background: var(--success-color);
}

.card.warning::before {
    background: var(--warning-color);
}

/* TABELAS */
.table-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 30px;
}

.table-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h2 {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

thead {
    background-color: #f8fafc;
}

th {
    padding: 16px 24px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
}

tbody tr:hover {
    background-color: #f8fafc;
}

/* BADGES */
.badge {
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #e0f2fe;
    color: #075985;
}

/* FORMULÁRIOS */
.form-container {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* BOTÕES */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
    gap: 8px;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background-color: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-color);
}

.modal-header {
    background-color: #f8fafc;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 30px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* LOADING */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* RESPONSIVIDADE */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }

    .sidebar.open {
        width: var(--sidebar-width);
    }
}

/* =========================================
   ESTILOS ADICIONAIS (COMPATIBILIDADE JS)
   ========================================= */

/* SEÇÕES (CRUCIAL PARA NAVEGAÇÃO) */
.section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.section.active {
    display: block;
}

/* STATUS (COMPATIBILIDADE COM JS EXISTENTE) */
.status-adequado {
    color: #166534;
    background: #dcfce7;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-atencao {
    color: #92400e;
    background: #fef3c7;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-critico {
    color: #991b1b;
    background: #fee2e2;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: var(--radius);
    background: #f8fafc;
}

.empresas-checkbox-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.empresas-checkbox-item:last-child {
    margin-bottom: 0;
}

.empresas-checkbox-item label {
    margin-bottom: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
}

.empresas-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

/* AUTOCOMPLETE MATERIAIS */
.material-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    display: none;
}

.material-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.material-item:hover {
    background: #f8fafc;
}

.material-item:last-child {
    border-bottom: none;
}

.material-nome {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.material-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    display: block;
}

/* BUSCA */
.search-bar {
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* LOADING */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* RESPONSIVIDADE */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }

    .sidebar.open {
        width: var(--sidebar-width);
    }
}

/* =========================================
   ESTILOS ADICIONAIS (COMPATIBILIDADE JS)
   ========================================= */

/* SEÇÕES (CRUCIAL PARA NAVEGAÇÃO) */
.section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.section.active {
    display: block;
}

/* STATUS (COMPATIBILIDADE COM JS EXISTENTE) */
.status-adequado {
    color: #166534;
    background: #dcfce7;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-atencao {
    color: #92400e;
    background: #fef3c7;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-critico {
    color: #991b1b;
    background: #fee2e2;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: var(--radius);
    background: #f8fafc;
}

.empresas-checkbox-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.empresas-checkbox-item:last-child {
    margin-bottom: 0;
}

.empresas-checkbox-item label {
    margin-bottom: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
}

.empresas-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

/* AUTOCOMPLETE MATERIAIS */
.material-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    display: none;
}

.material-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.material-item:hover {
    background: #f8fafc;
}

.material-item:last-child {
    border-bottom: none;
}

.material-nome {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.material-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    display: block;
}

/* BUSCA */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
}

/* TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease-out;
    min-width: 300px;
}

.alert-success {
    background-color: #f0fdf4;
    border-left: 4px solid #10b981;
    color: #166534;
}

.alert-error {
    background-color: #fef2f2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.alert-warning {
    background-color: #fefce8;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}