/* =============================================
   GitHub Profile README Generator — styles.css
   GitHub dark palette
   ============================================= */

/* ── Custom Properties ── */
:root {
    --primary: #238636;
    --primary-hover: #2ea043;
    --secondary: #58A6FF;
    --accent: #F78166;
    --bg: #0D1117;
    --bg-surface: #161B22;
    --bg-panel: #0D1117;
    --border: rgba(48, 54, 61, 0.9);
    --border-light: rgba(48, 54, 61, 0.5);
    --text: #E6EDF3;
    --text-muted: #8B949E;
    --text-link: #58A6FF;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --header-h: 56px;
}

/* ── Reset ── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ── Header ── */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
}

.logo-icon {
    font-size: 1.3rem;
}

.logo-text {
    color: var(--text);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ── Button ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: rgba(35, 134, 54, 0.5);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 12px rgba(35, 134, 54, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-outline:hover {
    color: var(--text);
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
}

.full-width {
    width: 100%;
    justify-content: center;
}

/* ── Main Layout ── */
.app-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr 360px;
    height: calc(100vh - var(--header-h));
    max-width: 100%;
    overflow: hidden;
}

/* ── Panels ── */
.builder-panel,
.sections-panel,
.preview-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.builder-panel,
.preview-panel {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
}

.preview-panel {
    border-right: none;
    border-left: 1px solid var(--border);
}

.builder-panel {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(48, 54, 61, 0.8) transparent;
}

.builder-panel::-webkit-scrollbar {
    width: 4px;
}

.builder-panel::-webkit-scrollbar-thumb {
    background: rgba(48, 54, 61, 0.8);
    border-radius: 2px;
}

/* ── Panel Sections ── */
.panel-section {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.panel-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ── Template Grid ── */
.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.template-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-card:hover {
    border-color: var(--secondary);
    color: var(--text);
    background: rgba(88, 166, 255, 0.08);
}

.template-preview {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: pre-line;
    line-height: 1.4;
    text-align: left;
}

/* ── Section Library ── */
.section-library {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lib-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    text-align: left;
    transition: all var(--transition);
    width: 100%;
}

.lib-item:hover {
    background: rgba(88, 166, 255, 0.08);
    border-color: rgba(88, 166, 255, 0.2);
}

.lib-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.lib-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lib-info strong {
    font-size: 0.85rem;
    font-weight: 600;
}

.lib-info span {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ── Badge Generator ── */
.badge-gen {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.input-field {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 8px 12px;
    width: 100%;
    transition: border-color var(--transition);
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:focus {
    outline: none;
    border-color: var(--secondary);
}

.select-field {
    appearance: none;
    cursor: pointer;
}

.badge-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
}

.badge-img-wrap {
    position: relative;
    cursor: pointer;
}

.badge-img-wrap:hover::after {
    content: '✕';
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 16px;
    text-align: center;
}

/* ── Sections Panel ── */
.sections-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.sections-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sections-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sections-list::-webkit-scrollbar {
    width: 4px;
}

.sections-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* ── Empty State ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
}

/* ── Section Card ── */
.section-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 14px 14px 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: all var(--transition);
    animation: slideIn 0.25s ease-out;
    position: relative;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.section-card:hover {
    border-color: var(--secondary);
    background: rgba(88, 166, 255, 0.05);
}

.section-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.section-card.drag-over {
    border-color: var(--primary);
    background: rgba(35, 134, 54, 0.08);
}

.drag-handle {
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: grab;
    flex-shrink: 0;
}

.section-card-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.section-card-info {
    flex: 1;
    min-width: 0;
}

.section-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-card-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.section-card-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.82rem;
    transition: all var(--transition);
    line-height: 1;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.icon-btn.delete:hover {
    color: var(--accent);
    background: rgba(247, 129, 102, 0.1);
}

/* ── Preview Panel ── */
.preview-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    background: var(--bg-surface);
}

.preview-header .panel-title {
    margin-bottom: 0;
}

.preview-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.preview-tab {
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.preview-tab.active {
    background: var(--secondary);
    color: #fff;
}

.preview-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.preview-pane {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.preview-pane::-webkit-scrollbar {
    width: 4px;
}

.preview-pane::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.preview-pane.active {
    display: block;
}

.preview-pane[hidden] {
    display: none;
}

.placeholder-msg {
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
    padding-top: 40px;
}

/* ── Rendered Markdown ── */
.rendered-content h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.rendered-content h2 {
    font-size: 1.1rem;
    margin-bottom: 6px;
    margin-top: 20px;
    color: var(--text);
}

.rendered-content h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--text);
}

.rendered-content p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 10px;
}

.rendered-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 6px 0;
}

.rendered-content a {
    color: var(--secondary);
    text-decoration: none;
}

.rendered-content a:hover {
    text-decoration: underline;
}

.rendered-content ul {
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.rendered-content li {
    margin-bottom: 4px;
}

.rendered-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.rendered-content code {
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

.section-rendered {
    margin-bottom: 20px;
}

/* ── Raw Output ── */
.raw-output {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    background: transparent;
}

.copy-bar {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

.modal-overlay[hidden] {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.glass {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.modal-card {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(16px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ── Form Groups ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    padding: 10px 12px;
    width: 100%;
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--secondary);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
    background: transparent;
    color: var(--text-muted);
}

.checkbox-pill:hover {
    border-color: var(--secondary);
    color: var(--text);
}

.checkbox-pill input {
    display: none;
}

.checkbox-pill.checked {
    background: rgba(88, 166, 255, 0.15);
    border-color: var(--secondary);
    color: var(--text);
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 0.88rem;
    color: var(--text);
    z-index: 999;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 300px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .app-layout {
        grid-template-columns: 240px 1fr 300px;
    }
}

@media (max-width: 860px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
        overflow: auto;
    }

    .builder-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 60vh;
    }

    .sections-panel {
        min-height: 300px;
    }

    .preview-panel {
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 500px) {
    .logo-text {
        display: none;
    }

    .header-actions .btn-outline {
        display: none;
    }
}