/* ==========================================================================
   Uhuu Smart Alert & Sistema de alerta de lotes - High-Performance Design System
   Cores Oficiais: #000000 (Preto), #DF387F (Rosa Magenta Uhuu), #FFFFFF (Branco)
   Desenvolvido por Terceirizario (terceirizario.com.br)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
    --bg-dark: #000000;
    --bg-surface: #0b0c10;
    --card-bg: #0d0f17;
    --card-border: rgba(223, 56, 127, 0.25);
    --primary: #DF387F;
    --primary-hover: #f0498f;
    --primary-glow: rgba(223, 56, 127, 0.35);
    --accent: #FF5C9D;
    --text-main: #FFFFFF;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --sidebar-width: 260px;
    --sidebar-compact-width: 74px;
    --header-height: 70px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --transition-fast: all 0.15s ease-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ── SUPORTE A MENU COMPACTO (COLLAPSED SIDEBAR) ────────────────────────── */
body.sidebar-collapsed {
    --sidebar-width: 74px;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-compact-width);
}

body.sidebar-collapsed .sidebar-header {
    padding: 0 10px;
    justify-content: center;
}

body.sidebar-collapsed .brand-title,
body.sidebar-collapsed .brand-tag,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-item-text,
body.sidebar-collapsed .sidebar-client-info,
body.sidebar-collapsed .dev-branding-card p,
body.sidebar-collapsed .dev-branding-card .dev-subtext {
    display: none !important;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    font-size: 20px;
}

body.sidebar-collapsed .app-header,
body.sidebar-collapsed .app-main-content {
    margin-left: var(--sidebar-compact-width);
    width: calc(100% - var(--sidebar-compact-width));
}

/* ── APP LAYOUT ──────────────────────────────────────────────────────────── */
.app-sidebar {
    width: var(--sidebar-width);
    background: #07080c;
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width var(--transition-fast);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--card-border);
    gap: 10px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    overflow: hidden;
}

.brand-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 0 12px var(--primary-glow);
}

.brand-title {
    font-weight: 800;
    font-size: 19px;
    color: #ffffff;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.brand-tag {
    font-size: 10px;
    background: var(--primary-glow);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 1px;
    padding: 12px 10px 4px;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition-fast);
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(223, 56, 127, 0.15);
    color: #ffffff;
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.sidebar-footer {
    padding: 16px 10px;
    border-top: 1px solid var(--card-border);
    background: #040508;
}

.dev-branding-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
}

.dev-branding-card p {
    font-size: 11px;
    color: var(--text-muted);
}

.dev-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    transition: var(--transition-fast);
}

.dev-link:hover {
    text-decoration: underline;
    color: #fff;
}

/* ── HEADER & MAIN (OCUPA 100% DO ESPAÇO RESTANTE DA TELA DE FORMA ULTRA RÁPIDA) ── */
.app-header {
    height: var(--header-height);
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    background: #0a0b10;
    border-bottom: 1px solid var(--card-border);
    position: fixed;
    top: 0;
    right: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: margin-left var(--transition-fast), width var(--transition-fast);
}

.header-title h1 {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 30px;
    border: 1px solid var(--card-border);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
}

.user-info span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
}

.user-info small {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.app-main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    width: calc(100% - var(--sidebar-width));
    padding: 24px 30px;
    min-height: calc(100vh - var(--header-height));
    box-sizing: border-box;
    transition: margin-left var(--transition-fast), width var(--transition-fast);
}

/* ── LAYOUT SPLIT (OCUPA TODO O ESPAÇO SEM GAPS VAZIOS NO LADO DIREITO) ── */
.split-layout {
    display: flex;
    gap: 24px;
    width: 100%;
    align-items: flex-start;
}

.split-form {
    width: 360px;
    min-width: 320px;
    flex-shrink: 0;
}

.split-main {
    flex: 1;
    min-width: 0; /* Previne overflow flex em tabelas grandes */
}

/* ── COMPONENTS & CARDS ─────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 22px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    margin-bottom: 24px;
    transition: border-color var(--transition-fast);
    width: 100%;
}

.card:hover {
    border-color: rgba(223, 56, 127, 0.45);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── GRID SYSTEM DE 4 CARDS (OCUPA 100% DA LARGURA) ─────────────────────── */
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; width: 100%; }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; width: 100%; }
.grid-cols-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; width: 100%; }

@media (max-width: 1400px) {
    .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .split-layout { flex-direction: column; }
    .split-form { width: 100%; }
}

@media (max-width: 650px) {
    .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
    .app-sidebar { width: 74px; }
    .sidebar-header .brand-title, .brand-tag, .nav-item span:nth-child(2), .dev-branding-card p { display: none !important; }
    .app-header, .app-main-content { margin-left: 74px; width: calc(100% - 74px); }
}

/* ── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid var(--card-border);
}
.btn-secondary:hover { 
    background: rgba(223, 56, 127, 0.15); 
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-success {
    background: var(--success);
    color: #ffffff;
}
.btn-success:hover { opacity: 0.9; }

/* ── FORMS & INPUTS ─────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: #000000;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ── ALERTS & BADGES ────────────────────────────────────────────────────── */
.alert-banner {
    background: var(--danger-bg);
    border: 2px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }

/* ── TABLES ─────────────────────────────────────────────────────────────── */
.table-responsive { width: 100%; overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th, .table td {
    padding: 14px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

.table th {
    background: #050609;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
}

.table tr:hover td { background: rgba(223, 56, 127, 0.05); }

/* ── TOAST NOTIFICATION ──────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--primary);
    color: #ffffff;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}
