:root {
    /* Paleta Principal - Indigo Premium */
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #e0e7ff;
    
    /* Cores do Menu Lateral (Dark Navy/Slate) */
    --sidebar-bg: #0f172a;
    --sidebar-text: #f8fafc;
    --sidebar-text-muted: #94a3b8;
    --sidebar-hover: #1e293b;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    /* Fundos */
    --bg-main: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-dark: #1f2937;
    
    /* Textos */
    --text-dark: #111827;
    --text-light: #4b5563;
    --text-muted: #9ca3af;
    
    /* Estados */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Sombras e Bordas Modernas */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.025);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.025);
    --shadow-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --border-color: #e5e7eb;
}

html {
    font-size: 14px; /* Fonte ligeiramente menor e refinada */
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Premium (WebKit & Standard) */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.2) transparent;
}
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}
.sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

/* -----------------------------
   MOBILE FIRST (Padrão)
----------------------------- */

/* Header */
.header {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.3rem;
    text-decoration: none;
    letter-spacing: -0.5px;
}

/* Menu Toggle (Mobile) */
.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-dark);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

/* Sidebar / Menu */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 280px;
    height: 100vh;
    background-color: var(--sidebar-bg);
    box-shadow: 10px 0 30px rgba(0,0,0,0.15);
    transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header .logo {
    color: #ffffff;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--sidebar-text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.sidebar-close:hover {
    color: #ffffff;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.sidebar .nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    stroke-width: 1.75;
}

.sidebar .nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.sidebar-footer {
    padding: 1rem 0.5rem;
    border-top: 1px solid var(--sidebar-border);
}
.sidebar-footer .nav-item {
    color: var(--sidebar-text-muted);
}
.sidebar-footer .nav-item:hover {
    color: var(--sidebar-text);
}

/* Main Content */
.main-content {
    padding: 1.5rem;
    min-height: calc(100vh - 140px); /* descontando header e footer */
}

/* Grid de Cards (Dashboard) */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--bg-main);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 0;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
    letter-spacing: -1px;
}

/* Glassmorphism Classes Extras (opcional para dashboard) */
.glass-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,255,255,0.4));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.5);
}

/* Tabelas adaptadas para Mobile */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    background: var(--bg-main);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0,0,0,0.03);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

th, td {
    padding: 1.25rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: #f9fafb; /* gray-50 */
}

th {
    background-color: #f9fafb;
    color: var(--text-light);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

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

.btn-outline:hover {
    border-color: #d1d5db;
    background-color: #f9fafb;
}

.btn-block {
    display: flex;
    width: 100%;
    box-sizing: border-box;
}

/* Formulários */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db; /* gray-300 */
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 0.95rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: #ffffff;
    color: var(--text-dark);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.form-control::placeholder {
    color: #9ca3af;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Badges / Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px; /* full rounded */
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-success { background-color: #d1fae5; color: #047857; } /* emerald */
.badge-warning { background-color: #fef3c7; color: #b45309; } /* amber */
.badge-primary { background-color: var(--primary-light); color: var(--primary-dark); }
.badge-info { background-color: #dbeafe; color: #1d4ed8; } /* blue */

/* Avatar e Componentes de Perfil */
.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid #ffffff;
    box-shadow: var(--shadow-sm);
}
.avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-lg {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 4px solid #ffffff;
    box-shadow: var(--shadow-md);
    margin: 0 auto;
    position: relative;
    cursor: pointer;
}
.avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-lg:hover::after {
    content: "Alterar";
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
    padding: 0.3rem 0;
}
.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer */
.footer {
    background-color: var(--bg-main);
    color: var(--text-light);
    text-align: center;
    padding: 1.5rem;
    font-size: 0.85rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.footer a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* -----------------------------
   DESKTOP / TABLET UP
----------------------------- */
@media (max-width: 767px) {
    .user-name-hide-mobile {
        display: none;
    }
    .mobile-logo {
        display: block !important;
    }
    .header {
        padding: 0.75rem 1rem;
    }
    .main-content {
        padding: 1rem;
    }
    /* Impedir sobreposição escondendo transbordamentos se a tela for muito fina */
    body {
        overflow-x: hidden;
    }
}

@media (min-width: 768px) {
    .menu-toggle {
        display: none;
    }
    
    .sidebar {
        left: 0;
        width: 260px;
    }
    
    .sidebar-close {
        display: none;
    }

    .header {
        margin-left: 260px;
        padding: 1.2rem 2.5rem;
    }

    .main-content {
        margin-left: 260px;
        padding: 2.5rem;
    }

    .footer {
        margin-left: 260px;
    }

    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .form-row {
        display: flex;
        gap: 1.5rem;
    }
    .form-row .form-group {
        flex: 1;
    }
}

@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* -----------------------------
   AI CHAT DASHBOARD
----------------------------- */
.ai-chat-wrapper {
    max-width: 800px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.ai-chat-header {
    text-align: center;
    margin-bottom: 2rem;
}

.ai-chat-header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.ai-chat-header p {
    color: var(--text-light);
    font-size: 1.1rem;
}

.ai-chat-history {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
    margin-bottom: 1rem;
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.message-bubble {
    padding: 1rem 1.5rem;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.6;
    animation: fadeIn 0.3s ease-in-out;
    box-shadow: var(--shadow-sm);
}

.user-message {
    background-color: var(--bg-main);
    color: var(--text-dark);
    align-self: flex-end;
    border: 1px solid rgba(0,0,0,0.05);
    border-bottom-right-radius: 4px;
}

.ai-message {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    align-self: flex-start;
    border: 1px solid rgba(79, 70, 229, 0.1);
    border-bottom-left-radius: 4px;
}

.ai-chat-input-container {
    background: var(--bg-main);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    position: relative;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.ai-chat-input-container:focus-within {
    box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.15);
    border-color: var(--primary);
}

.ai-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#aiPromptInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 0;
    font-size: 1.05rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-dark);
    resize: none;
    outline: none;
    max-height: 150px;
    min-height: 24px;
    line-height: 1.5;
}

.ai-send-btn {
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: not-allowed;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-send-btn.active {
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.ai-send-btn.active:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.ai-chat-suggestions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ai-suggestion-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.ai-suggestion-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #ffffff;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.5rem;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
