/* ============================================================================
   LAYOUT.CSS — Mentoria de Resultado
   Header, sidebar, navegação global
   Design: Apple-inspired, Inter/SF Pro, glassmorphism
   ============================================================================ */

/* ----------------------------------------------------------------------------
   CSS Variables (complementares às do tema das páginas)
   ---------------------------------------------------------------------------- */
:root {
    --layout-header-height: 64px;
    --layout-sidebar-width: 280px;
    --layout-sidebar-collapsed: 72px;
    --layout-z-header: 1000;
    --layout-z-sidebar: 900;
    --layout-z-overlay: 800;
    --layout-transition: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --layout-primary: #0071E3;
    --layout-primary-dark: #0051A8;
    --layout-text: #1D1D1F;
    --layout-text-secondary: #86868B;
    --layout-text-tertiary: #AEAEB2;
    --layout-bg: #F5F5F7;
    --layout-surface: rgba(255, 255, 255, 0.72);
    --layout-surface-solid: #FFFFFF;
    --layout-border: rgba(0, 0, 0, 0.06);
    --layout-glass: rgba(255, 255, 255, 0.65);
    --layout-glass-border: rgba(255, 255, 255, 0.25);
}

/* ----------------------------------------------------------------------------
   Reset para layout
   ---------------------------------------------------------------------------- */
.mr-layout-injected body {
    margin: 0;
    padding: 0;
}

/* ----------------------------------------------------------------------------
   Header
   ---------------------------------------------------------------------------- */
.mr-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--layout-header-height);
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--layout-border);
    z-index: var(--layout-z-header);
    display: flex;
    align-items: center;
    padding: 0 24px;
    transition: var(--layout-transition);
}

.mr-header-inner {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 100%;
    gap: 16px;
}

/* Botão hamburger */
.mr-header-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background 200ms ease;
    flex-shrink: 0;
    padding: 0;
}

.mr-header-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mr-header-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--layout-text);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Logo / Brand */
.mr-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.mr-header-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--layout-primary) 0%, var(--layout-primary-dark) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.mr-header-logo svg {
    width: 18px;
    height: 18px;
    stroke: #FFFFFF;
    stroke-width: 2;
    fill: none;
}

.mr-header-brand-text {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--layout-text);
}

/* Spacer */
.mr-header-spacer {
    flex: 1;
}

/* Online counter */
.mr-header-online {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(48, 209, 88, 0.08);
    border-radius: 100px;
    border: 1px solid rgba(48, 209, 88, 0.15);
    flex-shrink: 0;
}

.mr-header-online-dot {
    width: 7px;
    height: 7px;
    background: #30D158;
    border-radius: 50%;
    animation: mr-pulse 2.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes mr-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.mr-header-online-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--layout-text-secondary);
    white-space: nowrap;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Level badge */
.mr-header-level {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 8px;
    background: var(--layout-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 100px;
    border: 1px solid var(--layout-glass-border);
    cursor: pointer;
    transition: all 200ms ease;
    flex-shrink: 0;
    text-decoration: none;
}

.mr-header-level:hover {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 113, 227, 0.2);
}

.mr-header-level-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--layout-primary) 0%, #5856D6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: #FFFFFF;
    font-family: 'Inter', sans-serif;
    flex-shrink: 0;
}

.mr-header-level-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mr-header-level-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--layout-text-tertiary);
    line-height: 1;
}

.mr-header-level-bar {
    width: 48px;
    height: 3px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 100px;
    overflow: hidden;
}

.mr-header-level-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--layout-primary), #5856D6);
    border-radius: 100px;
    transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Agenda badge */
.mr-header-agenda {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 200ms ease;
    flex-shrink: 0;
    padding: 0;
    text-decoration: none;
}

.mr-header-agenda:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mr-header-agenda svg {
    width: 20px;
    height: 20px;
    stroke: var(--layout-text-secondary);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mr-header-agenda-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--layout-surface-solid);
    display: none;
}

.mr-header-agenda-badge.has-agenda {
    display: block;
    background: #30D158;
}

.mr-header-agenda-badge.no-agenda {
    display: block;
    background: #FF9F0A;
}

.mr-header-agenda-badge.rest-day {
    display: block;
    background: var(--layout-text-tertiary);
}

/* ----------------------------------------------------------------------------
   Sidebar Overlay (mobile)
   ---------------------------------------------------------------------------- */
.mr-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--layout-z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: all 250ms ease;
}

.mr-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ----------------------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------------------- */
.mr-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--layout-sidebar-width);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border-right: 1px solid var(--layout-border);
    z-index: var(--layout-z-sidebar);
    transform: translateX(-100%);
    transition: transform var(--layout-transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

/* Sidebar header */
.mr-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    height: var(--layout-header-height);
    border-bottom: 1px solid var(--layout-border);
    flex-shrink: 0;
}

.mr-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.mr-sidebar-brand-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--layout-primary) 0%, var(--layout-primary-dark) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.mr-sidebar-brand-logo svg {
    width: 18px;
    height: 18px;
    stroke: #FFFFFF;
    stroke-width: 2;
    fill: none;
}

.mr-sidebar-brand-text {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--layout-text);
}

.mr-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 200ms ease;
    padding: 0;
}

.mr-sidebar-close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.mr-sidebar-close svg {
    width: 18px;
    height: 18px;
    stroke: var(--layout-text-secondary);
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Sidebar nav */
.mr-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.08) transparent;
}

.mr-sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.mr-sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.mr-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
}

/* Section label */
.mr-nav-section {
    padding: 20px 12px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--layout-text-tertiary);
}

.mr-nav-section:first-child {
    padding-top: 4px;
}

/* Nav item */
.mr-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--layout-text-secondary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: all 150ms ease;
    position: relative;
    margin-bottom: 2px;
}

.mr-nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--layout-text);
}

.mr-nav-item.active {
    background: rgba(0, 113, 227, 0.08);
    color: var(--layout-primary);
    font-weight: 600;
}

.mr-nav-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 200ms ease;
}

.mr-nav-item-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mr-nav-item.active .mr-nav-item-icon {
    background: rgba(0, 113, 227, 0.1);
}

.mr-nav-item-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mr-nav-item-badge {
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.mr-nav-item-badge.new {
    background: rgba(0, 113, 227, 0.1);
    color: var(--layout-primary);
}

.mr-nav-item-badge.count {
    background: rgba(255, 55, 95, 0.1);
    color: #FF375F;
}

.mr-nav-item-external::after {
    content: '';
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23AEAEB2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 150ms ease;
}

.mr-nav-item-external:hover::after {
    opacity: 1;
}

/* Nav divider */
.mr-nav-divider {
    height: 1px;
    margin: 8px 12px;
    background: var(--layout-border);
}

/* Sidebar footer */
.mr-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--layout-border);
    flex-shrink: 0;
}

.mr-sidebar-footer-text {
    font-size: 11px;
    color: var(--layout-text-tertiary);
    text-align: center;
}

/* ----------------------------------------------------------------------------
   Header Major (sub-header com widgets)
   ---------------------------------------------------------------------------- */
.mr-header-major {
    position: fixed;
    top: var(--layout-header-height);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--layout-border);
    z-index: calc(var(--layout-z-header) - 1);
    padding: 0 24px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 300ms ease,
                padding 400ms ease;
}

.mr-header-major.visible {
    max-height: 80px;
    opacity: 1;
    padding: 12px 24px;
}

.mr-header-major-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.mr-header-major-inner::-webkit-scrollbar {
    display: none;
}

.mr-major-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 200ms ease;
}

.mr-major-widget:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.mr-major-widget-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mr-major-widget-icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mr-major-widget-icon.concursos {
    background: rgba(16, 185, 129, 0.1);
}

.mr-major-widget-icon.concursos svg {
    stroke: #10B981;
}

.mr-major-widget-icon.simulados {
    background: rgba(244, 63, 94, 0.1);
}

.mr-major-widget-icon.simulados svg {
    stroke: #F43F5E;
}

.mr-major-widget-icon.recuperacao {
    background: rgba(99, 102, 241, 0.1);
}

.mr-major-widget-icon.recuperacao svg {
    stroke: #6366F1;
}

.mr-major-widget-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mr-major-widget-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--layout-text-tertiary);
}

.mr-major-widget-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--layout-text);
    letter-spacing: -0.01em;
}

/* ----------------------------------------------------------------------------
   Page content offset
   ---------------------------------------------------------------------------- */
.mr-page-content {
    padding-top: var(--layout-header-height);
    min-height: 100vh;
    transition: padding-top 300ms ease;
}

.mr-page-content.with-major {
    padding-top: calc(var(--layout-header-height) + 56px);
}

/* ----------------------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .mr-header {
        padding: 0 16px;
    }

    .mr-header-brand-text {
        display: none;
    }

    .mr-header-online-text {
        max-width: 140px;
        font-size: 11px;
    }

    .mr-header-level-info {
        display: none;
    }

    .mr-header-level {
        padding: 6px;
        border-radius: 50%;
    }

    .mr-header-major.visible {
        padding: 8px 16px;
    }

    .mr-major-widget {
        padding: 6px 12px;
    }

    .mr-major-widget-label {
        display: none;
    }
}

@media (max-width: 480px) {
    .mr-header-online {
        display: none;
    }
}

/* ----------------------------------------------------------------------------
   Animações
   ---------------------------------------------------------------------------- */
@keyframes mr-fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.mr-header {
    animation: mr-fadeIn 400ms ease forwards;
}
