/* ============================================================
   css-layout-generator / style.css
   Prefix: clg-
   ============================================================ */

.clg-container {
    max-width: 1000px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- Mode Tabs --- */
.clg-mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
}

.clg-mode-tab {
    flex: 1;
    padding: 13px 16px;
    border: 2px solid #007bff;
    background: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    color: #007bff;
    line-height: 1.2;
}

.clg-mode-tab:first-child {
    border-radius: 8px 0 0 8px;
    border-right: 1px solid #007bff;
}

.clg-mode-tab:last-child {
    border-radius: 0 8px 8px 0;
    border-left: 1px solid #007bff;
}

.clg-mode-tab.active {
    background: #007bff;
    color: #fff;
}

.clg-mode-tab:hover:not(.active) {
    background: #e8f0fe;
}

/* --- Section Titles --- */
.clg-section {
    margin-bottom: 24px;
}

.clg-section-title {
    font-size: 14px;
    font-weight: 700;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #007bff;
    display: block;
}

/* --- Presets --- */
.clg-presets {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}

.clg-preset-btn {
    white-space: nowrap;
    padding: 6px 14px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    transition: all 0.2s;
    flex-shrink: 0;
}

.clg-preset-btn:hover {
    border-color: #007bff;
    background: #e8f0fe;
    color: #007bff;
}

/* --- Property Grid --- */
.clg-prop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
}

.clg-prop-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.clg-prop-row.full-width {
    grid-column: 1 / -1;
}

.clg-prop-label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    display: flex;
    align-items: center;
    gap: 4px;
}

.clg-prop-label code {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    color: #333;
}

.clg-tooltip {
    display: inline-flex;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #bbb;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    cursor: help;
    position: relative;
    flex-shrink: 0;
}

.clg-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    padding: 5px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
    max-width: 200px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

.clg-tooltip:hover::after {
    opacity: 1;
}

.clg-select,
.clg-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: #1a1a1a;
}

.clg-select:focus,
.clg-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Mode-specific panes */
.clg-mode-pane {
    display: none;
}

.clg-mode-pane.active {
    display: block;
}

/* --- Item Management --- */
.clg-items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.clg-add-item-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.clg-add-item-btn:hover {
    background: #0056b3;
}

.clg-item-count {
    font-size: 13px;
    color: #666;
}

.clg-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clg-item-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.clg-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.clg-item-header:hover {
    background: #f8f8f8;
}

.clg-item-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #444;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.clg-item-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.clg-item-toggle {
    font-size: 11px;
    color: #888;
    transition: transform 0.2s;
}

.clg-item-card.open .clg-item-toggle {
    transform: rotate(180deg);
}

.clg-item-delete {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: none;
    border: 1px solid #ccc;
    color: #999;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.clg-item-delete:hover {
    background: #d32f2f;
    border-color: #d32f2f;
    color: #fff;
}

.clg-item-detail {
    display: none;
    padding: 12px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

.clg-item-card.open .clg-item-detail {
    display: block;
}

.clg-item-prop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
}

/* --- Preview --- */
.clg-preview-wrap {
    margin-bottom: 24px;
}

.clg-preview-label {
    font-size: 12px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clg-preview-size-hint {
    font-size: 11px;
    color: #aaa;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.clg-preview-outer {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 16px;
    min-height: 200px;
    resize: vertical;
    overflow: auto;
    background: #fafafa;
    box-sizing: border-box;
}

.clg-preview-container {
    width: 100%;
    height: 100%;
    min-height: 168px;
}

.clg-preview-item {
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #333;
    min-height: 60px;
    min-width: 40px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    transition: opacity 0.15s;
}

/* --- Code Output --- */
.clg-code-area {
    margin-top: 32px;
}

.clg-output-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
}

.clg-output-tab {
    padding: 6px 20px;
    border: 1px solid #ccc;
    background: #f9f9f9;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    transition: all 0.2s;
    border-bottom: none;
}

.clg-output-tab.active {
    background: #24292e;
    color: #fff;
    border-color: #24292e;
}

.clg-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #24292e;
    padding: 10px 16px;
    border-top-right-radius: 6px;
    color: #fff;
    gap: 10px;
}

.clg-code-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #c9d1d9;
}

.clg-copy-btn {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 5px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.clg-copy-btn:hover {
    background: #0056b3;
}

.clg-copy-btn.copied {
    background: #28a745;
}

.clg-code-content {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 18px 20px;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    margin: 0;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 80px;
    max-height: 400px;
    overflow-y: auto;
}

/* Syntax highlight */
.clg-hl-prop {
    color: #89b4fa;
}

.clg-hl-val {
    color: #a6e3a1;
}

.clg-hl-tag {
    color: #cba6f7;
}

.clg-hl-attr {
    color: #89dceb;
}

.clg-hl-str {
    color: #a6e3a1;
}

.clg-hl-punc {
    color: #cdd6f4;
}

.clg-hl-sel {
    color: #f38ba8;
}

/* --- Responsive --- */
@media (max-width: 480px) {

    .clg-prop-grid,
    .clg-item-prop-grid {
        grid-template-columns: 1fr;
    }

    .clg-code-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}