/* ============================================
   GLOBAL STYLES - FreeLab Platform
   ============================================ */

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

:root {
    /* Colors */
    --bg-primary: #0F1115;
    --bg-secondary: #1A1D23;
    --bg-tertiary: #25282F;
    --bg-card: #1E2128;
    --text-primary: #FFFFFF;
    --text-secondary: #B4B4B4;
    --text-tertiary: #7A7A7A;
    --text-muted: #7A7A7A;
    
    /* Gradient - Enhanced */
    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 50%, #06b6d4 100%);
    --gradient-hover: linear-gradient(135deg, #9d6fff 0%, #4c8fff 50%, #17c5e0 100%);
    
    /* Accent Colors */
    --accent-primary: #8b5cf6;
    --accent-secondary: #3b82f6;
    --accent-tertiary: #06b6d4;
    --accent-green: #a4f44f;
    
    /* Status Colors */
    --success: #22C55E;
    --error: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-full: 9999px;
    
    /* Shadows - Enhanced */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.3);
    --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.3);
    --shadow-glow-lg: 0 0 48px rgba(139, 92, 246, 0.4);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-modal: 2000;
    --z-tooltip: 3000;
    --z-notification: 4000;

    /*
     * Tipografia (base 16px — escala ~1.25, alinhada a boas práticas de legibilidade)
     * Corpo: mín. 16px; line-height ≥ 1,5 em texto corrido (WCAG orientativo).
     */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;

    --font-size-xs: 0.75rem;      /* 12px */
    --font-size-sm: 0.875rem;    /* 14px */
    --font-size-base: 1rem;      /* 16px */
    --font-size-md: 1.125rem;    /* 18px */
    --font-size-lg: 1.25rem;     /* 20px */
    --font-size-xl: 1.5rem;      /* 24px */
    --font-size-2xl: 1.875rem;   /* 30px */
    --font-size-3xl: 2.25rem;    /* 36px */
    --font-size-4xl: 2.5rem;     /* 40px */

    --line-height-tight: 1.25;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;

    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --letter-spacing-tight: -0.02em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.02em;
    --letter-spacing-label: 0.06em; /* rótulos em caps */

    /* ── Aliases de compatibilidade (evitam variáveis undefined em páginas legadas) ── */
    --primary:       #8b5cf6;
    --border:        rgba(255, 255, 255, 0.1);
    --border-color:  rgba(255, 255, 255, 0.08);
    --card-bg:       #1E2128;
    --text:          #FFFFFF;

    /*
     * Altura de viewport útil em smartphones (barras do browser / áreas seguras).
     * Usar var(--fl-screen) no CSS; frações: calc(var(--fl-screen) * N / 100).
     */
    --fl-screen: 100vh;
}

@supports (height: 100dvh) {
    :root {
        --fl-screen: 100dvh;
    }
}

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-relaxed);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    margin-bottom: var(--spacing-md);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

p {
    margin-bottom: var(--spacing-md);
    font-size: inherit;
    line-height: var(--line-height-relaxed);
}

small,
.text-small {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
}

.text-xs { font-size: var(--font-size-xs); line-height: var(--line-height-normal); }
.text-sm { font-size: var(--font-size-sm); line-height: var(--line-height-normal); }
.text-base { font-size: var(--font-size-base); line-height: var(--line-height-relaxed); }
.text-md { font-size: var(--font-size-md); line-height: var(--line-height-relaxed); }
.text-lg { font-size: var(--font-size-lg); line-height: var(--line-height-snug); }
.text-xl { font-size: var(--font-size-xl); line-height: var(--line-height-snug); }
.text-2xl { font-size: var(--font-size-2xl); line-height: var(--line-height-tight); }
.text-3xl { font-size: var(--font-size-3xl); line-height: var(--line-height-tight); }
.text-4xl { font-size: var(--font-size-4xl); line-height: var(--line-height-tight); }

.lead {
    font-size: var(--font-size-md);
    line-height: var(--line-height-relaxed);
    color: var(--text-secondary);
}

.text-caption,
.caption {
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--text-tertiary);
}

.text-overline {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: var(--letter-spacing-label);
    text-transform: uppercase;
    line-height: var(--line-height-normal);
    color: var(--text-tertiary);
}

.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

a:hover {
    opacity: 0.8;
}

/* Gradient Text */
.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientFlow 3s ease infinite;
    background-size: 200% auto;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    cursor: pointer;
    transition: all var(--transition-base);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    position: relative;
}

.btn > * {
    position: relative;
    z-index: 2;
}

.btn-primary {
    background: var(--gradient-primary);
    background-size: 200% auto;
    color: var(--text-primary);
    width: 100%;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    background-position: right center;
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-glow), var(--shadow-xl);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--bg-tertiary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-outline {
    background: transparent;
    border: 2px solid transparent;
    background-image: var(--gradient-primary);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

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

.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    position: relative; /* Para posicionar o badge */
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.42);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.btn-icon:hover {
    background: rgba(30, 41, 59, 0.75);
    border-color: rgba(167, 139, 250, 0.45);
}

.btn-icon:focus-visible {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   HEADER
   ============================================ */

.app-header {
    background: rgba(24, 24, 27, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: var(--spacing-md) var(--spacing-xl);
    /* Safe area top: notch / status bar no iOS e Android edge-to-edge */
    padding-top: calc(var(--spacing-md) + env(safe-area-inset-top, 0px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xl);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    flex: 1;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.menu-toggle {
    display: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0 5px;
    border: 2px solid #0f1115;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    z-index: 10;
}

/* Botão de notificações com cursor pointer */
#notificationsBtn {
    background: linear-gradient(145deg, rgba(17, 24, 39, 0.92), rgba(15, 23, 42, 0.86));
    border-color: rgba(148, 163, 184, 0.28);
}

#notificationsBtn:hover {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.96), rgba(17, 24, 39, 0.92));
    border-color: rgba(167, 139, 250, 0.58);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.35);
    transform: translateY(-1px);
}

#notificationsBtn:active {
    transform: translateY(0) scale(0.97);
}

@keyframes notification-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

/* User Avatar in Header */
.user-profile-mini {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-avatar-mini {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255, 255, 255, 0.1);
    object-fit: cover;
}

/* Marca central (mobile app shell — visível só ≤768px) */
.app-header__center {
    display: none;
}

/* Responsive Header */
@media (max-width: 768px) {
    .app-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 10px;
        padding: var(--spacing-sm) var(--spacing-md);
        /* Safe area iOS (notch + Dynamic Island) */
        padding-top: calc(var(--spacing-sm) + env(safe-area-inset-top, 0px));
    }

    .header-left {
        grid-column: 1;
        min-width: 0;
        flex: unset;
        justify-self: start;
    }

    .app-header__center {
        display: flex;
        justify-content: center;
        align-items: center;
        grid-column: 2;
        justify-self: center;
        padding: 4px 8px;
        border-radius: 14px;
        opacity: 0.95;
        transition: opacity 0.15s ease, transform 0.15s ease;
    }

    .app-header__center:active {
        transform: scale(0.96);
        opacity: 0.85;
    }

    .app-header__center img {
        display: block;
        width: 32px;
        height: 32px;
    }

    /* Home: logo com nome (só esta página — injetado em fab.js) */
    .app-header__center--home img {
        width: auto;
        height: 26px;
        max-width: min(152px, 40vw);
        object-fit: contain;
        object-position: center;
    }

    .header-actions {
        grid-column: 3;
        justify-self: end;
        flex-shrink: 0;
    }

    .header-title {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 1.1rem;
    }

    .header-actions .btn-text {
        display: none;
    }

    .header-actions .btn {
        padding: 8px 10px;
        min-width: 40px;
    }

    /* Hide nav shortcuts & action buttons from header — bottom nav + page CTAs handle them */
    .header-actions #programasBtn,
    .header-actions #criarAnuncioBtn {
        display: none !important;
    }

    .menu-toggle {
        display: flex;
        flex-shrink: 0;
    }

    #notificationsBtn,
    .header-actions .btn-icon {
        width: 44px;
        height: 44px;
    }

    .notification-badge {
        top: -3px;
        right: -3px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: var(--spacing-sm) 16px;
        padding-top: calc(var(--spacing-sm) + env(safe-area-inset-top, 0px));
    }

    .header-title {
        font-size: 1.25rem;
    }

    .user-profile-mini span {
        display: none;
    }
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
    margin-bottom: var(--spacing-lg);
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-base);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #D946EF;
    box-shadow: 0 0 0 3px rgba(217, 70, 239, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.error-message {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 12px;
    color: var(--error);
}

.char-counter {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: right;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.05) 0%, 
        rgba(59, 130, 246, 0.05) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    transform: translateY(-6px) scale(1.01);
    box-shadow: var(--shadow-2xl);
    border-color: rgba(139, 92, 246, 0.2);
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.08) 0%, 
        rgba(59, 130, 246, 0.08) 100%);
}

.card-header {
    margin-bottom: var(--spacing-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.card-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

.card-footer {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--bg-tertiary);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    animation: fadeIn var(--transition-base);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    max-height: calc(var(--fl-screen) * 90 / 100);
    overflow-y: auto;
    animation: slideUp var(--transition-base);
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
}

.modal-header h2 {
    margin: 0;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0;
    cursor: pointer;
    padding: 0;
    /* Touch target mínimo 44×44px (Apple HIG / WCAG 2.5.5) */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
    margin: -6px -6px -6px auto;
}

.close-modal svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.close-modal:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 29, 33, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: #D946EF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--spacing-sm);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--spacing-md);
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
}

/* ============================================
   BADGES & TAGS
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.badge-gradient {
    background: var(--gradient-primary);
    color: var(--text-primary);
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-lg);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
}

.empty-state-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* ============================================
   NOTIFICATIONS/TOASTS
   ============================================ */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-notification);
    animation: slideInRight var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    max-width: 400px;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-clickable:hover {
    filter: brightness(1.1);
}

.toast-cta {
    margin-left: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary, #a855f7);
    white-space: nowrap;
    opacity: .85;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@keyframes gradientFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmerEffect {
    0% { 
        background-position: -1000px 0; 
    }
    100% { 
        background-position: 1000px 0; 
    }
}

/* ============================================
   UTILITIES
   ============================================ */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.text-center {
    text-align: center;
}

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

.text-tertiary {
    color: var(--text-tertiary);
}

.hidden {
    display: none !important;
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: #4A4D53;
}

/* ============================================
   SIDEBAR - MODERN FIXED LAYOUT
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: var(--fl-screen);
    background: #16181D;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-logo {
    margin-bottom: 40px;
    padding: 0 12px;
}

.sidebar-logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.logo span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
    position: relative;
    white-space: nowrap;
    text-decoration: none;
    margin-bottom: 4px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.1);
}

.nav-item.active {
    color: var(--text-primary);
    background: linear-gradient(90deg, 
        rgba(139, 92, 246, 0.15) 0%, 
        rgba(59, 130, 246, 0.1) 100%);
    font-weight: 600;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}

/* ============================================
   MAIN CONTENT LAYOUT
   ============================================ */

.main-content {
    margin-left: 260px;
    min-height: var(--fl-screen);
    padding: 32px 40px;
    background: var(--bg-primary);
}

/* ============================================
   HEADER FLOATING
   ============================================ */

.header-floating {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.08) 0%, 
        rgba(59, 130, 246, 0.08) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-xl);
    padding: 20px 32px;
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 24px;
    z-index: 90;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    cursor: pointer;
}

.user-profile-mini:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

.user-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* ============================================
   MODAL MODERN
   ============================================ */

.modal-modern {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-modal);
    animation: fadeIn var(--transition-base);
    padding: 24px;
    overflow-y: auto;
}

.modal-modern.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content-modern {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.08) 0%, 
        rgba(59, 130, 246, 0.08) 100%);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-2xl);
    padding: 32px;
    max-width: 600px;
    width: 100%;
    max-height: calc(var(--fl-screen) * 90 / 100);
    overflow-y: auto;
    animation: scaleIn var(--transition-base);
    position: relative;
    box-shadow: var(--shadow-2xl);
}

.modal-header-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header-modern h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.modal-close-modern {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    font-size: 0;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.modal-close-modern svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.modal-close-modern:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-body-modern {
    margin-bottom: 24px;
}

.modal-footer-modern {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ============================================
   FORM MODERN
   ============================================ */

.form-group-modern {
    margin-bottom: 20px;
}

.form-group-modern label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-modern {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    transition: all var(--transition-base);
}

select.input-modern {
    background-color: #1e293b;
    color: #f1f5f9;
    cursor: pointer;
}

select.input-modern option {
    background-color: #1e293b;
    color: #f1f5f9;
}

select.input-modern option:checked,
select.input-modern option:hover {
    background-color: #334155;
    color: #f1f5f9;
}

.input-modern::placeholder {
    color: var(--text-tertiary);
}

.input-modern:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

select.input-modern:focus {
    background-color: #1e293b;
}

/* ============================================
   EMPTY STATE MODERN
   ============================================ */

.empty-state-modern {
    text-align: center;
    padding: 48px 24px;
}

.empty-icon-modern {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.6;
    animation: float 3s ease-in-out infinite;
}

.empty-state-modern h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.empty-state-modern p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ============================================
   BUTTON SIZES
   ============================================ */

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
}

@media (max-width: 768px) {
    :root {
        --spacing-lg: 16px;
        --spacing-xl: 24px;
        --spacing-2xl: 32px;
        --font-size-4xl: 2rem;
        --font-size-3xl: 1.75rem;
        --font-size-2xl: 1.5rem;
        --font-size-xl: 1.3125rem;
    }
    
    h1 { font-size: var(--font-size-4xl); }
    h2 { font-size: var(--font-size-3xl); }
    h3 { font-size: var(--font-size-2xl); }
    
    /* Sidebar: off-canvas positioning handled by home.css (transform + fixed).
       Do not reset position here — it breaks the slide-in drawer. */
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .header-floating {
        padding: 16px 20px;
        top: 16px;
        margin-bottom: 24px;
    }
    
    .page-title {
        font-size: var(--font-size-lg);
    }
    
    .modal-content,
    .modal-content-modern {
        padding: var(--spacing-lg);
        max-width: 95%;
        border-radius: var(--radius-lg);
    }
    
    .toast {
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }
}

/* ============================================
   UTILITY ANIMATIONS
   ============================================ */

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-gradient {
    background-size: 200% auto;
    animation: gradientFlow 3s ease infinite;
}

/* ============================================
   ADVANCED UTILITY CLASSES
   ============================================ */

/* Glass Card Enhanced */
.glass-card {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.08) 0%, 
        rgba(59, 130, 246, 0.08) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
}

.glass-card:hover {
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    transform: translateY(-2px);
}

/* Interactive Card */
.interactive-card {
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.interactive-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.interactive-card:active::after {
    width: 300px;
    height: 300px;
}

/* Hover Lift */
.hover-lift {
    transition: all var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* Hover Scale */
.hover-scale {
    transition: transform var(--transition-base);
}

.hover-scale:hover {
    transform: scale(1.02);
}

/* Hover Glow */
.hover-glow {
    transition: all var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow-lg);
}

/* Focus Ring */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.4);
}

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loading-spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* Pulse Ring */
.pulse-ring {
    position: relative;
}

.pulse-ring::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.6;
    transform: translate(-50%, -50%);
    animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Status Dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background: var(--text-tertiary);
}

.status-dot.busy {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.status-dot.away {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

/* Divider */
.divider {
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 100%);
    margin: var(--spacing-lg) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 100%);
    margin: 0 var(--spacing-lg);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent);
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    pointer-events: none;
    z-index: var(--z-tooltip);
}

.tooltip::before {
    content: attr(data-tooltip);
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 13px;
    white-space: nowrap;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.tooltip::after {
    content: '';
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    margin-bottom: 2px;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Scrollbar Enhanced */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #9d6fff 0%, #4c8fff 100%);
}

/* Selection */
::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

/* Text Utilities */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-glow {
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Display Utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* Flex Utilities */
.flex-row { flex-direction: row !important; }
.flex-col { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.justify-start { justify-content: flex-start !important; }
.justify-end { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-around { justify-content: space-around !important; }
.items-start { align-items: flex-start !important; }
.items-end { align-items: flex-end !important; }
.items-center { align-items: center !important; }
.items-baseline { align-items: baseline !important; }
.items-stretch { align-items: stretch !important; }
.flex-1 { flex: 1 !important; }
.flex-auto { flex: auto !important; }

/* Spacing Utilities */
.m-0 { margin: 0 !important; }
.m-auto { margin: auto !important; }
.mt-auto { margin-top: auto !important; }
.mr-auto { margin-right: auto !important; }
.mb-auto { margin-bottom: auto !important; }
.ml-auto { margin-left: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.my-auto { margin-top: auto !important; margin-bottom: auto !important; }

.p-0 { padding: 0 !important; }

/* Width Utilities */
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }
.h-full { height: 100% !important; }
.h-auto { height: auto !important; }
.min-h-screen { min-height: var(--fl-screen) !important; }

/* Position Utilities */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }
.sticky { position: sticky !important; }

/* Overflow Utilities */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }
.overflow-y-auto { overflow-y: auto !important; }

/* Cursor Utilities */
.cursor-pointer { cursor: pointer !important; }
.cursor-not-allowed { cursor: not-allowed !important; }
.cursor-move { cursor: move !important; }

/* Opacity Utilities */
.opacity-0 { opacity: 0 !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-75 { opacity: 0.75 !important; }
.opacity-100 { opacity: 1 !important; }

/* Pointer Events */
.pointer-events-none { pointer-events: none !important; }
.pointer-events-auto { pointer-events: auto !important; }

/* User Select */
.select-none { user-select: none !important; }
.select-all { user-select: all !important; }
.select-text { user-select: text !important; }

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.focus-visible:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ── Todos os FABs flutuantes — sem badges de nenhum tipo ──────────────── */
#chatBtn .notification-badge,
#chatBtn .fab-unread-badge,
#chatBtn .fab-bot-badge,
.floating-chat .notification-badge,
.floating-chat .fab-unread-badge,
.floating-chat .fab-bot-badge {
    display: none !important;
}

/* ── Bot FAB — badge de rótulo (legado — mantido oculto) ────────────────── */
.fab-bot-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: var(--success, #22c55e);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.03em;
    padding: 2px 5px;
    border-radius: 99px;
    border: 2px solid var(--bg-primary, #0d1117);
    pointer-events: none;
    line-height: 1.2;
    text-transform: uppercase;
}

/* ── Bot FAB — badge de não-lidas ───────────────────────────────────────── */
.fab-unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    border-radius: 10px;
    border: 2px solid var(--bg-primary, #0d1117);
    text-align: center;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(239, 68, 68, .5);
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE POLISH — touch targets, typography, modals, overflow
   ══════════════════════════════════════════════════════════════════ */

/* Prevent horizontal scroll on entire app */
html {
    overflow-x: hidden;
}

/* Prevent images and media from causing card/page overflow (SVG omitido — height:auto quebra ícones inline) */
img,
video,
iframe {
    max-width: 100%;
    height: auto;
}

.btn svg,
.btn-icon svg,
.nav-item svg,
.pb-btn-ghost svg,
.pb-back-btn svg {
    max-width: none;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mob-nav-item__icon svg {
    max-width: none;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Grids and flex containers must not overflow their parent */
@media (max-width: 768px) {
    .main-content,
    .content-wrapper,
    .page-header,
    .filters-section,
    .filter-controls {
        max-width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 768px) {
    /* Minimum touch targets (Apple HIG: 44×44pt) */
    .btn,
    button:not(.mob-nav-item):not(.fpc-back-btn),
    [role="button"],
    .nav-item,
    .tab-insta,
    .tab-btn,
    .tab-secondary,
    .nf-act-btn,
    .fpc-header-btn {
        min-height: 44px;
    }

    /* Menos atraso no primeiro toque (tap) em browsers antigos */
    .btn,
    button:not(.mob-nav-item),
    [role="button"]:not(.mob-nav-item),
    .nav-item,
    .tab-insta,
    .tab-btn {
        touch-action: manipulation;
    }

    /* Inputs larger on mobile */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    select,
    textarea {
        min-height: 44px;
    }

    /* Prevent iOS from zooming on focus */
    input[type="text"]:not([readonly]),
    input[type="email"]:not([readonly]),
    input[type="password"]:not([readonly]),
    input[type="search"]:not([readonly]),
    input[type="number"]:not([readonly]),
    textarea:not([readonly]),
    select {
        font-size: max(16px, 1em);
    }

    /* Toast — full width on mobile */
    .toast {
        left: 12px;
        right: 12px;
        max-width: calc(100% - 24px);
    }
}

@media (max-width: 480px) {
    /* Modals as bottom sheets */
    .modal-content,
    .modal-content-modern {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-height: calc(var(--fl-screen) * 92 / 100) !important;
        /* Safe area: home indicator iOS não bloqueia botões */
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        animation: slideUpSheet 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUpSheet {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    /* Center vertically inside modal backdrop still works */
    .modal.active,
    .modal-modern.active {
        align-items: flex-end;
        padding: 0;
    }

    /* Header in modal — adjust for bottom sheet */
    .modal-header,
    .modal-content .modal-header {
        border-radius: 20px 20px 0 0;
    }
}

/* ============================================
   MOBILE APP-SHELL POLISH
   ============================================ */

/* Scroll suave só quando o utilizador não pediu menos movimento */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Inércia de scroll em painéis com overflow (evita aplicar a todos os elementos) */
.overflow-y-auto,
.overflow-auto,
.modal-body,
.chat-messages,
[class*="__scroll"] {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    /* ── Tap/press feedback on interactive cards ── */
    .feature-card,
    .anuncio-card,
    .anuncio-card-modern,
    .freela-card,
    .freela-card-modern,
    .curso-card,
    .t-card,
    .stat-card,
    .selo-card {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.12s ease, box-shadow 0.12s ease;
    }

    .feature-card:active,
    .anuncio-card:active,
    .anuncio-card-modern:active,
    .freela-card:active,
    .freela-card-modern:active,
    .curso-card:active,
    .t-card:active,
    .stat-card:active,
    .selo-card:active {
        transform: scale(0.97);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    }

    /* ── Tab bars scroll horizontally as pill row ── */
    .tabs-primary,
    .filter-buttons,
    .filter-controls,
    .tabs-section-bar {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
        scroll-snap-type: x proximity;
    }

    .tabs-primary::-webkit-scrollbar,
    .filter-buttons::-webkit-scrollbar,
    .filter-controls::-webkit-scrollbar,
    .tabs-section-bar::-webkit-scrollbar {
        display: none;
    }

    /* ── Page title: reduce large hero type ── */
    .page-header h1 {
        font-size: 1.45rem !important;
        line-height: 1.15 !important;
    }

    .page-header p {
        font-size: 13px !important;
    }

    /* ── Content padding consistency ── */
    .content-wrapper {
        padding: 16px;
    }

    /* ── Section headers more compact ── */
    .section-header {
        margin-bottom: 12px;
    }

    .section-header h2,
    .section-title {
        font-size: 1.1rem;
    }

    /* ── Notifications: folha completa cobre a tab bar; só padding extra no modo antigo ── */
    .nf-dropdown-wrap:not(.nf-dropdown-wrap--sheet) {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }
}

/* ============================================
   SELECT SYSTEM (PADRONIZADO)
   ============================================ */

/* Selects usados em abas/filtros (anúncios, freelancer, cursos, trilhas, etc.) */
select.form-select,
select.category-filter-select,
select.status-select-mobile,
.filters-section select,
.filter-buttons select,
#statusSelectMobile,
#freelaStatusSelectMobile {
    min-height: 42px;
    padding: 10px 40px 10px 14px;
    border: 1px solid rgba(148, 163, 184, 0.28) !important;
    border-radius: 12px !important;
    background-color: rgba(15, 23, 42, 0.86) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 14px 14px !important;
    color: #f8fafc !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.08s ease;
}

select.form-select:hover,
select.category-filter-select:hover,
select.status-select-mobile:hover,
.filters-section select:hover,
.filter-buttons select:hover,
#statusSelectMobile:hover,
#freelaStatusSelectMobile:hover {
    border-color: rgba(167, 139, 250, 0.62) !important;
    background-color: rgba(15, 23, 42, 0.96) !important;
}

select.form-select:focus,
select.category-filter-select:focus,
select.status-select-mobile:focus,
.filters-section select:focus,
.filter-buttons select:focus,
#statusSelectMobile:focus,
#freelaStatusSelectMobile:focus {
    outline: none;
    border-color: #8b5cf6 !important;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22) !important;
}

select.form-select:active,
select.category-filter-select:active,
select.status-select-mobile:active,
.filters-section select:active,
.filter-buttons select:active,
#statusSelectMobile:active,
#freelaStatusSelectMobile:active {
    transform: scale(0.995);
}

select.form-select option,
select.category-filter-select option,
select.status-select-mobile option,
.filters-section select option,
.filter-buttons select option,
#statusSelectMobile option,
#freelaStatusSelectMobile option {
    background: #111827;
    color: #e2e8f0;
}

@media (max-width: 768px) {
    select.form-select,
    select.category-filter-select,
    select.status-select-mobile,
    .filters-section select,
    .filter-buttons select,
    #statusSelectMobile,
    #freelaStatusSelectMobile {
        min-height: 44px;
        font-size: 16px !important; /* evita zoom no iOS */
    }
}

/* ── Marca /assets/brand (sidebar escuro = logo branca) ─────────────────── */
.fl-brand {
    display: block;
    line-height: 0;
    text-decoration: none;
    flex-shrink: 0;
}

.fl-brand:focus-visible {
    outline: 2px solid rgba(167, 139, 250, 0.85);
    outline-offset: 3px;
    border-radius: 8px;
}

.fl-brand-logo {
    display: block;
    height: 32px;
    width: auto;
    max-width: min(176px, 100%);
    object-fit: contain;
    object-position: left center;
}

.sidebar-header .fl-brand-logo {
    height: 34px;
    max-width: 180px;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE BOTTOM TAB BAR (#mobileBottomNav — fab.js)
   Estilos globais: páginas com bundle.css ou só global.css + fab
   ══════════════════════════════════════════════════════════════════ */

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 98;
}

.mob-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex: 1;
    min-width: 0;
    position: relative;
    color: rgba(255, 255, 255, 0.48);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.18s ease, background 0.18s ease, transform 0.15s ease;
    padding: 10px 6px;
    border-radius: 999px;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.mob-nav-item__icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.mob-nav-item__icon svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.mob-nav-item__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mob-nav-item:hover {
    color: rgba(255, 255, 255, 0.82);
}

.mob-nav-item:active .mob-nav-item__icon svg {
    transform: scale(0.9);
}

.mob-nav-item.active {
    color: #f5f3ff;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.42), rgba(217, 70, 239, 0.32));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.mob-nav-item.active .mob-nav-item__icon svg {
    filter: drop-shadow(0 0 6px rgba(217, 70, 239, 0.45));
}

@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        justify-content: center;
        align-items: flex-end;
        pointer-events: none;
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        /* ≥16px laterais para distância mínima nativa */
        padding: 0 16px calc(10px + env(safe-area-inset-bottom, 0px));
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .mobile-bottom-nav__pill {
        pointer-events: auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2px;
        width: 100%;
        max-width: min(400px, 100%);
        padding: 6px 8px;
        border-radius: 999px;
        background: rgba(22, 24, 29, 0.92);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow:
            0 14px 44px rgba(0, 0, 0, 0.5),
            0 2px 12px rgba(0, 0, 0, 0.35),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }

    /* Espaço para a pill só onde não há .main-content nem player (evita padding duplo) */
    body:has(#mobileBottomNav):not(.pb-body):not(.cp-body-root):not(:has(.main-content)) {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    html[data-auth="in"] #pfMainWrap {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }
}

/* ══════════════════════════════════════════════════════════════════
   TIPOGRAFIA MOBILE — textos, listas, links, botões (≤768px / ≤480px)
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    body {
        font-size: 0.9375rem;
        line-height: 1.55;
    }

    p,
    li,
    dd,
    dt,
    td,
    th {
        font-size: 0.9375rem;
    }

    ul,
    ol {
        padding-left: 1.25rem;
    }

    li + li {
        margin-top: 0.2em;
    }

    small,
    .text-caption {
        font-size: 0.8125rem;
    }

    h1,
    .h1-like {
        font-size: clamp(1.35rem, 4.2vw, 1.65rem);
    }

    h2 {
        font-size: clamp(1.2rem, 3.6vw, 1.4rem);
    }

    h3 {
        font-size: 1.1rem;
    }

    h4 {
        font-size: 1rem;
    }

    a:not(.mob-nav-item) {
        line-height: 1.45;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-outline,
    .btn-ghost {
        font-size: 0.9375rem;
        letter-spacing: 0.01em;
    }

    .text-link,
    .link-inline {
        font-size: inherit;
    }

    .error-title,
    .page-header h1 {
        font-size: clamp(1.35rem, 4vw, 1.55rem) !important;
    }

    .error-description {
        font-size: 0.9375rem !important;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    body {
        font-size: 0.875rem;
    }

    p,
    li,
    dd,
    dt,
    td,
    th {
        font-size: 0.875rem;
    }

    small,
    .text-caption {
        font-size: 0.75rem;
    }

    h2 {
        font-size: 1.15rem;
    }

    h3 {
        font-size: 1.02rem;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-outline,
    .btn-ghost {
        font-size: 0.875rem;
    }
}

/* ── Tabelas largas (listagens / admin): scroll horizontal sem partir o layout mobile ── */
.table-responsive {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    width: max-content;
    min-width: 100%;
}

/* Menos movimento: scroll e animações respeitam preferência do sistema */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
