/* global.css - Gestor ERP */

:root {
    /* Tema Dark - Minimalist Deep */
    --bg-body: #0f172a;
    --bg-sidebar: rgba(15, 23, 42, 0.9);
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --bg-hover: rgba(59, 130, 246, 0.12);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #334155;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    /* Tema Light - Crystal Clear & Indigo */
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-hover: rgba(99, 102, 241, 0.08);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #e11d48;
    --danger-hover: #be123c;
    --success: #059669;
    --warning: #d97706;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

/* Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

/* Layout */
.main-content {
    padding: 2rem 3rem;
}

.header-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header {
    margin-bottom: 1.5rem;
    /* Adiciona o espaço para baixo */
}

.breadcrumb {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Contêineres */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Abas */
.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 2px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.tabs-header::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 0.8rem 1.2rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: 0.3s;
    font-size: 0.9rem;
    border-radius: 8px 8px 0 0;
    position: relative;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(1);
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Formulários */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.2rem;
    margin-bottom: 1rem;
}

.sub-grid-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.2rem;
}

.form-row {
    display: grid;
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}

.form-row-2 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-row-3 {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.form-row-4 {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: 0.3s;
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-control:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.05);
}

/* Seções e Divisores */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i {
    color: var(--primary);
    font-size: 1.2rem;
}

.section-divider {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin: 2.5rem 0 1.5rem 0;
    padding-bottom: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

/* Botões */
.btn {
    padding: 0.8rem 1.4rem;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 4px rgba(225, 29, 72, 0.2);
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

/* Barra de Ações */
.action-bar {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.action-bar>div[style*="flex: 1"] {
    flex: 1;
}

.btn-sm {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    height: auto;
}

.btn-small {
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    height: auto;
}

/* Tabelas e Grids */
.grid-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.table-responsive,
.table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-height: 400px;
    overflow-y: auto;
}

/* Classes utilitárias para altura de grids */
.grid-sm {
    max-height: 250px !important;
}

.grid-md {
    max-height: 400px !important;
}

.grid-lg {
    max-height: 500px !important;
}

.grid-xl {
    max-height: 600px !important;
}


table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: rgba(0, 0, 0, 0.05);
}

th {
    background: var(--bg-sidebar);
    padding: 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 0.9rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.92rem;
}

tr.selected {
    background: var(--bg-hover);
    border-left: 3px solid var(--primary);
}

/* Busca */
.search-container {
    position: relative;
    width: 100%;
}

.search-container i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-container .form-control {
    padding-left: 2.8rem;
    border-radius: 8px;
    width: 100%;
    background: rgba(0, 0, 0, 0.2) !important;
}

.search-bar {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-bar i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.search-bar input {
    width: 100%;
    padding: 0.55rem 1rem 0.55rem 2.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: all 0.3s;
}

.search-bar input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Toggles e Badges */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: rgba(100, 116, 139, 0.3);
    border-radius: 20px;
    transition: 0.3s;
}

.toggle-track::after {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-track {
    background: var(--primary);
}

.toggle-switch input:checked+.toggle-track::after {
    transform: translateX(20px);
}

.badge-status {
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
    vertical-align: middle;
    line-height: normal;
}

.badge-novo {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-edit {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Responsividade */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .action-bar {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .sub-grid-row,
    .form-grid {
        display: flex !important;
        flex-direction: column !important;
    }

    .form-group {
        max-width: 100% !important;
    }
}

tr.data-row {
    transition: background-color 0.2s ease;
    cursor: pointer;
    /* Muda o cursor para a 'mãozinha' de seleção */
}

tr.data-row:hover {
    background-color: var(--bg-hover) !important;
    box-shadow: inset 4px 0 0 0 var(--primary);
    background: var(--bg-hover);
}

/* Esconde o grid em abas que não estão ativas */
/* Esta regra assume que o grid está dentro de um container com a classe .tab-content */
.tab-content:not(.active) .grid-header,
.tab-content:not(.active) .table-wrap,
.tab-content:not(.active) .table-responsive {
    display: none !important;
}