/* Integration with the Dashboard styling for the Commands Page */

.commands-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

#page-commands {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0;
    margin: 0;
}

.commands-page .floating-header {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    min-height: 72px;
    overflow: hidden;
}

.commands-page .brand-wrapper {
    gap: 0.75rem;
    min-width: 0;
}

.commands-page .status-badge-slot {
    width: 150px;
    flex: 0 0 150px;
}

.commands-page .nav-links {
    display: flex;
    justify-content: center;
    min-width: 0;
    gap: 0.6rem;
    flex-wrap: nowrap;
    overflow: hidden;
}

.commands-page .nav-links .nav-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 0;
    white-space: nowrap;
}

.commands-page .nav-item-icon {
    display: none;
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.commands-page .nav-item-icon svg {
    display: block;
    width: 16px;
    height: 16px;
}

.commands-page .nav-item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commands-page .profile-wrapper,
.commands-page .header-auth {
    justify-self: end;
}

.commands-page .header-auth {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.45rem;
    min-width: 140px;
}

/* Visitor auth: wide desktop → text buttons */
.commands-page.commands-visitor .header-auth {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.45rem;
    justify-self: end;
}

.commands-page.commands-visitor .header-auth .nav-item {
    height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.commands-page.commands-visitor .header-auth .nav-item-icon {
    display: inline-flex;
}

/* Wide desktop (>1100px): keep text buttons fixed to right */
@media (min-width: 1101px) {
    .commands-page.commands-visitor .header-auth {
        grid-column: -1;
        margin-left: auto;
    }
}

/* Shrinking desktop (851–1100px): icon-only */
@media (min-width: 851px) and (max-width: 1100px) {
    .commands-page.commands-visitor .header-auth .nav-item {
        width: 40px;
        min-width: 40px;
        padding: 0;
        justify-content: center;
    }

    .commands-page.commands-visitor .header-auth .nav-item-label {
        display: none;
    }
}

/* Mobile (≤850px): nav-toggle aparece, botões entram no menu mobile */
@media (max-width: 850px) {
    .commands-page.commands-visitor .header-auth {
        display: none !important;
    }
}

@media (min-width: 851px) {
    .commands-page.commands-visitor .floating-header {
        position: relative;
    }

    .commands-page.commands-visitor #header-profile,
    .commands-page.commands-visitor .profile-wrapper {
        display: none !important;
    }

    .commands-page.commands-visitor .nav-links {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: max-content;
        z-index: 1;
    }

    .commands-page.commands-visitor .header-auth {
        position: relative;
        z-index: 2;
    }
}

.commands-page.commands-visitor #header-profile,
.commands-page.commands-visitor .profile-wrapper,
.commands-page.commands-visitor #mobile-header-profile {
    display: none !important;
}

@media (min-width: 851px) {
    .commands-page.commands-authenticated .floating-header {
        position: relative;
    }

    .commands-page.commands-authenticated .nav-links {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: max-content;
        z-index: 1;
    }

    .commands-page.commands-authenticated .profile-wrapper {
        grid-column: 4 / 5;
        justify-self: end;
        margin-left: auto;
        position: relative;
        z-index: 2;
    }
}

@media (min-width: 851px) and (max-width: 1180px) {
    .commands-page .floating-header {
        position: relative;
    }

    .commands-page .profile-wrapper,
    .commands-page .header-auth {
        grid-column: -1;
        justify-self: end;
        margin-left: auto;
        position: relative;
        z-index: 2;
    }

    .commands-page .status-badge-slot {
        width: 122px;
        flex-basis: 122px;
    }

    .commands-page .nav-links {
        gap: 0.35rem;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        justify-content: center;
        width: max-content;
        z-index: 1;
    }

    .commands-page .nav-links .nav-item {
        width: 40px;
        min-width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 12px;
    }

    .commands-page .nav-item-icon {
        display: inline-flex;
    }

    .commands-page .nav-item-label {
        display: none;
    }
}

@media (min-width: 851px) and (max-width: 1040px) {
    .commands-page .floating-header {
        gap: 0.55rem;
        padding-inline: 14px;
    }

    .commands-page .status-badge-slot {
        width: 104px;
        flex-basis: 104px;
    }

    .commands-page .header-auth {
        gap: 0.35rem;
        min-width: 0;
    }
}

@media (max-width: 850px) {
    .commands-page .nav-links {
        display: none;
    }

    .commands-page .header-auth {
        display: none;
    }
}

.commands-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #fff;
    border: 1px solid var(--color-border-muted);
    border-radius: 16px;
    padding: 1rem 1rem 1.1rem;
}

.commands-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.55rem;
    width: 100%;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 38px;
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(139, 102, 85, 0.2);
    background: #ffffff;
    color: var(--color-brown-accent);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-chip:hover {
    background: #faf7f4;
    border-color: rgba(139, 102, 85, 0.35);
}

.category-chip.active {
    background: #f3e9e2;
    border-color: rgba(139, 102, 85, 0.42);
    color: #5f4438;
    box-shadow: inset 0 0 0 1px rgba(139, 102, 85, 0.08);
}

.commands-tabs-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: var(--color-bg-soft);
    padding: 0.25rem;
    border-radius: 12px;
}

.commands-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 0.6rem 1.2rem;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.commands-tab svg {
    width: 15px;
    height: 15px;
}

.commands-tab:hover {
    color: var(--color-text-dark);
}

.commands-tab.active {
    background: #fff;
    color: var(--color-brown-accent);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.toolbar-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    width: 100%;
    margin-top: 1rem;
    border-top: 1px solid var(--color-border-muted);
    padding-top: 1rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.toolbar-search-box {
    flex: 1 1 auto;
    max-width: none;
}

.count-badge {
    background: var(--color-bg-light);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-weight: 500;
    font-size: 0.85rem;
    border: 1px solid var(--color-border-muted);
}

/* Sections */

.commands-section {
    background: var(--color-bg-light);
    border: 1px solid var(--color-border-muted);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.commands-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border-muted);
    background: #fff;
}

.section-head h2 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--color-text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-head-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.section-toggle-btn {
    border: 1px solid var(--color-border-muted);
    background: #fff;
    color: var(--color-text-muted);
    border-radius: 8px;
    padding: 0.3rem 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

.section-toggle-btn:hover {
    color: var(--color-text-dark);
    border-color: #d1c2b7;
    background: #faf7f4;
}

.section-toggle-btn svg {
    width: 14px;
    height: 14px;
}

.commands-section.collapsed .section-notes,
.commands-section.collapsed .command-grid {
    display: none;
}

.section-count {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    background: var(--color-bg-soft);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

.section-notes {
    padding: 1rem 1.5rem;
    background: #fafaf9;
    border-bottom: 1px solid var(--color-border-muted);
    color: var(--color-text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Commands Grid */

.command-grid {
    padding: 1.5rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: stretch;
}

.command-card {
    background: #fff;
    border: 1px solid var(--color-border-muted);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.2s ease;
    height: 100%;
}

.command-card:hover {
    border-color: #d1d5db; /* slightly darker border */
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.command-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.command-top code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-dark);
    background: var(--color-bg-soft);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    word-break: break-word;
    border: 1px solid var(--color-border-muted);
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--color-border-muted);
    color: var(--color-text-muted);
    border-radius: 6px;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-btn:hover {
    background: var(--color-bg-light);
    color: var(--color-text-dark);
}

.command-desc {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    flex: 1 1 auto;
}

.command-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    background: #fafaf9;
    border-radius: 12px;
    border: 1px dashed var(--color-border-muted);
}

/* Toast override */
.toast {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    background: var(--color-text-dark);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .commands-page .floating-header {
        grid-template-columns: auto auto auto;
    }

    .commands-page .status-badge-slot {
        display: none;
    }

    .commands-page .header-auth {
        display: none;
    }

    .commands-toolbar {
        margin-inline: 0;
        padding: 0.95rem;
    }
    .commands-tabs-container {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
    }
    .toolbar-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .toolbar-search-box {
        width: 100%;
    }

    .commands-categories {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}


.search-box { position: relative; width: 100%; max-width: 400px; }
.search-box i,
.search-box svg { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); width: 18px; height: 18px; pointer-events: none; }
.search-box input { width: 100%; padding: 0.75rem 1rem 0.75rem 2.75rem; border: 1px solid var(--color-border-muted); border-radius: 12px; background: #fff; font-family: inherit; font-size: 0.95rem; color: var(--color-text-dark); transition: all 0.2s ease; }
.search-box input:focus { outline: none; border-color: var(--color-brown-accent); box-shadow: 0 0 0 3px rgba(139, 102, 85, 0.1); }

/* ─── Permission Badges ─── */
.perm-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.55rem;
    border-radius: 99px;
    border: 1px solid transparent;
    flex-shrink: 0;
}
.perm-badge.publico  { background: #dcfce7; color: #16a34a; border-color: #bbf7d0; }
.perm-badge.admin    { background: #fef3c7; color: #d97706; border-color: #fde68a; }
.perm-badge.dono     { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

/* ─── Guide Button ─── */
.guide-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--color-brown-accent);
    background: rgba(139, 102, 85, 0.07);
    border: 1px solid rgba(139, 102, 85, 0.2);
    border-radius: 8px;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.guide-btn:hover {
    background: rgba(139, 102, 85, 0.14);
    border-color: rgba(139, 102, 85, 0.35);
}
.guide-btn svg { width: 13px; height: 13px; }

.alias-btn {
    color: #6f5648;
    background: #f8f3ef;
    border-color: #dfcdbf;
}

.alias-btn:hover {
    background: #f3e8df;
    border-color: #cdb4a2;
}

/* ─── Command card meta row ─── */
.command-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-top: 1px solid #f1ece7;
    padding-top: 0.7rem;
    margin-top: auto;
}

.meta-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

/* ─── Guide Modal ─── */
.guide-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.guide-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}
.guide-modal {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 560px;
    max-height: calc(100dvh - 32px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
}
.guide-modal-overlay.open .guide-modal {
    transform: translateY(0) scale(1);
}
.guide-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border-muted);
    background: #fafaf9;
    flex-shrink: 0;
}
.guide-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.guide-modal-icon {
    width: 20px;
    height: 20px;
    color: var(--color-brown-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.guide-modal-icon svg {
    width: 20px;
    height: 20px;
}
.guide-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-dark);
}
.guide-modal-close {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}
.guide-modal-close:hover {
    background: var(--color-bg-soft);
    color: var(--color-text-dark);
}
.guide-modal-body {
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Guide Sections */
.guide-desc {
    font-size: 0.92rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    margin: 0;
    padding: 0.85rem 1rem;
    background: var(--color-bg-soft);
    border-radius: 10px;
    border-left: 3px solid var(--color-brown-accent);
}
.guide-steps-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem;
}
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.guide-step {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}
.guide-step-num {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--color-brown-accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.guide-step-content strong {
    display: block;
    font-size: 0.88rem;
    color: var(--color-text-dark);
    margin-bottom: 0.2rem;
}
.guide-step-content span {
    font-size: 0.84rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}
.guide-step-content code {
    font-size: 0.8rem;
    background: var(--color-bg-soft);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    border: 1px solid var(--color-border-muted);
}
.guide-tips {
    background: #fffbf5;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 0.85rem 1rem;
}
.guide-tips-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #d97706;
    margin: 0 0 0.5rem;
}
.guide-tips ul {
    margin: 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.guide-tips li {
    font-size: 0.84rem;
    color: #92400e;
    line-height: 1.4;
}

.aliases-list ul {
    margin: 0;
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    list-style: none;
}

.aliases-list li {
    font-size: 0.9rem;
    color: #333;
}

.aliases-list code {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 0.3rem 0.6rem;
    font-family: 'Courier New', monospace;
    color: #d97706;
    display: inline-block;
}

/* ─── Section Icons ─── */
.section-icon {
    width: 18px;
    height: 18px;
    color: var(--color-brown-accent);
    flex-shrink: 0;
}

/* ─── Highlight matching text ─── */
.search-highlight {
    background: rgba(139, 102, 85, 0.15);
    border-radius: 3px;
    padding: 0 2px;
}

.empty-state-icon {
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #947565;
}

.empty-state-icon svg {
    width: 28px;
    height: 28px;
}

/* ─── Tab counter badge ─── */
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--color-bg-soft);
    color: var(--color-text-muted);
    padding: 0 5px;
    margin-left: 4px;
    transition: all 0.2s;
}
.commands-tab.active .tab-count {
    background: rgba(139, 102, 85, 0.1);
    color: var(--color-brown-accent);
}

@media (max-width: 600px) {
    .guide-modal {
        width: min(560px, calc(100vw - 32px));
        max-height: calc(100dvh - 32px);
        border-radius: 16px;
        margin: 0 auto;
    }

    .guide-modal-overlay {
        align-items: center;
        justify-content: center;
        padding: 16px;
    }
}
