/* ========================================
   LIBRARY LAYOUT
======================================== */

.library {
    min-height: 100vh;
    display: flex;
}


/* ========================================
   SIDEBAR
======================================== */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;

    background: var(--surface);
    border-right: 1px solid var(--border);

    display: flex;
    flex-direction: column;

    z-index: 10;
}


/* BRAND */

.brand {
    padding: 30px 25px;
    border-bottom: 1px solid var(--border);
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 3px;
}

.brand-subtitle {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 10px;
    letter-spacing: 2px;
}


/* NAV */

.sidebar-nav {
    padding: 25px 15px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 30px;
}

.nav-title {
    padding: 0 10px;
    margin-bottom: 8px;

    color: var(--text-light);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.nav-item {
    width: 100%;
    border: 0;
    background: transparent;

    padding: 10px;

    display: flex;
    align-items: center;
    gap: 10px;

    border-radius: var(--radius-small);

    color: var(--text-muted);
    text-align: left;

    transition: 0.2s ease;
}

.nav-item span {
    width: 18px;
    text-align: center;
}

.nav-item:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}


/* SIDEBAR FOOTER */

.sidebar-footer {
    margin-top: auto;
    padding: 20px 25px;

    border-top: 1px solid var(--border);

    font-size: 12px;
    font-weight: 600;
}

.sidebar-footer span {
    display: block;
    margin-top: 3px;

    color: var(--text-light);
    font-size: 10px;
    font-weight: 400;
}


/* ========================================
   MAIN
======================================== */

.main {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
}


/* ========================================
   TOPBAR
======================================== */

.topbar {
    min-height: 90px;

    padding: 20px 40px;

    background: var(--surface);
    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 30px;
}

.page-title h1 {
    margin-bottom: 2px;
    font-size: 20px;
}

.page-title p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* SEARCH */

.search {
    height: 40px;

    padding: 0 12px;

    display: flex;
    align-items: center;
    gap: 8px;

    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}

.search span {
    color: var(--text-light);
    font-size: 18px;
}

.search input {
    width: 200px;

    border: 0;
    outline: none;
    background: transparent;

    color: var(--text);
}

.search input::placeholder {
    color: var(--text-light);
}


/* THEME BUTTON */

.theme-button {
    height: 40px;

    padding: 0 16px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface);
    color: var(--text);

    transition: 0.2s ease;
}

.theme-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}


/* ========================================
   CONTENT
======================================== */

.content {
    max-width: var(--container);
    margin: auto;
    padding: 45px 40px 80px;
}


/* ========================================
   WELCOME
======================================== */

.welcome {
    padding: 50px;

    border-radius: var(--radius);

    background: var(--surface);

    box-shadow: var(--shadow);
}

.eyebrow {
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
}

.welcome h2 {
    margin: 12px 0 15px;

    font-family: var(--font-heading);
    font-size: clamp(36px, 5vw, 62px);
    font-weight: 400;
    line-height: 1.05;
}

.welcome p {
    max-width: 560px;

    margin-bottom: 0;

    color: var(--text-muted);
    font-size: 16px;
}


/* ========================================
   STATS
======================================== */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;

    margin-top: 15px;
}

.stat-card {
    padding: 25px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-label {
    display: block;

    color: var(--text-light);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.stat-card strong {
    display: block;

    margin: 8px 0 2px;

    font-size: 30px;
    font-weight: 500;
}

.stat-description {
    color: var(--text-muted);
    font-size: 12px;
}


/* ========================================
   SECTION HEADINGS
======================================== */

.section-heading {
    margin: 55px 0 20px;
}

.section-heading h3 {
    margin: 5px 0 0;

    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 400;
}


/* ========================================
   CATEGORY GRID
======================================== */

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.category-card {
    padding: 25px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);

    transition: 0.2s ease;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--secondary);
}

.category-icon {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-bottom: 20px;

    background: var(--surface-soft);
    border-radius: var(--radius-small);

    color: var(--primary);
    font-size: 20px;
}

.category-card h4 {
    margin-bottom: 5px;
    font-size: 16px;
}

.category-card p {
    min-height: 48px;

    margin-bottom: 15px;

    color: var(--text-muted);
    font-size: 13px;
}

.category-card span {
    color: var(--text-light);
    font-size: 11px;
}


/* ========================================
   MOBILE
======================================== */

@media (max-width: 900px) {

    :root {
        --sidebar-width: 210px;
    }

    .topbar {
        padding: 20px;
    }

    .content {
        padding: 30px 20px 60px;
    }

    .welcome {
        padding: 35px;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }

}


@media (max-width: 650px) {

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;

        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .library {
        display: block;
    }

    .sidebar-nav {
        display: none;
    }

    .sidebar-footer {
        display: none;
    }

    .main {
        width: 100%;
        margin-left: 0;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
    }

    .search {
        flex: 1;
    }

    .search input {
        width: 100%;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }

}


/* ========================================
   THEME PANEL
======================================== */

.theme-panel {
    position: fixed;

    top: 0;
    right: -380px;

    width: 380px;
    height: 100vh;

    background: var(--surface);

    border-left: 1px solid var(--border);

    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.08);

    z-index: 100;

    display: flex;
    flex-direction: column;

    transition: right 0.3s ease;
}

.theme-panel.open {
    right: 0;
}


/* HEADER */

.theme-panel-header {
    padding: 25px;

    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.theme-panel-header h3 {
    margin: 5px 0 0;

    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 400;
}

.theme-close {
    width: 35px;
    height: 35px;

    border: 0;

    background: var(--surface-soft);

    border-radius: 50%;

    color: var(--text);

    font-size: 22px;
}


/* CONTENT */

.theme-panel-content {
    padding: 25px;

    overflow-y: auto;
}


/* GROUP */

.theme-group {
    padding-bottom: 25px;
    margin-bottom: 25px;

    border-bottom: 1px solid var(--border);
}

.theme-group-title {
    margin-bottom: 15px;

    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}


/* COLOUR CONTROL */

.colour-control {
    margin-bottom: 12px;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.colour-control label {
    color: var(--text-muted);
    font-size: 13px;
}

.colour-control input {
    width: 45px;
    height: 30px;

    padding: 0;

    border: 1px solid var(--border);
    border-radius: 5px;

    background: transparent;

    cursor: pointer;
}


/* SELECT */

.select-label {
    display: block;

    margin-bottom: 6px;

    color: var(--text-muted);
    font-size: 12px;
}

.theme-group select {
    width: 100%;

    height: 42px;

    padding: 0 10px;

    margin-bottom: 15px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface);

    color: var(--text);

    outline: none;
}


/* RESET */

.reset-theme {
    width: 100%;
    height: 42px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface);

    color: var(--text);

    cursor: pointer;
}

.reset-theme:hover {
    border-color: var(--primary);
    color: var(--primary);
}


/* MOBILE */

@media (max-width: 500px) {

    .theme-panel {
        width: 100%;
        right: -100%;
    }

}


/* ========================================
   THEME NAME INPUT
======================================== */

.theme-name-input {
    width: 100%;
    height: 42px;

    padding: 0 12px;

    margin-bottom: 10px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    background: var(--surface);

    color: var(--text);

    outline: none;
}

.theme-name-input:focus {
    border-color: var(--primary);
}


/* ========================================
   SAVE BUTTON
======================================== */

.save-theme {
    width: 100%;
    height: 42px;

    border: 0;
    border-radius: var(--radius-small);

    background: var(--primary);
    color: white;

    font-weight: 600;

    cursor: pointer;
}

.save-theme:hover {
    opacity: 0.9;
}


/* ========================================
   SAVED THEMES
======================================== */

.saved-themes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.no-themes {
    padding: 12px;

    background: var(--surface-soft);

    border-radius: var(--radius-small);

    color: var(--text-light);

    font-size: 12px;
}


.saved-theme {
    padding: 10px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;
}


.saved-theme-info {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 10px;
}

.saved-theme-info strong {
    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 12px;
}


/* COLOUR PREVIEW */

.theme-colour-preview {
    display: flex;
}

.theme-colour-preview span {
    width: 18px;
    height: 18px;

    border: 2px solid var(--surface);

    border-radius: 50%;

    margin-left: -4px;
}

.theme-colour-preview span:first-child {
    margin-left: 0;
}


/* ACTIONS */

.saved-theme-actions {
    display: flex;
    gap: 4px;
}

.load-theme,
.delete-theme {
    height: 30px;

    border: 1px solid var(--border);
    border-radius: 4px;

    background: var(--surface);

    color: var(--text);

    font-size: 11px;
}

.load-theme {
    padding: 0 8px;
}

.delete-theme {
    width: 30px;

    font-size: 16px;
}

.load-theme:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.delete-theme:hover {
    border-color: #b44;
    color: #b44;
}

/* ========================================
   COMPONENT LIBRARY
======================================== */

.component-library-section {
    margin-top: 50px;
}

#componentList {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}


/* ========================================
   COMPONENT CARD
======================================== */

.component-preview {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}


/* ========================================
   PREVIEW HEADER
======================================== */

.preview-header {
    min-height: 52px;
    padding: 10px 14px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid var(--border);
}

.preview-header strong {
    display: block;
    font-size: 12px;
    line-height: 1.3;
}

.preview-header span {
    display: block;
    margin-top: 2px;

    color: var(--text-light);
    font-size: 10px;
}

.preview-toggle {
    padding: 5px 9px;

    border: 1px solid var(--border);
    border-radius: 5px;

    background: var(--surface);
    color: var(--text);

    font-size: 10px;
}


/* ========================================
   COMPONENT PREVIEW
======================================== */

.dynamic-component-preview {
    height: 300px;
    overflow: hidden;
}

.dynamic-component-preview > * {
    min-height: 100% !important;
}


/* Scale large wedding components down
   so they fit nicely inside cards */

.dynamic-component-preview .hero-component {
    min-height: 300px;
    padding: 30px 20px;
}

.dynamic-component-preview .hero-component h1 {
    font-size: clamp(35px, 4vw, 60px);
}

.dynamic-component-preview .hero-component p {
    font-size: 14px;
    margin-bottom: 20px;
}

.dynamic-component-preview .hero-component .hero-eyebrow {
    font-size: 9px;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.dynamic-component-preview .hero-split {
    min-height: 300px;
}

.dynamic-component-preview .hero-split-content {
    padding: 25px;
}

.dynamic-component-preview .hero-split h1 {
    font-size: clamp(35px, 4vw, 55px);
}

.dynamic-component-preview .hero-split-image {
    min-height: 300px;
}


/* ========================================
   CODE AREA
======================================== */

.code-area {
    border-top: 1px solid var(--border);
    background: #1c1c1c;
    color: #f5f5f5;
}


/* Tiny code header */

.code-header {
    min-height: 34px;
    padding: 6px 10px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #333;
}

.code-header strong {
    font-size: 9px;
    letter-spacing: 1px;
}

.copy-code {
    padding: 4px 7px;

    border: 1px solid #555;
    border-radius: 4px;

    background: transparent;
    color: white;

    font-size: 9px;
}


/* Tiny HTML/CSS snippet */

.code-area pre {
    height: 55px;

    margin: 0;
    padding: 8px 10px;

    overflow: hidden;

    font-family: Consolas, monospace;
    font-size: 8px;
    line-height: 1.35;

    white-space: pre;
}


/* ========================================
   TABLET
======================================== */

@media (max-width: 1100px) {

    #componentList {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}


/* ========================================
   MOBILE
======================================== */

@media (max-width: 700px) {

    #componentList {
        grid-template-columns: 1fr;
    }

    .dynamic-component-preview {
        height: 350px;
    }

}


/* ========================================
   PREVIEW
======================================== */

.component-preview {

    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow);
}


.preview-header {

    min-height: 60px;

    padding: 12px 18px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom: 1px solid var(--border);
}


.preview-header strong {

    display: block;

    font-size: 13px;
}


.preview-header span {

    color: var(--text-light);

    font-size: 11px;
}


.preview-toggle {

    padding: 7px 12px;

    border: 1px solid var(--border);

    border-radius: 5px;

    background: var(--surface);

    color: var(--text);

    font-size: 11px;
}


/* ========================================
   HERO PREVIEW
======================================== */

.hero-preview {

    overflow: hidden;
}


.hero-preview .hero-component {

    min-height: 650px;
}


/* ========================================
   CODE
======================================== */

.code-area {

    border-top: 1px solid var(--border);

    background: #1c1c1c;

    color: #f5f5f5;
}


.code-header {

    min-height: 50px;

    padding: 10px 15px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom: 1px solid #333;
}


.code-header strong {

    font-size: 11px;

    letter-spacing: 1px;
}


.copy-code {

    padding: 6px 10px;

    border: 1px solid #555;

    border-radius: 4px;

    background: transparent;

    color: white;

    font-size: 11px;
}


.copy-code:hover {

    border-color: var(--primary);
}


.code-area pre {

    margin: 0;

    padding: 20px;

    overflow-x: auto;

    font-family: Consolas, monospace;

    font-size: 12px;

    line-height: 1.7;

    white-space: pre-wrap;
}

/* ========================================
   DYNAMIC COMPONENT LIBRARY
======================================== */

#componentList {
    display: flex;
    flex-direction: column;
    gap: 30px;
}


.dynamic-component-preview {
    overflow: hidden;
}


.component-loading {
    padding: 50px;
    text-align: center;
    color: var(--text-muted);
}


.no-components {
    padding: 70px 30px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}


.no-components strong {
    display: block;
    margin-bottom: 8px;
    font-size: 18px;
}


.no-components span {
    color: var(--text-muted);
    font-size: 14px;
}


.category-card {
    cursor: pointer;
}


.category-card:hover {
    transform: translateY(-3px);
}

/* ========================================
   SEARCH
======================================== */

.search input {
    outline: none;
}


.search:focus-within {
    border-color: var(--primary);
}

/* ========================================
   COMPACT COMPONENT GRID
======================================== */

#componentList {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 20px;
    width: 100%;
}


/* ========================================
   COMPONENT CARD
======================================== */

#componentList .component-preview {
    width: 100%;
    min-width: 0;
    margin: 0;
}


/* ========================================
   COMPACT PREVIEW
======================================== */

#componentList .dynamic-component-preview {
    width: 100%;
    height: 260px;
    overflow: hidden;
}


/* ========================================
   COMPACT HERO
======================================== */

#componentList .hero-component {
    min-height: 260px !important;
    height: 260px;
    padding: 30px 20px !important;
}

#componentList .hero-component h1 {
    font-size: 42px !important;
}

#componentList .hero-component p {
    font-size: 14px;
    margin-bottom: 20px;
}


/* ========================================
   SPLIT HERO
======================================== */

#componentList .hero-split {
    min-height: 260px !important;
    height: 260px;
}

#componentList .hero-split-content {
    padding: 25px !important;
}

#componentList .hero-split h1 {
    font-size: 42px !important;
}

#componentList .hero-split-image {
    min-height: 260px !important;
    height: 260px;
}


/* ========================================
   CODE
======================================== */

#componentList .code-area pre {
    height: 45px;
    max-height: 45px;
    overflow: hidden;

    padding: 6px 10px;

    font-size: 8px;
    line-height: 1.3;
}


/* ========================================
   TABLET
======================================== */

@media (max-width: 1100px) {

    #componentList {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

}


/* ========================================
   MOBILE
======================================== */

@media (max-width: 700px) {

    #componentList {
        grid-template-columns: 1fr !important;
    }

}

/* ========================================
   COMPONENT COPY BUTTONS
======================================== */

#componentList .code-area {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

#componentList .copy-code {
    flex: 1;

    padding: 8px 10px;

    border: 1px solid var(--border);
    border-radius: 5px;

    background: var(--surface);
    color: var(--text);

    font-size: 10px;
    font-weight: 600;
}

#componentList .copy-code:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ========================================
   EXPANDED COMPONENT PREVIEW
======================================== */

#componentList .component-preview.preview-expanded {
    grid-column: 1 / -1;
}

#componentList .component-preview.preview-expanded
.dynamic-component-preview {
    height: 650px;
}

#componentList .component-preview.preview-expanded
.hero-component {
    min-height: 650px !important;
    height: 650px;
}

#componentList .component-preview.preview-expanded
.hero-split {
    min-height: 650px !important;
    height: 650px;
}

#componentList .component-preview.preview-expanded
.hero-split-image {
    min-height: 650px !important;
    height: 650px;
}

/* ========================================
   COMPONENT PREVIEW POSITIONING
======================================== */

#componentList .dynamic-component-preview {
    position: relative;
}


/* ========================================
   NAVIGATION PREVIEW
======================================== */

#componentList .dynamic-component-preview
.wedding-navigation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

#componentList .dynamic-component-preview:has(.wedding-navigation) {
    background:
        linear-gradient(
            rgba(0, 0, 0, 0.25),
            rgba(0, 0, 0, 0.25)
        ),
        url("https://images.unsplash.com/photo-1519225421980-715cb0215aed?auto=format&fit=crop&w=1800&q=80")
        center / cover no-repeat;
}

/* ========================================
   COMPONENT PREVIEW — EXPANDED
======================================== */

#componentList .component-preview.preview-expanded {
    grid-column: 1 / -1;
}

#componentList .component-preview.preview-expanded
.dynamic-component-preview {
    height: 650px;
}


/* Hero */

#componentList .component-preview.preview-expanded
.hero-component {
    min-height: 650px !important;
    height: 650px !important;
}


/* Split Hero */

#componentList .component-preview.preview-expanded
.hero-split {
    min-height: 650px !important;
    height: 650px !important;
}

#componentList .component-preview.preview-expanded
.hero-split-image {
    min-height: 650px !important;
    height: 650px !important;
}

/* ========================================
   NAVIGATION PREVIEW
======================================== */

#componentList .component-preview
.dynamic-component-preview:has(.wedding-navigation) {
    background:
        linear-gradient(
            rgba(0, 0, 0, 0.25),
            rgba(0, 0, 0, 0.25)
        ),
        url("https://images.unsplash.com/photo-1519225421980-715cb0215aed?auto=format&fit=crop&w=1800&q=80")
        center / cover no-repeat;
}

#componentList .component-preview.preview-expanded
.dynamic-component-preview {
    min-height: 650px;
}