/**
 * Flavor Theme - Correções e Melhorias v2.0
 * Academia Borromeu
 * 
 * Correções:
 * - Menu mobile e desktop
 * - Grid de cursos LearnDash
 * - Responsividade geral
 * - Shortcodes do plugin ABM
 */

/* ==========================================================================
   CORREÇÕES DE OVERFLOW / ESTOURO
   ========================================================================== */

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

* {
    box-sizing: border-box;
}

img, video, iframe, embed {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   HEADER / MENU - CORREÇÕES
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--flavor-bg-primary);
    border-bottom: 1px solid var(--flavor-border);
    padding: 10px 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--flavor-container-max);
    margin: 0 auto;
    padding: 0 15px;
    gap: 15px;
    flex-wrap: nowrap;
}

.site-logo {
    flex-shrink: 0;
}

.site-logo img {
    max-height: 45px;
    width: auto;
}

.site-logo a {
    font-size: 1.1rem; /* Reduzido */
}

/* Menu Principal - Desktop */
.main-navigation {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
    min-width: 0; /* Permite shrink */
}

.main-navigation ul {
    display: flex;
    align-items: center;
    gap: 10px; /* Reduzido */
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.main-navigation a {
    color: var(--flavor-text-secondary);
    font-size: 0.85rem; /* Reduzido */
    font-weight: 500;
    padding: 8px 10px; /* Reduzido */
    white-space: nowrap;
    display: block;
}

/* Submenu */
.main-navigation .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid var(--flavor-border);
    border-radius: 8px;
    box-shadow: var(--flavor-shadow-lg);
    min-width: 200px;
    display: none;
    z-index: 1001;
}

.main-navigation .menu-item-has-children {
    position: relative;
}

.main-navigation .menu-item-has-children:hover > .sub-menu {
    display: block;
}

.main-navigation .sub-menu li {
    border-bottom: 1px solid var(--flavor-border);
}

.main-navigation .sub-menu li:last-child {
    border-bottom: none;
}

.main-navigation .sub-menu a {
    padding: 12px 15px;
    font-size: 0.875rem;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-action-btn {
    width: 38px;
    height: 38px;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1002;
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--flavor-text-primary);
    transition: all 0.3s;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

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

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ==========================================================================
   LEARNDASH - GRID DE CURSOS
   ========================================================================== */

/* Container de cursos */
.learndash-wrapper .ld-item-list,
.ld-course-list-items,
[class*="ld-course-list"],
.learndash-course-list {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* Card individual do curso */
.learndash-wrapper .ld-item-list-item,
.ld-course-list-item,
[class*="ld-course-list"] > div,
.learndash-course-list .course,
.ld-item-list-item {
    display: flex !important;
    flex-direction: column;
    background: white;
    border: 1px solid var(--flavor-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
}

.learndash-wrapper .ld-item-list-item:hover,
.ld-course-list-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--flavor-shadow-lg);
    border-color: var(--flavor-accent);
}

/* Imagem do curso */
.learndash-wrapper .ld-item-list-item .ld-item-thumb,
.ld-course-list-item .thumbnail,
.ld-course-list-item img,
.course-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Conteúdo do card */
.learndash-wrapper .ld-item-list-item .ld-item-details,
.ld-course-list-item .content,
.course-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Título do curso */
.learndash-wrapper .ld-item-list-item .ld-item-title,
.ld-course-list-item .entry-title,
.course-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--flavor-text-primary);
    line-height: 1.3;
}

/* Link clicável em todo o card */
.learndash-wrapper .ld-item-list-item > a,
.ld-course-list-item > a {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* Progresso dentro do card */
.learndash-wrapper .ld-item-list-item .ld-progress,
.ld-course-list-item .ld-progress {
    margin-top: auto;
    padding-top: 15px;
}

.learndash-wrapper .ld-progress-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.learndash-wrapper .ld-progress-bar-percentage {
    background: linear-gradient(90deg, #667eea, #764ba2);
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* ==========================================================================
   LISTA DE CURSOS - MODO ALTERNATIVO
   ========================================================================== */

/* Modo Lista (quando .view-list está ativo) */
body.courses-view-list .learndash-wrapper .ld-item-list,
body.courses-view-list .ld-course-list-items,
.courses-list-view {
    display: flex !important;
    flex-direction: column;
    gap: 15px;
}

body.courses-view-list .learndash-wrapper .ld-item-list-item,
body.courses-view-list .ld-course-list-item,
.courses-list-view .course-item {
    flex-direction: row !important;
    align-items: center;
    padding: 15px 20px !important;
}

body.courses-view-list .ld-item-list-item .ld-item-thumb,
body.courses-view-list .course-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    margin-right: 20px;
    flex-shrink: 0;
}

/* Toggle de visualização */
.courses-view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: flex-end;
}

.courses-view-toggle button {
    padding: 10px 15px;
    border: 1px solid var(--flavor-border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.courses-view-toggle button.active,
.courses-view-toggle button:hover {
    background: var(--flavor-accent);
    color: white;
    border-color: var(--flavor-accent);
}

/* ==========================================================================
   PLUGIN ABM - ESTILOS RESPONSIVOS
   ========================================================================== */

/* Chat */
.abm-chat-fullpage {
    display: flex;
    min-height: 70vh;
    background: #f5f5f5;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.abm-chat-sidebar {
    width: 300px;
    background: white;
    border-right: 1px solid #eee;
    flex-shrink: 0;
}

.abm-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Calendário */
.abm-calendar {
    max-width: 100%;
    overflow-x: auto;
}

.abm-calendar-grid {
    min-width: 700px;
}

/* Perfis */
.abm-profile-selector {
    padding: 30px 15px;
}

.profiles-grid {
    gap: 20px;
}

.profile-card {
    width: 100px;
}

.profile-avatar img,
.profile-avatar span {
    width: 80px !important;
    height: 80px !important;
}

/* ==========================================================================
   RESPONSIVO - TABLET
   ========================================================================== */

@media (max-width: 1024px) {
    .header-inner {
        padding: 0 15px;
    }
    
    .main-navigation ul {
        gap: 5px;
    }
    
    .main-navigation a {
        font-size: 0.8rem;
        padding: 6px 8px;
    }
    
    /* Grid de cursos 2 colunas */
    .learndash-wrapper .ld-item-list,
    .ld-course-list-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   RESPONSIVO - MOBILE
   ========================================================================== */

@media (max-width: 768px) {
    /* Header */
    .site-header {
        padding: 8px 0;
    }
    
    .header-inner {
        padding: 0 10px;
    }
    
    .site-logo img {
        max-height: 35px;
    }
    
    /* Menu Mobile */
    .mobile-menu-toggle {
        display: flex;
    }
    
    .main-navigation {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 1001;
        padding: 80px 20px 20px;
        overflow-y: auto;
    }
    
    .main-navigation.active {
        display: block;
    }
    
    .main-navigation ul {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }
    
    .main-navigation li {
        border-bottom: 1px solid var(--flavor-border);
    }
    
    .main-navigation a {
        display: block;
        padding: 15px;
        font-size: 1rem;
    }
    
    .main-navigation .sub-menu {
        position: static;
        display: none;
        border: none;
        box-shadow: none;
        padding-left: 20px;
        background: #f9f9f9;
    }
    
    .main-navigation .menu-item-has-children.open > .sub-menu {
        display: block;
    }
    
    /* Grid de cursos 1 coluna */
    .learndash-wrapper .ld-item-list,
    .ld-course-list-items,
    [class*="ld-course-list"] {
        grid-template-columns: 1fr !important;
        gap: 15px;
        padding: 10px;
    }
    
    /* Cards menores */
    .learndash-wrapper .ld-item-list-item .ld-item-thumb {
        height: 150px;
    }
    
    /* Chat */
    .abm-chat-fullpage {
        flex-direction: column;
        min-height: auto;
    }
    
    .abm-chat-sidebar {
        width: 100%;
        max-height: 200px;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    
    .abm-chat-main {
        min-height: 400px;
    }
    
    /* Calendário */
    .abm-calendar-grid {
        min-width: 0;
    }
    
    .cal-days {
        font-size: 12px;
    }
    
    .cal-day {
        min-height: 50px;
        padding: 3px;
    }
    
    .cal-event {
        font-size: 8px;
        padding: 1px 3px;
    }
    
    /* Perfis */
    .abm-profile-selector h2 {
        font-size: 24px;
    }
    
    .profiles-grid {
        gap: 15px;
    }
    
    .profile-card {
        width: 80px;
    }
    
    .profile-avatar img,
    .profile-avatar span {
        width: 60px !important;
        height: 60px !important;
        font-size: 40px !important;
    }
    
    .profile-name {
        font-size: 12px;
    }
    
    /* Horário */
    .schedule-grid {
        overflow-x: auto;
    }
    
    .schedule-header,
    .schedule-row {
        min-width: 600px;
    }
    
    /* Formulários */
    .woocommerce div.product form.cart {
        flex-direction: column;
    }
    
    .woocommerce div.product form.cart .button {
        width: 100%;
    }
    
    /* Tipografia */
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    /* Container */
    .flavor-container {
        padding: 0 10px;
    }
}

/* ==========================================================================
   RESPONSIVO - MOBILE PEQUENO
   ========================================================================== */

@media (max-width: 480px) {
    .header-action-btn {
        width: 34px;
        height: 34px;
    }
    
    .header-action-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .learndash-wrapper .ld-item-list-item .ld-item-thumb {
        height: 120px;
    }
    
    .abm-chat-sidebar {
        max-height: 150px;
    }
    
    /* Botões menores */
    .btn,
    button,
    input[type="submit"] {
        padding: 10px 15px;
        font-size: 0.875rem;
    }
    
    /* Alertas popup */
    .abm-alert-popup {
        width: 95% !important;
        max-width: none !important;
    }
    
    .abm-alert-popup h2 {
        font-size: 18px !important;
    }
}

/* ==========================================================================
   UTILITÁRIOS
   ========================================================================== */

/* Forçar clicável */
.clickable-card {
    cursor: pointer;
}

.clickable-card:hover {
    transform: translateY(-2px);
}

/* Esconder em mobile */
.hide-mobile {
    display: block;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Mostrar só em mobile */
.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* Fix para WooCommerce em mobile */
@media (max-width: 768px) {
    .woocommerce-cart-form table {
        display: block;
        overflow-x: auto;
    }
    
    .woocommerce-checkout .col2-set {
        grid-template-columns: 1fr;
    }
    
    .woocommerce ul.products {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   ADMIN BAR FIX
   ========================================================================== */

@media (max-width: 782px) {
    .admin-bar .site-header {
        top: 46px;
    }
    
    .admin-bar .main-navigation.active {
        top: 46px;
    }
}

@media (min-width: 783px) {
    .admin-bar .site-header {
        top: 32px;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .site-header,
    .site-footer,
    .mobile-menu-toggle,
    .header-actions,
    .abm-chat-button {
        display: none !important;
    }
    
    .site-content {
        padding: 0;
    }
}
