/* Main App Grid */
.cmc-app-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    /* Canvas | Sidebar */
    gap: 40px;
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Left: Sticky Canvas */
.cmc-app-left {
    position: relative;
    min-height: 800px;
}

.cmc-canvas-sticky {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#cmcCardCanvas {
    width: 100%;
    max-width: 500px;
    /* Prevent it getting too huge */
    height: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
}

.cmc-size-note {
    margin-top: 15px;
    font-size: 13px;
    color: #666;
    text-align: center;
    line-height: 1.5;
}

/* Right: Tools & Form */
.cmc-app-right {
    background: #fdfdfd;
    border-radius: 12px;
    padding: 0 5px;
    /* Visual spacing */
}

.cmc-app-right h1 {
    font-size: 24px;
    margin: 0 0 20px 0;
    color: #333;
    font-weight: 700;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

/* Accordions */
details.cmc-accordion {
    margin-bottom: 15px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

details.cmc-accordion[open] {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

summary {
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 600;
    color: #444;
    background: #fcfcfc;
    list-style: none;
    /* Hide default triangle */
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

summary::-webkit-details-marker {
    display: none;
}

summary:after {
    content: '+';
    font-size: 18px;
    font-weight: 400;
    color: #888;
}

details[open] summary:after {
    content: '−';
}

details[open] summary {
    border-bottom: 1px solid #eee;
}

.cmc-accordion-content {
    padding: 20px;
}

/* Inputs & Rows */
.cmc-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-end;
    /* Align inputs to bottom so labels don't mess up height */
}

/* When fields are inside a row, remove their bottom margin so they sit tight */
.cmc-row>.cmc-field {
    margin-bottom: 0;
}

.flex-grow {
    flex: 1;
}

.cmc-field {
    margin-bottom: 15px;
}

.cmc-field:last-child {
    margin-bottom: 0;
}

.cmc-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cmc-sublabel {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #888;
    margin: 15px 0 8px;
    text-transform: uppercase;
}

/* Form Elements */
input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Files */
.cmc-file-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7f7f7;
    padding: 10px;
    border-radius: 6px;
}

.button-link {
    background: none;
    border: none;
    color: #d63638;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
}

/* Divider */
.cmc-divider {
    border: 0;
    border-top: 1px solid #eee;
    margin: 20px 0;
}

/* Checkboxes */
.cmc-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.cmc-checkbox-row input {
    margin: 0;
}

.cmc-checkbox-row label {
    cursor: pointer;
    color: #2271b1;
}

.cmc-checkbox-row input {
    margin: 0;
}

.cmc-desc {
    margin-top: 4px;
    margin-left: 26px;
    font-size: 12px;
    color: #888;
}

/* Line 5 Group logic */
.cmc-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cmc-inline-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
    color: #666;
}

/* Action Bar */
.cmc-actions-bar {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
}

.cmc-btn-primary {
    background: #111;
    color: #fff;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.1s, background 0.2s;
}

.cmc-btn-primary:hover {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cmc-status {
    font-weight: 600;
    color: #2271b1;
}

/* Mini Carousel Overrides */
.mini-carousel {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    margin: 0;
}

.mini-carousel-item {
    height: 140px;
    /* Ensure previews have height */
}

/* Responsive */
@media (max-width: 900px) {
    .cmc-app-container {
        grid-template-columns: 1fr;
        /* Stack */
    }

    .cmc-app-left {
        order: 1;
        /* Canvas Second on mobile? Or First? Usually canvas first */
        min-height: auto;
    }

    .cmc-canvas-sticky {
        position: static;
        width: 100%;
        max-width: 100%;
    }

    .cmc-app-right {
        order: 2;
    }
}

/* Old preview styles removed */

/* Margin Indicator */
.cmc-gen-preview.has-margins {
    width: 80%;
    /* Simulate margins */
    margin: 0 auto;
    border: 1px dashed rgba(0, 0, 0, 0.1);
}

/* Footer Indicator */
.cmc-gen-preview.has-white-footer:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20%;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Generated Template Preview (Rich) */
.cmc-gen-preview {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #fff;
    /* Base canvas is white */
    border: 1px solid #ddd;
}

/* The Colored Band */
.cmc-gen-bg {
    position: absolute;
    left: 0;
    right: 0;
    transition: all 0.2s;
    z-index: 1;
}

/* Margins logic */
.cmc-gen-preview.has-margins .cmc-gen-bg {
    left: 10%;
    right: 10%;
}

/* White Footer logic */
.cmc-gen-preview.has-white-footer:after {
    content: '';
    position: absolute;
    /* Overlays the BG */
    bottom: 0;
    left: 0;
    right: 0;
    height: 15%;
    background: #fff;
    z-index: 2;
    border-top: 1px dashed #eee;
}

/* Content Layer */
.cmc-gen-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Text */
.cmc-gen-text {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    /* Ensure readable on light/dark */
}

/* Mock Image */
.cmc-gen-mock-img {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    position: relative;
}

.cmc-gen-mock-img:before,
.cmc-gen-mock-img:after {
    content: '';
    position: absolute;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.cmc-gen-mock-img:before {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(45deg);
    border: none;
    background: linear-gradient(45deg, transparent 48%, rgba(0, 0, 0, 0.1) 50%, transparent 52%);
}

.cmc-gen-mock-img:after {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-45deg);
    border: none;
    background: linear-gradient(-45deg, transparent 48%, rgba(0, 0, 0, 0.1) 50%, transparent 52%);
}

/* Dummy Lines */
.cmc-gen-lines {
    width: 60%;
    height: 3px;
    background: currentColor;
    opacity: 0.6;
    margin-top: 2px;
    border-radius: 2px;
}