/* ========================================
   MODERN SIDEBAR NAVIGATION
   Sidebar Colapsável com localStorage
   ======================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 60px;
    --sidebar-transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 60px;
}

/* ========================================
   LAYOUT CONTAINER
   ======================================== */

.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* ========================================
   SIDEBAR STYLES
   ======================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    transition: width var(--sidebar-transition), transform var(--sidebar-transition);
    z-index: 1000;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* ========================================
   SIDEBAR HEADER (Logo + Toggle)
   ======================================== */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: var(--header-height);
    background: rgba(0, 0, 0, 0.2);
    position: relative;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--sidebar-transition);
}

.sidebar.collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-logo img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: white;
    padding: 4px;
    flex-shrink: 0;
}

/* NOVO BOTÃO DE TOGGLE MODERNO E VISÍVEL */
.sidebar-toggle-btn {
    position: absolute;
    top: 16px;
    right: -20px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 0 0 0 rgba(102, 126, 234, 0.4);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6), 0 0 0 8px rgba(102, 126, 234, 0.1);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

.sidebar-toggle-btn .toggle-icon {
    color: white;
    font-size: 1.4rem;
    line-height: 1;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-btn .toggle-icon i {
    transition: transform 0.3s ease;
}

/* Animação quando sidebar está collapsed */
.sidebar.collapsed .sidebar-toggle-btn {
    right: -20px;
}

.sidebar.collapsed .sidebar-toggle-btn .toggle-icon i {
    transform: rotate(180deg);
}

/* Pulsar effect no botão (chamar atenção) */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4), 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

.sidebar-toggle-btn.pulse {
    animation: pulse 2s infinite;
}

/* ========================================
   SIDEBAR MENU
   ======================================== */

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.menu-item {
    margin: 0.25rem 0.75rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    position: relative;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.menu-link.active {
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.menu-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.menu-link-text {
    opacity: 1;
    transition: opacity var(--sidebar-transition);
}

.sidebar.collapsed .menu-link-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .menu-link {
    justify-content: center;
    padding: 0.875rem 0;
}

/* Tooltip removido - agora usando Bootstrap 5 tooltips padrão */

/* ========================================
   SIDEBAR FOOTER (User Profile)
   ======================================== */

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
    padding: 0.75rem;
    border-radius: 10px;
    transition: all 0.2s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    opacity: 1;
    transition: opacity var(--sidebar-transition);
}

.sidebar.collapsed .user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ========================================
   MAIN CONTENT AREA
   ======================================== */

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--sidebar-transition);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

.sidebar.collapsed ~ .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* ========================================
   TOP HEADER (Breadcrumbs + User Actions)
   ======================================== */

.top-header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ========================================
   BREADCRUMBS
   ======================================== */

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    color: #64748b;
}

.breadcrumb-item a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item a:hover {
    color: #ec4899;
}

.breadcrumb-item.active {
    color: #1e293b;
    font-weight: 600;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    margin: 0 0.5rem;
    color: #cbd5e1;
}

.breadcrumb-item i {
    font-size: 1rem;
    margin-right: 0.25rem;
}

/* ========================================
   HEADER ACTIONS
   ======================================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    transition: background 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.header-user:hover {
    background: #f8fafc;
}

.header-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
}

.header-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
}

.btn-logout {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-logout:hover {
    background: #fecaca;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

/* ========================================
   CONTENT AREA
   ======================================== */

.content-wrapper {
    flex: 1;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, #fce7f3 0%, #f3e8ff 50%, #e0e7ff 100%);
    position: relative;
}

.content-wrapper::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(236, 72, 153, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.content-inner {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   MOBILE BACKDROP
   ======================================== */

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity var(--sidebar-transition);
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Desktop and Tablet (> 992px) - Sidebar always visible */
@media (min-width: 993px) {
    .mobile-menu-toggle {
        display: none;
    }

    .sidebar-toggle-btn {
        display: flex; /* Mostrar botão apenas em desktop */
    }
}

/* Tablet and Mobile (≤ 992px) - Sidebar overlay */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    /* Esconder botão de toggle desktop em mobile */
    .sidebar-toggle-btn {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
        color: white;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.2s;
        font-size: 1.25rem;
    }

    .mobile-menu-toggle:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
    }

    /* Mostrar backdrop quando sidebar está aberta */
    .sidebar.mobile-open ~ .sidebar-backdrop {
        display: block;
        opacity: 1;
    }
}

/* Mobile (≤ 768px) - Ajustes adicionais */
@media (max-width: 768px) {
    .top-header {
        padding: 0.75rem 1rem;
    }

    .content-wrapper {
        padding: 1.25rem 1rem;
    }

    .breadcrumb {
        font-size: 0.85rem;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        margin: 0 0.35rem;
    }

    .header-user-name {
        display: none;
    }

    .btn-logout span {
        display: none;
    }

    .btn-logout {
        padding: 0.5rem;
        width: 40px;
        justify-content: center;
    }
}

/* Very Small Mobile (≤ 576px) */
@media (max-width: 576px) {
    .sidebar {
        width: 280px;
    }

    .sidebar.mobile-open {
        width: 280px;
    }

    .content-wrapper {
        padding: 1rem 0.75rem;
    }

    .breadcrumb-item:not(:last-child):not(:first-child) {
        display: none;
    }

    .breadcrumb-item:not(:last-child)::after {
        content: '...';
        margin: 0 0.5rem;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sidebar.mobile-open {
    animation: slideInFromLeft 0.3s ease-out;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.75rem 1rem;
}

.menu-label {
    padding: 0.5rem 1rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.5rem;
}

.sidebar.collapsed .menu-label {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

/* Badge de notificações */
.menu-badge {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    font-weight: 700;
    margin-left: auto;
}

.sidebar.collapsed .menu-badge {
    display: none;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .sidebar,
    .top-header,
    .sidebar-backdrop {
        display: none !important;
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .content-wrapper {
        padding: 0 !important;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.sidebar-toggle:focus,
.menu-link:focus,
.mobile-menu-toggle:focus {
    outline: 2px solid #ec4899;
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .main-wrapper,
    .menu-link,
    .sidebar-toggle i {
        transition: none !important;
    }
}
