/* Layout - Container, grid, flexbox */

/* Compact Header */
.compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 8px;
    border-bottom: 2px solid #da7756;
    margin-bottom: 4px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 1.4rem;
    color: #2d3748;
    font-weight: 700;
    margin: 0;
}

.tagline {
    font-size: 0.8rem;
    color: #718096;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-start-inline {
    font-size: 0.9rem;
    color: #4a5568;
    white-space: nowrap;
}

.quick-start-inline code {
    background: #2d3748;
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-family: 'Consolas', monospace;
}

.readme-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.readme-link:hover {
    text-decoration: underline;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    flex-wrap: wrap;
    gap: 4px;
}

.section-header h2 {
    font-size: 1rem;
    color: #2d3748;
    font-weight: 600;
    margin: 0;
}

.section-header h2 span {
    font-weight: 400;
    color: #64748b;
    font-size: 0.85rem;
}

/* Top Row - Platform Config + Presets + Profiles */
.top-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-bottom: 6px;
}

.platform-config {
    background: #fef7f4;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #f0c8b8;
}

.config-row {
    display: flex;
    gap: 6px;
}

.config-row .selector-group {
    flex: 1;
}

.platform-config {
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 6px;
}

.platform-config h2 {
    color: #2d3748;
    margin-bottom: 6px;
    font-size: 1.2rem;
    font-weight: 600;
    border-bottom: 1px solid #667eea;
    padding-bottom: 4px;
}

/* Main Content Grid */
main {
    display: grid;
    gap: 6px;
}

.command-tools-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.command-tools-wrapper .command-preview {
    min-width: 0;
}

.command-tools-wrapper .tool-categories {
    min-width: 0;
}

main section {
    background: white;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* Preset Selector Layout */
.preset-selector {
    background: #f4f9fc;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #b8d8e8;
}

.preset-header {
    margin-bottom: 2px;
}

.preset-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 8px;
}

/* Profile Management Layout */
.top-row .profile-management {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fafbfc;
    border: 1px solid #e2e8f0;
    padding: 6px;
    border-radius: 6px;
}

.top-row .section-header {
    margin-bottom: 2px;
}

.top-row .profile-management h2 {
    font-size: 0.95rem;
    margin: 0;
    color: #2d3748;
    border-bottom: 2px solid #da7756;
    padding-bottom: 4px;
}

.profile-controls, .level-selector {
    container-type: inline-size;
    min-width: 0;
    max-width: 100%;
}

.profile-actions {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
    margin-top: 4px;
    justify-content: flex-start;
}

.default-display {
    font-size: 0.75rem;
    color: #64748b;
    margin-left: auto;
}

/* Tool Categories - Dynamic sizing */
.categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category {
    background: #fafafa;
    border-radius: 4px;
    padding: 4px 6px;
    border: 1px solid #e0e0e0;
    overflow: visible;
    display: inline-flex;
    flex-direction: column;
    width: fit-content;
}

/* Categories with fewer tools get smaller */
.category.small {
}

.category.medium {
}

.category.large {
}

.category h3 {
    color: white;
    background: #667eea;
    margin-bottom: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: block !important;
    width: fit-content;
    text-align: left;
    padding: 2px 6px;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    border-radius: 3px;
}

/* Command Section */
.command-tools-wrapper {
    display: grid;
    grid-template-columns: minmax(400px, 1fr) minmax(500px, 1.5fr);
    gap: 8px;
}

.command-preview {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tool-categories {
    min-width: 0;
}

/* Code block - keep fixed width and size */
.command-preview .code-container {
    width: 100%;
    flex-shrink: 0;
}

/* Explanation panel - flows naturally in flex container */
.command-preview {
    display: flex;
    flex-direction: column;
}

#command-explanation {
    width: var(--explanation-width, 100%);
    margin-top: 0;
    background: white;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.command-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.command-header-left h2 {
    margin: 0;
}

.command-header-left .beginner-hint {
    font-size: 0.7rem;
    color: #718096;
    margin: 0;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    border-radius: 3px;
    padding: 4px 8px;
    white-space: nowrap;
    width: fit-content;
}

.command-explain-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Tool Categories */
.tool-categories {
    display: block;
}

.tool-categories h2 {
    margin-bottom: 6px;
}

/* Tools & Flags Wrapper - flex container for all categories */
.tools-flags-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}

.tools-section, .flags-section {
    display: contents;
}

.tools-section > h3, .flags-section > h3 {
    display: none !important;
}

/* Containers use display:contents so categories flow in wrapper */
#tools-container, #flags-container {
    display: contents;
}

/* Tool headers - blue */
.tools-section .category h3 {
    background: #667eea;
}

/* Flag headers - orange/red */
.flags-section .category h3 {
    background: #e67e22;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.modal-content h3 {
    margin: 0 0 12px 0;
    color: #2d3748;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f56565;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
}

/* Quick Reference - Always visible, compact */
.quick-reference {
    display: none;
    background: #f0f9ff;
    border-radius: 6px;
    border: 1px solid #bae6fd;
    padding: 12px;
}

.quick-reference h3 {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: #0369a1;
}

.reference-content {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    font-size: 0.8rem;
    color: #4a5568;
}

.reference-content ol {
    margin: 0 0 16px 20px;
    color: #4a5568;
}

.reference-content li {
    padding: 4px 0;
}

.reference-content p {
    color: #4a5568;
    font-size: 0.9rem;
    margin: 0;
}

.reference-content code {
    background: #2d3748;
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .level-buttons {
        grid-template-columns: 1fr;
    }

    .tool-group {
        grid-template-columns: 1fr;
    }

    .profile-controls {
        grid-template-columns: 1fr;
    }

    #command-output {
        padding-right: 20px;
    }

    .copy-btn {
        position: static;
        margin-top: 10px;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .category {
        padding: 15px;
    }

    section {
        padding: 20px 15px;
    }

    .tool-group label {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
}
