/* ============================================
   ESTILOS MÓDULO DE AJUDA/TUTORIAL (Padronizado)
   OTIMIZADO: Layout responsivo + Desktop melhorado
   CORRECAO MOBILE: Botoes (2/linha) + Tabs (3/linha) - FORÇA BRUTA
   ============================================ */

.help-tutorial-module {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0;
    animation: help-fadeIn var(--transition-normal) ease;
}

/* ========== HEADER ========== */
.help-tutorial-module .module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 18px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--accent-blue);
}

.help-tutorial-module .module-title h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.help-tutorial-module .module-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 5px 0 0 0;
}

.help-tutorial-module .module-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.help-tutorial-module .module-actions button {
    padding: 10px 18px;
    font-size: 13px;
    transition: all var(--transition-fast);
}

/* ========== TABS ========== */
.help-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border: 1px solid var(--border-color);
    border-bottom: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.help-tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.help-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.help-tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* ========== SEARCH ========== */
.help-search {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.help-search .filter-search {
    position: relative;
    flex: 2;
    min-width: 250px;
}

.help-search .filter-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 1;
}

.help-search .filter-search input {
    padding-left: 36px;
    width: 100%;
}

/* ========== CORPO DO CONTEÚDO ========== */
.help-body {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-height: 500px;
}

/* ========== TÍTULOS ========== */
.help-body h3 {
    color: var(--text-primary);
    margin-top: 30px;
    margin-bottom: 16px;
    font-size: 1.3em;
    border-left: 4px solid var(--accent-blue);
    padding-left: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-body h3:first-child {
    margin-top: 0;
}

.help-body h4 {
    color: var(--text-secondary);
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 1.1em;
    font-weight: 600;
}

.help-body p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-body ul, 
.help-body ol {
    margin-bottom: 16px;
    padding-left: 28px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-body li {
    margin-bottom: 8px;
}

.help-body strong {
    color: var(--text-primary);
}

/* ========== CARDS DE MÓDULOS ========== */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.module-card {
    background: transparent;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
    transition: all var(--transition-fast);
    cursor: pointer;
    box-shadow: none;
}

.module-card:hover {
    transform: translateY(0);
    box-shadow: none;
    border-color: var(--border-color);
}

.module-card:active {
    transform: translateY(-1px);
}

.module-card h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}

.module-card h4 i {
    color: var(--accent-blue);
    font-size: 18px;
}

.module-card p {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.module-card .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

/* ========== WORKFLOW STEPS ========== */
.workflow-step {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: transparent;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
    transition: all var(--transition-fast);
    box-shadow: none;
}

.workflow-step:hover {
    box-shadow: none;
}

.step-number {
    min-width: 48px;
    width: 48px;
    height: 48px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2em;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.step-content p {
    margin-bottom: 8px;
}

.code-example {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-cyan);
    padding: 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    margin: 12px 0;
    color: var(--text-muted);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ========== TABELAS ========== */
.help-table-container {
    overflow-x: auto;
    margin: 24px 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
    min-width: 500px;
}

.help-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 14px 18px;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.help-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-table tbody tr:last-child td {
    border-bottom: none;
}

.help-table tbody tr:hover {
    background: var(--bg-hover);
}

.help-table td:first-child {
    font-weight: 600;
    color: var(--accent-cyan);
}

.glossario-table td:first-child,
.roles-table td:first-child {
    white-space: nowrap;
    width: 28%;
}

/* ========== FAQ & SEARCH RESULTS ========== */
.faq-item {
    padding: 20px;
    margin: 16px 0;
    background: transparent;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 4px solid #764ba2;
    transition: all var(--transition-fast);
    box-shadow: none;
}

.faq-item:hover {
    box-shadow: none;
}

.search-result {
    padding: 20px;
    margin: 16px 0;
    background: transparent;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-purple);
    transition: all var(--transition-fast);
    box-shadow: none;
}

.search-result:hover {
    box-shadow: none;
}

.faq-item h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
}

.faq-item h4 i {
    color: var(--accent-purple);
}

.search-result h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--accent-blue);
    font-size: 16px;
}

.search-result p {
    margin: 10px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.help-select {
    max-width: 350px;
    margin-bottom: 20px;
}

/* ========== BOTÕES ========== */
.help-body button {
    margin: 10px 0;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.help-body button:active {
    transform: scale(0.96);
}

/* ========== RESPONSIVO ========== */

/* Tablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .help-tutorial-module .module-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .help-tutorial-module .module-actions {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .help-tutorial-module .module-actions button {
        flex: 1;
        min-width: 0;
    }
    
    .help-tabs {
        flex-wrap: nowrap;
    }
    
    .help-tab-btn {
        padding: 10px 18px;
        font-size: 13px;
    }
    
    .help-tab-btn i {
        display: none;
    }
    
    .modules-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 16px;
    }
    
    .workflow-step {
        flex-direction: column;
        gap: 15px;
    }
    
    .step-number {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 1.1em;
    }
    
    .help-table {
        min-width: 400px;
    }
    
    .help-table th,
    .help-table td {
        padding: 12px 14px;
    }
}

/* Mobile (< 768px) - CORRECAO PRINCIPAL DE FORÇA BRUTA */
@media (max-width: 767px) {
    .help-tutorial-module .module-header {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
    }
    
    .help-tutorial-module .module-title h2 {
        font-size: 18px;
    }
    
    .help-tutorial-module .module-title p {
        font-size: 11px;
    }
    
    /* BOTOES SUPERIORES: 2 por linha - FORÇA BRUTA */
    .help-tutorial-module .module-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
        width: 100%;
    }
    
    .help-tutorial-module .module-actions button {
        flex: 0 0 calc(50% - 4px);
        max-width: calc(50% - 4px);
        width: calc(50% - 4px);
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 10px 4px;
        font-size: 11px;
        white-space: normal;
        word-break: break-word;
        min-height: 48px;
        margin: 0;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        border-radius: 0;
        box-sizing: border-box;
    }
    
    .help-tutorial-module .module-actions button i {
        display: inline-block;
        margin-right: 5px;
        font-size: 12px;
    }
    
    /* TABS INFERIORES: 3 por linha - FORÇA BRUTA */
    .help-tabs {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px;
        border-bottom: none;
        margin-bottom: 16px;
        overflow-x: visible;
        background: transparent;
        width: 100%;
    }
    
    .help-tab-btn {
        flex: 0 0 calc(33.333% - 6px);
        max-width: calc(33.333% - 6px);
        width: calc(33.333% - 6px);
        justify-content: center;
        text-align: center;
        padding: 10px 4px;
        font-size: 11px;
        white-space: normal;
        word-break: break-word;
        min-height: 48px;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 0;
        margin: 0;
    }
    
    .help-tab-btn i {
        display: inline-block;
        margin-right: 5px;
        font-size: 11px;
    }
    
    .help-tab-btn.active {
        border-bottom: 2px solid var(--accent-blue);
        background: rgba(59, 130, 246, 0.1);
    }
    
    /* Search */
    .help-search {
        flex-direction: column;
        padding: 14px;
        gap: 12px;
    }
    
    .help-search .filter-search {
        width: 100%;
        min-width: auto;
    }
    
    .help-search button {
        width: 100%;
    }
    
    /* Body */
    .help-body {
        padding: 16px;
    }
    
    .help-body h3 {
        font-size: 1.2em;
        margin-top: 24px;
        padding-left: 10px;
    }
    
    .help-body h4 {
        font-size: 1em;
    }
    
    .help-body p {
        font-size: 13px;
    }
    
    /* Modules grid */
    .modules-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .module-card {
        padding: 16px;
    }
    
    .module-card h4 {
        font-size: 15px;
    }
    
    .module-card p {
        font-size: 12px;
    }
    
    /* Workflow */
    .workflow-step {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
        margin: 16px 0;
    }
    
    .step-number {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 1em;
    }
    
    .code-example {
        font-size: 11px;
        padding: 12px;
    }
    
    /* Tabelas */
    .help-table-container {
        margin: 16px 0;
    }
    
    .help-table {
        min-width: 350px;
        font-size: 12px;
    }
    
    .help-table th,
    .help-table td {
        padding: 10px 12px;
    }
    
    .help-table td:first-child {
        white-space: normal;
        width: auto;
    }
    
    .glossario-table td:first-child,
    .roles-table td:first-child {
        white-space: normal;
        width: auto;
    }
    
    /* FAQ */
    .faq-item,
    .search-result {
        padding: 16px;
        margin: 12px 0;
    }
    
    .faq-item h4,
    .search-result h4 {
        font-size: 14px;
    }
    
    .help-select {
        max-width: 100%;
    }
}

/* Telas pequenas (400px - 480px) - TABS 2 por linha - FORÇA BRUTA */
@media (max-width: 480px) {
    .help-tab-btn {
        flex: 0 0 calc(50% - 4px);
        max-width: calc(50% - 4px);
        width: calc(50% - 4px);
        font-size: 10px;
        padding: 8px 4px;
        min-height: 44px;
    }
    
    .help-tab-btn i {
        font-size: 10px;
    }
}

/* Telas extremamente pequenas (< 350px) - TABS 1 por linha */
@media (max-width: 350px) {
    .help-tab-btn {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
    }
}

/* Desktop (> 768px) */
@media (min-width: 769px) {
    .help-tab-btn:hover {
        background: rgba(255, 255, 255, 0.03);
    }
    
    .module-card:hover {
        transform: translateY(-3px);
    }
    
    .workflow-step:hover {
        transform: translateX(4px);
    }
    
    .faq-item:hover,
    .search-result:hover {
        transform: translateX(4px);
    }
}

/* Large Desktop (> 1200px) */
@media (min-width: 1201px) {
    .help-body {
        max-width: 1100px;
        margin: 0 auto;
    }
    
    .modules-grid {
        gap: 24px;
    }
}

/* ========== TOUCH OTIMIZAÇÕES ========== */
@media (hover: none) and (pointer: coarse) {
    .module-card:active,
    .help-tab-btn:active,
    .faq-item:active {
        transform: scale(0.98);
        transition: transform 0.05s ease;
    }
    
    .module-card:hover,
    .workflow-step:hover,
    .faq-item:hover {
        transform: none;
    }
    
    button, .help-tab-btn {
        min-height: 44px;
    }
}

/* ========== ANIMAÇÕES ========== */
@keyframes help-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    .help-tutorial-module,
    .module-card,
    .workflow-step,
    .faq-item {
        animation: none;
        transition: none;
    }
    
    .module-card:hover,
    .workflow-step:hover {
        transform: none;
    }
}

/* ========== PRINT ========== */
@media print {
    .help-tutorial-module .module-actions,
    .help-search,
    .help-tabs,
    .help-select,
    .help-body button {
        display: none;
    }
    
    .help-body {
        padding: 0;
        background: white;
        color: black;
    }
    
    .module-card {
        break-inside: avoid;
        border: 1px solid #ccc;
    }
    
    .workflow-step {
        break-inside: avoid;
        border: 1px solid #ccc;
    }
    
    .help-table {
        border: 1px solid #ccc;
    }
    
    .help-table th {
        background: #f0f0f0;
        color: #000;
    }
}
