/**
 * Novo Layout - MizuConecta
 * CSS customizado para o novo design baseado em Tailwind
 */

/* ===========================================
   FONTES
   =========================================== */
.font-jost {
    font-family: 'Jost', sans-serif;
}

/* ===========================================
   SIDEBAR
   =========================================== */
.sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 270px !important;
    height: 100vh !important;
    background-color: #fafafa !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: 999 !important;
    border-right: 1px solid #cfcfcf !important;
    border-radius: 0 0 0 12px !important;
}

.sidebar.active {
    transform: translateX(0) !important;
}

/* ===========================================
   MAIN CONTENT AREA
   =========================================== */
#main-content {
    padding: 2rem !important;
    background-color: #ececec !important;
    border: 1px solid #d3d2d1 !important;
    border-left: none !important;
    border-top: 1px solid #d3d2d1 !important;
    border-radius: 0 24px 24px 0 !important;
    box-shadow: -1px 1px 1px 0px rgba(0, 0, 0, 0.15) !important;
    min-height: calc(100vh - 69px) !important;
}

/* ===========================================
   MOBILE HEADER (Hamburger menu)
   =========================================== */
@media (max-width: 1023px) {
    /* Mobile header visível apenas em mobile/tablet */
    header.lg\:tw-hidden {
        display: flex !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 4rem !important;
        z-index: 1000 !important;
        background-color: white !important;
    }
}

@media (min-width: 1024px) {
    /* Mobile header oculto em desktop */
    header.lg\:tw-hidden {
        display: none !important;
    }
}

/* ===========================================
   MOBILE OVERLAY
   =========================================== */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 998;
    backdrop-filter: blur(2px);
}

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

/* ===========================================
   MOBILE MENU BUTTON ANIMATION
   =========================================== */
.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translateY(8px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-8px);
}

/* ===========================================
   STATUS BADGES
   =========================================== */
.status-badge {
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 9999px;
    font-weight: 500;
    display: inline-block;
    text-align: center;
    min-width: 80px;
}

.status-pendente {
    background-color: #fef9c2;
    color: #894b00;
}

.status-aprovado {
    background-color: #eeeeee;
    color: #2a2a2a;
}

.status-reprovado {
    background-color: #ffe2e2;
    color: #9f0712;
}

/* ===========================================
   NAV ITEMS (SIDEBAR)
   =========================================== */
.nav-item {
    transition: all 0.2s ease;
}

.nav-item:hover {
    transform: translateX(2px);
}

.nav-item.active {
    background-color: #82807e !important;
    color: white !important;
    font-weight: 600;
}

/* ===========================================
   TOP NAVIGATION
   =========================================== */
.top-nav {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 1rem 2rem 0 2rem !important;
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    height: 69px !important;
}

/* Botão de logout/seta */
.top-nav .logout-btn,
.top-nav button.logout-btn {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.75rem !important;
    cursor: pointer !important;
}

.top-nav .logout-btn:hover {
    background-color: #f3f4f6 !important;
    border-radius: 0.25rem !important;
}

/* ===========================================
   TABS (TOP NAV)
   =========================================== */
.tab {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    padding: 0.625rem 1.25rem !important;
    border-radius: 10px 10px 0 0 !important;
    border: 1px solid #d3d2d1 !important;
    border-bottom: none !important;
    min-height: 44px !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    white-space: nowrap !important;
}

.tab:hover {
    opacity: 1 !important;
    text-decoration: none !important;
}

.tab.active,
.tab[class*="tw-bg-[#ececec]"] {
    background-color: #ececec !important;
    opacity: 1 !important;
}

/* Tabs inativas */
.tab[class*="tw-opacity-60"] {
    background-color: #fafafa !important;
    opacity: 0.6 !important;
}

.tab[class*="tw-opacity-60"]:hover {
    opacity: 1 !important;
}

/* ===========================================
   METRIC CARDS
   =========================================== */
.metric-card {
    transition: all 0.2s ease;
}

.metric-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* ===========================================
   SUMMARY TABLES
   =========================================== */
.summary-table-row {
    transition: background-color 0.15s ease;
}

.summary-table-row:hover {
    background-color: #f9fafb;
}

/* ===========================================
   SCROLLBAR CUSTOMIZADO (SIDEBAR)
   =========================================== */
.sidebar nav::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar nav::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 2px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* ===========================================
   RESPONSIVIDADE MOBILE
   =========================================== */

/* ---- TABLET E MOBILE (max 1023px) ---- */
@media (max-width: 1023px) {
    /* Sidebar SEMPRE oculta por padrão no mobile/tablet */
    /* IMPORTANTE: Sobrescrever a classe .collapsed que reduz width para 76px */
    aside.sidebar,
    .sidebar,
    aside.sidebar.collapsed,
    .sidebar.collapsed {
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
        position: fixed !important;
        left: 0 !important;
        z-index: 999 !important;
        width: 270px !important;
        max-width: 85vw !important;
        overflow-x: visible !important;
        overflow-y: auto !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }

    /* Sobrescrever TODOS os estilos da classe collapsed */
    .sidebar.collapsed .menu-text,
    aside.sidebar.collapsed .menu-text {
        display: inline !important;
    }

    .sidebar.collapsed .menuItem,
    aside.sidebar.collapsed .menuItem {
        display: inline-block !important;
    }

    .sidebar.collapsed .sidebar__menu-group,
    aside.sidebar.collapsed .sidebar__menu-group {
        margin-bottom: inherit !important;
    }

    .sidebar.collapsed .nav-item,
    aside.sidebar.collapsed .nav-item,
    .sidebar.collapsed nav a,
    aside.sidebar.collapsed nav a {
        display: flex !important;
        width: 100% !important;
        height: auto !important;
        border-radius: 0.5rem !important;
        padding: 0.75rem !important;
        justify-content: flex-start !important;
        margin: 0 !important;
    }

    .sidebar.collapsed nav,
    aside.sidebar.collapsed nav {
        padding: 1rem 0.5rem !important;
    }

    /* Sidebar ativa (quando menu é clicado) */
    aside.sidebar.active,
    .sidebar.active,
    aside.sidebar.collapsed.active,
    .sidebar.collapsed.active {
        transform: translateX(0) !important;
        left: 0 !important;
        width: 270px !important;
    }

    /* Main content ocupa tela toda - sem margin-left */
    main.main-content,
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Content area sem bordas arredondadas */
    #main-content {
        border-radius: 0 !important;
        padding: 1rem !important;
        margin-top: 0 !important;
    }

    /* App container - padding top para mobile header */
    .app-container {
        padding-top: 4rem !important;
    }

    /* Sidebar - nav container */
    .sidebar nav,
    aside.sidebar nav {
        padding-left: 0.75rem !important;
        padding-right: 0.5rem !important;
        margin: 0 !important;
    }

    /* Sidebar itens de navegação */
    .sidebar .nav-item,
    aside.sidebar .nav-item {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.875rem !important;
    }

    /* Space-y container */
    .sidebar .tw-space-y-1,
    aside.sidebar .tw-space-y-1 {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* User profile dentro da sidebar */
    .sidebar .tw-p-4 {
        padding: 0.75rem !important;
    }

    /* Logo area */
    .sidebar .tw-px-6,
    aside.sidebar .tw-px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ---- SIDEBAR MOBILE PEQUENO (max 480px) ---- */
@media (max-width: 480px) {
    aside.sidebar,
    .sidebar {
        width: 250px !important;
        max-width: 85vw !important;
        overflow-x: hidden !important;
        left: 0 !important;
        border-radius: 0 !important;
    }

    /* Logo menor */
    .sidebar .tw-h-\[76px\] {
        height: 60px !important;
        padding: 0.5rem 0.75rem !important;
    }

    .sidebar .tw-h-\[76px\] img {
        height: 1.75rem !important;
    }

    /* Área de navegação */
    .sidebar nav,
    aside.sidebar nav {
        padding: 0.75rem 0.5rem !important;
        margin: 0 !important;
    }

    /* Nav items */
    .sidebar .nav-item,
    aside.sidebar .nav-item {
        padding: 0.5rem 0.5rem !important;
        font-size: 0.8rem !important;
        min-height: 38px !important;
    }

    .sidebar nav .tw-space-y-1 > * {
        margin-bottom: 0.25rem !important;
    }

    /* Logo area */
    .sidebar .tw-px-6,
    aside.sidebar .tw-px-6 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* ---- MOBILE (max 768px) ---- */
@media (max-width: 768px) {
    /* Top Navigation - layout flexível */
    nav.top-nav,
    .top-nav {
        padding: 0.5rem 0.75rem 0 0.75rem !important;
        height: auto !important;
        min-height: 56px !important;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
        align-items: center !important;
    }

    /* Container das tabs - SCROLL HORIZONTAL */
    nav.top-nav > div:first-child,
    .top-nav > div:first-child,
    .top-nav > .tw-flex:first-child {
        display: flex !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: calc(100% - 50px) !important;
        padding-bottom: 0 !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        flex-wrap: nowrap !important;
    }

    nav.top-nav > div:first-child::-webkit-scrollbar,
    .top-nav > div:first-child::-webkit-scrollbar,
    .top-nav > .tw-flex:first-child::-webkit-scrollbar {
        display: none !important;
        height: 0 !important;
    }

    /* Tabs compactas no mobile */
    .tab,
    a.tab {
        padding: 0.4rem 0.6rem !important;
        min-height: 34px !important;
        font-size: 0.7rem !important;
        gap: 0.35rem !important;
        flex-shrink: 0 !important;
    }

    .tab svg {
        width: 0.9rem !important;
        height: 0.9rem !important;
        flex-shrink: 0 !important;
    }

    .tab span {
        font-size: 0.65rem !important;
        white-space: nowrap !important;
    }

    /* Botão de logout - fixo à direita */
    .top-nav .logout-btn,
    .top-nav button.logout-btn {
        padding: 0.4rem !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
    }

    /* Main content com padding menor */
    #main-content {
        padding: 0.75rem !important;
        min-height: calc(100vh - 120px) !important;
    }
}

/* ---- MOBILE PEQUENO (max 480px) ---- */
@media (max-width: 480px) {
    /* Top nav ainda mais compacta */
    nav.top-nav,
    .top-nav {
        padding: 0.25rem 0.5rem 0 0.5rem !important;
        min-height: 48px !important;
    }

    /* Tabs muito pequenas */
    .tab,
    a.tab {
        padding: 0.3rem 0.5rem !important;
        min-height: 30px !important;
    }

    .tab svg {
        width: 0.8rem !important;
        height: 0.8rem !important;
    }

    .tab span {
        font-size: 0.6rem !important;
        max-width: 55px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Main content */
    #main-content {
        padding: 0.5rem !important;
    }
}

/* ===========================================
   CONSULTA DE FORNECEDOR
   =========================================== */

/* Supplier Card */
.supplier-card {
    animation: fadeInSupplier 400ms ease;
}

@keyframes fadeInSupplier {
    from {
        opacity: 0;
        transform: translateY(0.625rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tab Buttons - Estilo border-bottom */
.tab-btn {
    position: relative;
    border: none;
    background: transparent;
}

.tab-btn:focus {
    outline: none;
    box-shadow: 0 0 0 0.1875rem rgba(0, 119, 182, 0.2);
}

.tab-btn.active,
.tab-btn[aria-selected="true"] {
    color: #0077B6;
    border-bottom-color: #0077B6;
}

/* Tab Badge */
.tab-badge {
    transition: all 200ms ease;
}

.tab-btn.active .tab-badge,
.tab-btn[aria-selected="true"] .tab-badge {
    background-color: #0077B6;
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active,
.tab-content:not(.tw-hidden) {
    display: block;
}

/* Search Input */
.search-input-fornecedor:focus {
    border-color: #0077B6;
    box-shadow: 0 0 0 0.1875rem rgba(0, 119, 182, 0.1);
}

/* Status Badge verde */
#fornecedor-status.status-ativo {
    background-color: #DEF7EC;
    color: #03543F;
    border-color: #84E1BC;
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    .supplier-card {
        animation: none;
    }
    
    * {
        transition-duration: 0.01ms !important;
    }
}
