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

:root {
    --font-primary: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Premium Color Palette (Corporate Blue & Ice theme) */
    --color-primary: #1a56db;
    --color-primary-rgb: 26, 86, 219;
    --color-primary-hover: #1e429f;
    --color-secondary: #e5edff;
    --color-secondary-text: #1a56db;
    
    --color-bg: #f8fafc;
    --color-card: #ffffff;
    --color-border: #f1f5f9; /* low contrast */
    
    --color-text-main: #0f172a;
    --color-text-muted: #64748b;
    --color-text-white: #ffffff;
    
    /* Status Colors */
    --status-em-criacao: #3b82f6;
    --status-aguardando-gestor: #d97706;
    --status-com-diretor: #f97316;
    --status-devolvida: #8b5cf6;
    --status-pdf-gerado: #10b981;
    --status-aguardando-pedido: #059669;
    --status-finalizada: #06b6d4;
    --status-faturada: #0f766e;
    --status-perdida: #ef4444;
    --status-expirada: #64748b;
    
    /* Layout Constants */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 6px 20px -4px rgba(26,86,219,0.04), 0 1px 3px rgba(0,0,0,0.01);
    --shadow-lg: 0 12px 30px -10px rgba(0,0,0,0.05), 0 2px 8px -2px rgba(0,0,0,0.02);
    
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Main Layout Grid */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: #0f172a; /* Deep slate corporate look */
    color: var(--color-text-white);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 4px 0 10px rgba(0,0,0,0.05);
    border-right: 1px solid #1e293b;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-collapsed .sidebar {
    width: 76px;
    padding: 24px 10px;
}

.sidebar-brand {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 8px;
    white-space: nowrap;
}

.sidebar-brand span {
    color: #3b82f6; /* Modern Blue brand tag */
}

/* Sidebar Brand mini vs full toggle styling */
.brand-mini {
    display: none;
    color: #3b82f6;
    font-size: 24px;
    font-weight: 800;
    margin: 0 auto;
}

.sidebar-collapsed .brand-full {
    display: none;
}

.sidebar-collapsed .brand-mini {
    display: block;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    color: #94a3b8; /* Muted slate link text */
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
    gap: 0;
}

.sidebar-collapsed .sidebar-text {
    display: none;
}

.sidebar-link:hover, .sidebar-link.active {
    color: var(--color-text-white);
    background-color: #1e293b; /* Dark active/hover tab background */
}

.sidebar-link.active {
    background-color: #1e293b;
    border-left: 3px solid var(--color-primary);
}

.sidebar-collapsed .sidebar-link.active {
    border-left: none;
    background-color: var(--color-primary);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 8px;
    border-top: 1px solid #1e293b;
    transition: padding 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed .sidebar-footer {
    padding: 16px 0;
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.navbar {
    height: 70px;
    background-color: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 20px;
    color: var(--color-text-main);
}

/* Global Go Back Button */
.btn-go-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--color-bg, #f1f5f9);
    color: var(--color-text-main, #334155);
    border: 1px solid var(--color-border, #cbd5e1);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-go-back:hover {
    background-color: var(--color-primary, #1a56db);
    color: #ffffff;
    border-color: var(--color-primary, #1a56db);
    box-shadow: 0 2px 6px rgba(26, 86, 219, 0.2);
}
.btn-go-back svg {
    transition: transform 0.2s ease;
}
.btn-go-back:hover svg {
    transform: translateX(-3px);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    background-color: var(--color-bg);
}

.user-role-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--color-primary);
    color: var(--color-text-white);
}

.content-body {
    padding: 32px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Card layout components */
.card {
    background-color: var(--color-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 24px;
    transition: var(--transition);
}

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

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text-main);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background-color: var(--color-bg);
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--color-primary);
    background-color: var(--color-card);
    box-shadow: 0 0 0 3px rgba(15, 81, 50, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background-color: var(--color-secondary);
    color: var(--color-secondary-text);
}

.btn-secondary:hover {
    background-color: #d2e4c8;
}

.btn-outline {
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text-main);
}

.btn-outline:hover {
    background-color: var(--color-bg);
}

.btn-danger {
    background-color: var(--status-perdida);
    color: var(--color-text-white);
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Table grid styles */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table-premium {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table-premium th {
    background-color: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
}

.table-premium td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.table-premium tbody tr:hover {
    background-color: rgba(15, 81, 50, 0.02);
}

/* Badge tags for status */
.badge-status {
    display: inline-flex;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 50px;
    text-transform: uppercase;
}

.badge-status.em-criacao { background-color: rgba(59, 130, 246, 0.1); color: var(--status-em-criacao); }
.badge-status.aguardando-gestor { background-color: rgba(217, 119, 6, 0.1); color: var(--status-aguardando-gestor); }
.badge-status.com-diretor { background-color: rgba(249, 115, 22, 0.1); color: var(--status-com-diretor); }
.badge-status.devolvida { background-color: rgba(139, 92, 246, 0.1); color: var(--status-devolvida); }
.badge-status.pdf-gerado { background-color: rgba(16, 185, 129, 0.1); color: var(--status-pdf-gerado); }
.badge-status.aguardando-pedido { background-color: rgba(5, 150, 105, 0.1); color: var(--status-aguardando-pedido); }
.badge-status.finalizada { background-color: rgba(6, 182, 212, 0.1); color: var(--status-finalizada); }
.badge-status.faturada { background-color: rgba(15, 118, 110, 0.1); color: var(--status-faturada); }
.badge-status.perdida { background-color: rgba(239, 68, 68, 0.1); color: var(--status-perdida); }
.badge-status.expirada { background-color: rgba(100, 116, 139, 0.12); color: var(--status-expirada); }
.badge-status.recusado { background-color: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-status.aprovado { background-color: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

/* Custom items grid features for representatives */
.item-card-row,
.compact-item-card {
    transition: var(--transition);
}

.item-card-row.recusado,
.compact-item-card.recusado {
    background-color: #fef2f2 !important;
    border-color: #f87171 !important;
    border-left: 5px solid var(--status-perdida) !important;
}

.item-card-row.aprovado,
.compact-item-card.aprovado {
    background-color: rgba(16, 185, 129, 0.03);
    border-left: 4px solid #10b981;
}

.price-below-min {
    border-color: var(--status-perdida) !important;
    background-color: #fff5f5 !important;
    color: #991b1b !important;
}

/* Stepper log styling */
.stepper-list {
    position: relative;
    padding-left: 24px;
    list-style: none;
}

.stepper-list::before {
    content: '';
    position: absolute;
    top: 5px;
    bottom: 5px;
    left: 7px;
    width: 2px;
    background-color: var(--color-border);
}

.stepper-item {
    position: relative;
    margin-bottom: 24px;
}

.stepper-item::before {
    content: '';
    position: absolute;
    top: 5px;
    left: -22px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--color-card);
    border: 2px solid var(--color-primary);
}

.stepper-time {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.stepper-desc {
    font-size: 13px;
}

/* Grid helper utilities */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

@media (max-width: 992px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .totals-table { width: 100%; margin-left: 0; }
}

/* Login/Public View Centered layouts */
.centered-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--color-bg);
    padding: 20px;
}

.auth-card {
    max-width: 420px;
    width: 100%;
    background-color: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
    padding: 40px;
}

.logo-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo-header h1 {
    font-size: 28px;
    color: var(--color-primary);
}

.logo-header span {
    color: var(--color-text-muted);
    font-size: 14px;
}

/* --- Card Hover Elevation Effections --- */
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(26, 86, 219, 0.2);
}

/* --- Bento Grid Layout System --- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.bento-card {
    background-color: var(--color-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    padding: 24px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    min-width: 0; /* CRITICAL: Prevents columns from expanding beyond their flex constraints */
}

.bento-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(26, 86, 219, 0.25);
}

.col-span-1 { grid-column: span 1; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.row-span-1 { grid-row: span 1; }
.row-span-2 { grid-row: span 2; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    width: 100%;
}

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }
    .col-span-2, .col-span-3 {
        grid-column: span 1;
    }
}

@media (max-width: 600px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .kpi-block {
        border-right: none !important;
        border-bottom: 1px solid var(--color-border);
        padding-bottom: 15px;
        padding-right: 0 !important;
    }
    .kpi-block:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }
}

/* --- Progressive Disclosure Sheet Drawers --- */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sheet-overlay.open,
.sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.sheet-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 100%;
    height: 100%;
    background-color: var(--color-card);
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.08);
    z-index: 1050;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 32px;
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sheet-drawer.open,
.sheet-drawer.active {
    transform: translateX(0);
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.sheet-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: var(--transition);
    font-size: 20px;
    font-weight: 500;
}

.sheet-close-btn:hover {
    color: var(--color-text-main);
}

/* --- Support Native OS-based Dark Mode (Advanced Graphite Theme) --- */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0b0f19;
        --color-card: #111827;
        --color-border: #1f2937;
        
        --color-text-main: #f8fafc;
        --color-text-muted: #94a3b8;
        
        --color-secondary: #1e293b;
        --color-secondary-text: #60a5fa;
        
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
        --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 2px 8px -2px rgba(0, 0, 0, 0.2);
    }
    
    body {
        background-color: var(--color-bg);
        color: var(--color-text-main);
    }
    
    .navbar {
        background-color: var(--color-card);
        border-bottom-color: var(--color-border);
    }
    
    .sidebar {
        background-color: #030712;
        border-right: 1px solid var(--color-border);
    }
    
    .user-profile-badge {
        background-color: #1e293b;
    }
    
    .form-control, select, textarea {
        background-color: #1e293b;
        border-color: #334155;
        color: var(--color-text-main);
    }
    
    .form-control:focus, select:focus, textarea:focus {
        border-color: var(--color-primary);
        background-color: #111827;
    }
    
    .table-premium th {
        background-color: #1e293b;
        color: var(--color-text-muted);
    }
    
    .table-premium td {
        border-bottom-color: var(--color-border);
    }
    
    .table-premium tr:hover {
        background-color: rgba(255, 255, 255, 0.02) !important;
    }
    
    ::placeholder {
        color: #64748b !important;
    }
    
    /* Scrollbar */
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    ::-webkit-scrollbar-track {
        background: #0b0f19;
    }
    ::-webkit-scrollbar-thumb {
        background: #1f2937;
        border-radius: 4px;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: #374151;
    }
}

/* --- Mobile Sidebar Overlay and Responsive Adjustments --- */
.sidebar-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1055;
}

@media (max-width: 768px) {
    .sidebar-mobile-backdrop {
        transition: opacity 0.25s ease-in-out;
    }
    
    .sidebar-mobile-open .sidebar-mobile-backdrop {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1060;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        width: 260px !important;
        padding: 24px 16px !important;
        box-shadow: 10px 0 30px rgba(15, 23, 42, 0.15);
    }
    
    .sidebar-brand .brand-full {
        display: inline !important;
    }
    
    .sidebar-brand .brand-mini {
        display: none !important;
    }
    
    .sidebar-text {
        display: inline !important;
    }
    
    .sidebar-link {
        justify-content: flex-start !important;
        padding: 12px 16px !important;
        gap: 12px !important;
    }

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

    .navbar {
        padding: 0 16px;
    }

    .content-body {
        padding: 16px;
    }
    
    .main-wrapper {
        width: 100%;
        overflow-x: hidden;
    }
    
    /* Make sure grid layouts stack vertically on mobile */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* Adjust page headers */
    .navbar .page-title {
        font-size: 15px;
    }
}

@media (max-width: 576px) {
    .user-profile-badge span:first-child {
        display: none; /* Hide name on small screens */
    }
}

