/* ============================================================
   SISTEMA FLEXCORE - Stylesheet Principal
   Variáveis, Layout, Componentes e Dashboard
   ============================================================ */

/* ---- CSS VARIABLES ---- */
:root {
    --primary: #0F62FE;
    --primary-light: #4589FF;
    --primary-dark: #0043CE;
    --accent: #00D4AA;
    --accent-warm: #FF6B35;
    --bg-body: #F4F6FA;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFF;
    --bg-sidebar: #0A1628;
    --bg-sidebar-hover: #132240;
    --bg-hero: linear-gradient(135deg, #0A1628 0%, #0F2847 40%, #0D3B66 100%);
    --text-primary: #1A2138;
    --text-secondary: #5A6B8A;
    --text-muted: #8E99B0;
    --text-on-dark: #E8ECF4;
    --text-on-dark-muted: #8E99B0;
    --border: #E2E8F0;
    --border-light: #F0F3F8;
    --shadow-sm: 0 1px 3px rgba(10,22,40,0.06);
    --shadow-md: 0 4px 16px rgba(10,22,40,0.08);
    --shadow-lg: 0 8px 32px rgba(10,22,40,0.12);
    --shadow-xl: 0 16px 48px rgba(10,22,40,0.16);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-heading: 'Sora', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

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

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ---- NAV LOGO ---- */
.nav-logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading);
    font-weight: 800; font-size: 1.1rem; color: #fff;
}

/* ---- DASHBOARD LAYOUT ---- */
.dash-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.dash-layout.sidebar-collapsed {
    grid-template-columns: 64px 1fr;
}

/* ---- SIDEBAR 3.0 ---- */
.dash-sidebar {
    background: var(--sb-bg, #0C1525);
    padding: 20px 0 0;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto; overflow-x: hidden;
    width: 260px;
    z-index: 50;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.dash-sidebar.collapsed { width: 64px; }

/* Brand */
.dash-sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px; margin-bottom: 4px;
    position: relative; min-height: 36px;
}

/* Collapse button */
#sidebarCollapseBtn {
    display: none;
    position: absolute; right: -13px; top: 50%; transform: translateY(-50%);
    width: 26px; height: 26px; border-radius: 50%;
    background: #1a2d45;
    border: 1.5px solid rgba(255,255,255,0.10);
    color: #5e7491;
    cursor: pointer; font-size: 0.6rem;
    align-items: center; justify-content: center;
    transition: background .2s, color .2s, border-color .2s; z-index: 10;
    flex-shrink: 0;
}
#sidebarCollapseBtn:hover { background: var(--sb-accent, #00D4AA); color: #fff; border-color: var(--sb-accent, #00D4AA); }
#sidebarCollapseBtn i { transition: transform 0.3s ease; }
.dash-sidebar.collapsed #sidebarCollapseBtn i { transform: rotate(180deg); }

/* Favoritos: override de margin-left para classes antigas que ainda existam */
.fav-add-btn {
    margin-left: auto; background: none; border: none;
    color: #4d6480; cursor: pointer;
    opacity: 0; transition: opacity .15s;
    font-size: 0.68rem; padding: 2px 4px; line-height: 1; flex-shrink: 0;
}
.fav-add-btn:hover { opacity: 1 !important; }
.fav-add-btn.favoritado { opacity: 1 !important; color: #f59e0b; }
.fav-remove-btn {
    background: none; border: none; color: #4d6480; cursor: pointer;
    opacity: 0; transition: opacity .15s; font-size: 0.68rem;
    padding: 2px 4px; line-height: 1; flex-shrink: 0;
}
.fav-remove-btn:hover { opacity: 1 !important; color: #f43f5e; }
.dash-sidebar.collapsed .fav-add-btn,
.dash-sidebar.collapsed .fav-remove-btn { display: none; }

/* ---- MAIN CONTENT ---- */
.dash-main { padding: 28px 32px; overflow-y: auto; }

.dash-topbar {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 32px;
}
.dash-topbar h1 {
    font-family: var(--font-heading);
    font-size: 1.6rem; font-weight: 700;
}

.dash-user-badge {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 8px 16px; border-radius: var(--radius-sm);
}
.dash-user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.8rem;
}
.dash-user-info span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.dash-user-info small { font-size: 0.7rem; color: var(--text-muted); }

/* ---- KPI CARDS ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px; margin-bottom: 32px;
}
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 24px;
    transition: var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.kpi-change {
    font-family: var(--font-mono); font-size: 0.75rem;
    font-weight: 600; padding: 3px 8px; border-radius: 50px;
}
.kpi-change.up { background: rgba(0,212,170,0.1); color: #00D4AA; }
.kpi-change.down { background: rgba(255,107,53,0.1); color: #FF6B35; }

.kpi-value {
    font-family: var(--font-heading); font-size: 1.75rem;
    font-weight: 800; color: var(--text-primary); margin-bottom: 4px;
}
.kpi-label { font-size: 0.85rem; color: var(--text-secondary); }

/* ---- SUMMARY CARDS ---- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; margin-bottom: 32px;
}
.summary-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 24px;
    display: flex; align-items: center; gap: 20px;
    transition: var(--transition);
}
.summary-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.summary-card .summary-icon {
    width: 56px; height: 56px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.summary-card .summary-info { flex: 1; }
.summary-card .summary-value {
    font-family: var(--font-heading); font-size: 1.35rem;
    font-weight: 800; color: var(--text-primary);
}
.summary-card .summary-label {
    font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px;
}

/* ---- QUICK ACCESS CARDS ---- */
.quick-access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.quick-access-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 20px 16px;
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; text-decoration: none;
    transition: var(--transition); cursor: pointer;
    text-align: center;
}
.quick-access-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.quick-access-card .qa-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
}
.quick-access-card .qa-label {
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
}
.quick-access-card .qa-count {
    font-family: var(--font-mono); font-size: 0.72rem;
    color: var(--text-muted); margin-top: -4px;
}

/* ---- MODULE CARDS ---- */
.dash-section-title {
    font-family: var(--font-heading); font-size: 1.15rem;
    font-weight: 700; color: var(--text-primary);
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px;
}
.dash-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.dash-modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px; margin-bottom: 32px;
}
.dash-module-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 24px;
    display: flex; align-items: flex-start; gap: 16px;
    transition: var(--transition); cursor: pointer;
}
.dash-module-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.dash-module-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.dash-module-info h3 {
    font-family: var(--font-heading); font-size: 1rem;
    font-weight: 700; color: var(--text-primary); margin-bottom: 4px;
}
.dash-module-info p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }

.dash-module-status {
    margin-top: 8px; font-family: var(--font-mono);
    font-size: 0.7rem; font-weight: 600;
    padding: 3px 10px; border-radius: 50px; display: inline-block;
}
.status-active { background: rgba(0,212,170,0.1); color: #00D4AA; }
.status-dev { background: rgba(245,166,35,0.1); color: #F5A623; }

/* ---- FORM ELEMENTS ---- */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 0.85rem;
    font-weight: 600; color: var(--text-primary); margin-bottom: 6px;
}
.form-input {
    width: 100%; padding: 12px 16px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-body); color: var(--text-primary);
    font-family: var(--font-body); font-size: 16px;
    transition: var(--transition); outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,98,254,0.12); }
.form-input.error { border-color: #EF4444; }
.form-error { color: #EF4444; font-size: 0.8rem; margin-top: 6px; display: none; }
.form-error.show { display: block; }

/* ---- TOASTS ---- */
.toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 300;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 20px;
    box-shadow: var(--shadow-lg); display: flex; align-items: center;
    gap: 10px; font-size: 0.9rem; font-weight: 500;
    animation: fadeInUp 0.3s ease; min-width: 260px;
}
.toast.success { border-left: 4px solid var(--accent); }
.toast.error { border-left: 4px solid #EF4444; }
.toast.info { border-left: 4px solid var(--primary); }
.toast.warning { border-left: 4px solid #F5A623; }

/* ---- CUSTOM MODAL ---- */
.custom-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(10,15,26,0.6); backdrop-filter: blur(6px);
    z-index: 250; align-items: center; justify-content: center; padding: 20px;
}
.custom-modal-overlay.active { display: flex; }
.custom-modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px;
    max-width: 400px; width: 100%; box-shadow: var(--shadow-xl);
    text-align: center; animation: fadeInUp 0.3s ease;
}
.custom-modal h3 {
    font-family: var(--font-heading); font-size: 1.1rem;
    font-weight: 700; margin-bottom: 10px; color: var(--text-primary);
}
.custom-modal p {
    font-size: 0.9rem; color: var(--text-secondary);
    margin-bottom: 24px; line-height: 1.6;
}
.custom-modal-actions { display: flex; gap: 12px; justify-content: center; }

.modal-btn {
    padding: 10px 24px; border-radius: var(--radius-sm);
    font-family: var(--font-body); font-size: 0.9rem;
    font-weight: 600; border: none; cursor: pointer; transition: var(--transition);
}
.modal-btn-cancel {
    background: var(--bg-body); color: var(--text-secondary);
    border: 1px solid var(--border);
}
.modal-btn-cancel:hover { background: var(--border-light); }
.modal-btn-confirm { background: var(--primary); color: #fff; }
.modal-btn-confirm:hover { background: var(--primary-light); }
.modal-btn-danger { background: #EF4444; color: #fff; }
.modal-btn-danger:hover { background: #DC2626; }

/* ---- MOBILE SIDEBAR ---- */
.mobile-sidebar-toggle {
    display: none; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px;
    font-size: 1.1rem; color: var(--text-primary); cursor: pointer;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 149;
}
.sidebar-overlay.active { display: block; }

/* ---- ANIMATIONS ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    font-size: 0.85rem; margin-bottom: 20px;
}
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: #EF4444; }
.alert-info { background: rgba(15,98,254,0.1); border: 1px solid rgba(15,98,254,0.2); color: var(--primary); }
.alert-success { background: rgba(0,212,170,0.1); border: 1px solid rgba(0,212,170,0.2); color: #00D4AA; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .dash-layout { grid-template-columns: 1fr; }
    .dash-sidebar {
        position: fixed; left: -280px; top: 0; bottom: 0;
        width: 260px; z-index: 150; transition: var(--transition);
    }
    .dash-sidebar.mobile-open { left: 0; }
    .mobile-sidebar-toggle { display: block; }
    .dash-main { padding: 20px 16px; }
    .dash-topbar { flex-wrap: wrap; gap: 12px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .summary-grid { grid-template-columns: 1fr; }
    .quick-access-grid { grid-template-columns: 1fr 1fr; }
    .dash-modules-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .quick-access-grid { grid-template-columns: 1fr 1fr; }
}
