/**
 * ===================================================================
 * MARVIA SYSTEM - GLOBAL DESIGN SYSTEM & UI/UX STANDARDIZATION
 * ===================================================================
 * Versão: 7.0 - Premium SaaS (Stripe/Linear Style)
 */

:root {
    /* 🎨 Core Colors */
    --color-primary: #3b82f6;
    --color-primary-glow: rgba(59, 130, 246, 0.35);
    --color-success: #22c55e;
    --color-warning: #eab308;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    --color-accent: #a855f7;
    --color-pink: #ec4899;
    
    /* 🌑 Dark Mode Surface Palette */
    --bg-main: #0a0e16;
    --bg-sidebar: #05070a;
    --bg-card: #0d1117;
    --bg-input: #161b22;
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-bright: rgba(255, 255, 255, 0.1);
    
    /* ✍️ Typography Scale (SaaS Professional) */
    --font-display: 'Arial', sans-serif;
    --font-body: 'Arial', sans-serif;
    --font-mono: 'Arial', monospace;
    
    --fs-h1: 26px;
    --fs-h2: 22px;
    --fs-h3: 18px;
    --fs-body: 16px;
    --fs-small: 14px;
    --fs-label: 12px;
    --fs-kpi: 36px;
    
    /* 📑 Text Colors */
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681; /* Melhorado para legibilidade */
    
    /* 📏 Sizing & Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* ✨ Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
    font-size: var(--fs-body) !important;
    line-height: 1.6 !important;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, .h1 { font-size: var(--fs-h1) !important; }
h2, .h2, .title-display { font-size: var(--fs-h2) !important; }
h3, .h3 { font-size: var(--fs-h3) !important; }

h1, h2, h3, .h1, .h2, .h3, .title-display {
    font-family: var(--font-display) !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    color: #fff;
    line-height: 1.2 !important;
}

/* 📦 Layout Structure - THE FIX FOR "CUT OFF" LAYOUT */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-main);
    position: relative;
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.03) 0px, transparent 50%);
}

.content {
    padding: 32px 40px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    flex: 1;
    animation: fadeIn 0.4s ease-out;
}

/* 🌑 Sidebar Refinement */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-subtle) !important;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
}

.sidebar-logo {
    padding: 32px 24px;
    margin-bottom: 8px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 24px;
}

.nav-label {
    padding: 0 24px;
    font-family: var(--font-display);
    font-size: var(--fs-label);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    opacity: 0.8;
    margin-bottom: 12px;
}

.nav-link, .nav-item {
    border-radius: var(--radius-md) !important;
    margin: 4px 16px !important;
    padding: 12px 16px !important;
    color: var(--text-secondary) !important;
    font-weight: 600 !important;
    font-size: var(--fs-small) !important;
    transition: var(--transition) !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    text-decoration: none !important;
    cursor: pointer;
}

.nav-link i, .nav-item i {
    font-size: 18px !important;
    width: 24px !important;
    text-align: center !important;
    opacity: 0.7;
}

.nav-link:hover, .nav-item:hover {
    background: rgba(255, 255, 255, 0.03) !important;
    color: #ffffff !important;
}

.nav-link.active, .nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.12) 0%, transparent 100%) !important;
    border-left: 3px solid var(--color-info) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
}

.nav-link.active i, .nav-item.active i {
    color: var(--color-primary);
    opacity: 1;
}

/* 💬 Modern Chat UI (Premium SaaS) */
.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.chat-bubble.out {
    background: var(--color-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.chat-bubble.in {
    background: var(--bg-input);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.chat-media-preview {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 300px;
    cursor: pointer;
}

.chat-media-preview img, .chat-media-preview video {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.chat-file-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
}

.chat-file-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

/* 🏔️ Topbar / Header */
.topbar {
    height: 72px;
    min-height: 72px;
    background: rgba(10, 14, 22, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: flex;
    }
}

/* 🚀 Premium Card Base */
.saas-card, .stat-card-modern, .details-card, .form-card, .lead-card-kanban {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-lg) !important;
    padding: 20px !important;
    transition: var(--transition) !important;
    box-shadow: var(--shadow-md) !important;
    position: relative;
    overflow: hidden;
}

.lead-card-kanban {
    padding: 24px !important;
    cursor: grab;
}

.lead-card-kanban:hover {
    border-color: var(--color-primary) !important;
    transform: translateY(-4px) !important;
    box-shadow: var(--shadow-lg) !important;
}

.lead-card-kanban .card-title, .lead-card-kanban [style*="font-weight: 800"] {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #fff !important;
    margin-bottom: 12px !important;
}

.lead-card-kanban [style*="font-size: 11px"], .lead-card-kanban .card-meta {
    font-size: 14px !important;
    color: var(--text-secondary) !important;
}

.lead-card-kanban .card-score {
    font-size: 18px !important;
    font-weight: 800 !important;
}

/* 📊 Stats Grid & KPIs */
.stats-grid-modern, .saas-stats-grid, .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 24px !important;
    margin-bottom: 32px !important;
}

.kpi-card-premium, .stat-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.kpi-value, .stat-value, .kpi-val {
    font-family: var(--font-display) !important;
    font-size: var(--fs-kpi) !important;
    font-weight: 800 !important;
    color: #fff !important;
    line-height: 1 !important;
}

.kpi-label, .stat-label {
    font-size: var(--fs-small) !important;
    color: var(--text-secondary) !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ⌨️ Forms & Inputs */
input, select, textarea, .form-input, .form-select, .topbar-search input {
    width: 100%;
    background: var(--bg-input) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-md) !important;
    padding: 14px 18px !important;
    color: #fff !important;
    font-family: var(--font-body) !important;
    font-size: 15px !important;
    min-height: 48px !important;
    transition: var(--transition) !important;
}

input::placeholder {
    color: var(--text-muted) !important;
    opacity: 1;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-primary) !important;
    outline: none !important;
    box-shadow: 0 0 0 4px var(--color-primary-glow) !important;
}

/* 🚀 Buttons */
.btn-primary-glow, .btn-premium, .btn-blue, .btn {
    background: var(--color-primary) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--radius-md) !important;
    padding: 12px 24px !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    min-height: 44px !important;
    cursor: pointer !important;
    transition: var(--transition) !important;
    box-shadow: 0 4px 14px var(--color-primary-glow) !important;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.btn-primary-glow:hover, .btn-blue:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px var(--color-primary-glow) !important;
    filter: brightness(1.1);
}

.btn-secondary-glass, .btn-outline {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.btn-secondary-glass:hover, .btn-outline:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--border-bright) !important;
}

/* 🏷️ Badges */
.badge, .card-temp-pill, .status-pill {
    border-radius: var(--radius-sm) !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border: 1px solid transparent !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.badge-info, .badge-primary { background: rgba(59, 130, 246, 0.15) !important; color: #60a5fa !important; border-color: rgba(59, 130, 246, 0.3) !important; }
.badge-success { background: rgba(34, 197, 92, 0.15) !important; color: #4ade80 !important; border-color: rgba(34, 197, 92, 0.3) !important; }
.badge-danger { background: rgba(239, 68, 68, 0.15) !important; color: #f87171 !important; border-color: rgba(239, 68, 68, 0.3) !important; }

/* 📋 Tables & Lists */
table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
    margin-top: -8px !important;
}

th {
    padding: 16px 24px !important;
    text-align: left !important;
    font-size: var(--fs-small) !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
}

td {
    padding: 20px 24px !important;
    background: var(--bg-card) !important;
    font-size: 15px !important;
    color: var(--text-primary) !important;
    border-top: 1px solid var(--border-subtle) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
}

td:first-child {
    border-left: 1px solid var(--border-subtle) !important;
    border-top-left-radius: var(--radius-md) !important;
    border-bottom-left-radius: var(--radius-md) !important;
}

td:last-child {
    border-right: 1px solid var(--border-subtle) !important;
    border-top-right-radius: var(--radius-md) !important;
    border-bottom-right-radius: var(--radius-md) !important;
}

tr:hover td {
    background: var(--bg-input) !important;
    border-color: var(--border-bright) !important;
}

/* 📱 Responsive Grid Utilities */
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

@media (max-width: 1024px) {
    .grid-2-1, .grid-1-2, .grid-1-1 {
        grid-template-columns: 1fr !important;
    }
}

/* 📱 Responsive Adjustments */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        width: 100vw;
    }

    .content {
        padding: 24px;
    }

    .topbar {
        padding: 0 20px;
    }

    .hide-mobile {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0 16px;
    }

    .content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* 🌀 Micro-animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

/* overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    transition: var(--transition);
}

.sidebar-overlay.active {
    display: block;
}

.loading-overlay-global {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 22, 0.9);
    backdrop-filter: blur(12px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay-global.active {
    opacity: 1;
    pointer-events: all;
}

/* 📭 Empty States & Fallbacks */
.empty-state-premium {
    text-align: center;
    padding: 60px 24px;
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    margin: 20px 0;
}

.empty-state-premium i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 20px;
    display: block;
}

.empty-state-premium h3 {
    font-size: 18px;
    color: #fff;
    margin-bottom: 8px;
}

.empty-state-premium p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 300px;
    margin: 0 auto;
}

/* 🚨 Error Boundaries */
.error-state-premium {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    color: #fca5a5;
}

.error-state-premium i {
    font-size: 40px;
    margin-bottom: 16px;
}

/* 🚄 Skeleton Overrides */
.skeleton-premium {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
