/* ===== Layout principal ===== */

.back-link {
    color: #2a9d8f;
    text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

.sw-main {
    display: grid;
    grid-template-columns: minmax(380px, 1fr) 420px;
    gap: 2em;
    width: 100%;
    margin: 0;
    padding: 1.5em 2em 3em;
    box-sizing: border-box;
}

@media (max-width: 1000px) {
    .sw-main { grid-template-columns: 1fr; padding: 1em; gap: 1em; }
    .sw-preview-sticky { position: static !important; }
}

.sw-config, .sw-preview-sticky {
    background: #fff;
    border-radius: 1em;
    padding: 2em 2.2em;
    box-shadow: 0 10px 20px #dbdbdb;
}

.sw-preview-sticky {
    position: sticky;
    top: 1em;
    align-self: start;
    text-align: center;
}

.sw-config h2, .sw-preview-sticky h2 {
    margin: 1.8em 0 1em;
    font-size: 1.1em;
    color: #264653;
    border-bottom: 2px solid #e76f51;
    padding-bottom: 0.4em;
}

.sw-config h2:first-of-type, .sw-preview-sticky h2:first-of-type {
    margin-top: 0;
}

/* ===== Tabs ===== */

.tabs {
    display: flex;
    gap: 0.4em;
    border-bottom: 3px solid #e76f51;
    margin-bottom: 1.8em;
    flex-wrap: wrap;
}

.tab {
    background: #f5f5f5;
    color: #555;
    border: none;
    padding: 0.7em 1.1em;
    border-radius: 0.5em 0.5em 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: background 0.15s, color 0.15s;
}

.tab:hover { background: #e9c46a; color: #264653; }
.tab.active { background: #e76f51; color: #fff; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Form rows ===== */

.tab-content > label {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    font-size: 0.95em;
    color: #555;
    font-weight: 600;
    margin-bottom: 1.1em;
}

.tab-content input[type="text"],
.tab-content input[type="url"],
.tab-content textarea,
.tab-content select {
    padding: 0.75em 1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
    width: 100%;
}

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

.cfg-row {
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
    margin-bottom: 1em;
}
.cfg-row.two > * { flex: 1; min-width: 0; }

.cfg-row label {
    display: flex;
    flex-direction: column;
    gap: 0.4em;
    font-size: 0.9em;
    color: #555;
    font-weight: 600;
}

.cfg-row input[type="color"],
.color-row input[type="color"] {
    height: 44px;
    padding: 0;
    cursor: pointer;
    background: none;
    border: 1px solid #ccc;
    border-radius: 0.4em;
    flex: 1;
}

.cfg-range {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.9em !important;
    font-weight: 500 !important;
    margin-bottom: 1em !important;
}
.cfg-range input[type="range"] { flex: 1; min-width: 0; }
.cfg-range span {
    color: #264653;
    font-size: 0.85em;
    font-family: monospace;
    background: #f5f5f5;
    padding: 0.3em 0.5em;
    border-radius: 0.3em;
    min-width: 56px;
    text-align: right;
}

.cfg-check {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.6em !important;
    font-weight: 500 !important;
    margin-bottom: 0.7em !important;
    cursor: pointer;
}
.cfg-check input { cursor: pointer; }

/* Color with saved button */
.color-with-saved .color-row {
    display: flex;
    gap: 0.4em;
    align-items: stretch;
}
.saved-btn {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 0.4em;
    cursor: pointer;
    font-size: 1.1em;
    padding: 0 0.7em;
    transition: background 0.15s;
}
.saved-btn:hover { background: #e9c46a; }

/* ===== File drop ===== */

.file-drop {
    display: block;
    border: 2px dashed #e76f51;
    border-radius: 0.6em;
    padding: 1.2em;
    text-align: center;
    color: #e76f51;
    cursor: pointer;
    margin-bottom: 1em;
    transition: background 0.15s, border-color 0.15s;
    font-weight: 600;
}
.file-drop:hover, .file-drop.dragover { background: #fff0ec; border-color: #c2503a; }

/* ===== Buttons ===== */

.add-action {
    background: #2a9d8f;
    color: #fff;
    border: none;
    padding: 0.7em 1em;
    border-radius: 0.5em;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 0.5em;
}
.add-action:hover { background: #264653; }

.del-action {
    background: #e76f51;
    color: #fff;
    border: none;
    padding: 0.6em 0.9em;
    border-radius: 0.4em;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    margin-top: 0.5em;
}
.del-action:hover { background: #c2503a; }

.hint {
    color: #888;
    font-size: 0.85em;
    margin: 0 0 1em;
    line-height: 1.4;
}

/* ===== List rows ===== */

.list-row {
    display: grid;
    grid-template-columns: 20px 1fr 1fr 28px;
    align-items: center;
    gap: 0.5em;
    margin-bottom: 0.6em;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 0.5em;
    padding: 0.6em 0.7em;
}

.list-row.link-row {
    grid-template-columns: 20px 36px 1fr 1fr 36px 28px;
}

.list-row.social-row {
    grid-template-columns: 20px 36px 130px 1fr 28px;
}

.drag-handle {
    cursor: grab;
    color: #b8b8b8;
    font-size: 1.1em;
    line-height: 1;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    font-weight: bold;
    letter-spacing: -2px;
    transition: color 0.15s;
}
.drag-handle:hover { color: #264653; }
.drag-handle:active { cursor: grabbing; }

.list-row.link-row .row-subtitle {
    grid-column: 3 / 5;
    grid-row: 2;
}

.list-row .icon-cell {
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}

.list-row .icon-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.list-row input[type="text"], .list-row select {
    padding: 0.5em 0.6em !important;
    font-size: 0.9em !important;
}

.list-row .row-color {
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
    background: none;
    border: 1px solid #ccc;
    border-radius: 0.3em;
}

.list-row .del-row {
    background: #e76f51;
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    line-height: 1;
    padding: 0;
}

/* ===== Phone mockup ===== */

.phone-mockup {
    width: 320px;
    height: 640px;
    background: linear-gradient(135deg, #2a2a30 0%, #1a1a1f 50%, #2a2a30 100%);
    border-radius: 46px;
    padding: 8px;
    margin: 0 auto 1em;
    box-shadow:
        0 24px 50px rgba(0,0,0,0.35),
        0 0 0 1px rgba(255,255,255,0.05) inset;
    position: relative;
    transition: background 0.25s ease;
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><circle cx='16' cy='16' r='12' fill='rgba(0,0,0,0.25)' stroke='rgba(255,255,255,0.9)' stroke-width='2'/><circle cx='16' cy='16' r='3' fill='white'/></svg>") 16 16, pointer;
}

.phone-mockup * { cursor: inherit; }

/* Petits boutons lateraux pour realisme */
.phone-mockup::before,
.phone-mockup::after {
    content: '';
    position: absolute;
    background: #1a1a1f;
    border-radius: 2px;
    pointer-events: none;
}
.phone-mockup::before {
    left: -2px;
    top: 110px;
    width: 3px;
    height: 32px;
    box-shadow: 0 50px 0 #1a1a1f, 0 110px 0 #1a1a1f;
}
.phone-mockup::after {
    right: -2px;
    top: 130px;
    width: 3px;
    height: 56px;
}


.phone-notch::before {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #4a5570 0%, #1a1f2e 60%, #0a0d18 100%);
    box-shadow: inset 0 0 1px rgba(120,160,220,0.5);
}
.phone-notch::after {
    content: '';
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #0a0d18;
    box-shadow: inset 0 0 1px rgba(255,255,255,0.15);
}

.phone-notch {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 110px;
    height: 32px;
    background: #000;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
    z-index: 5;
    pointer-events: none;
}

.phone-screen-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 38px;
    overflow: hidden;
    background: var(--phone-bg, #111);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.6) inset;
    transition: background 0.25s ease;
}

.phone-screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 38px;
    background: transparent;
    display: block;
    visibility: hidden;
    z-index: 1;
    pointer-events: none;
}

.phone-screen.phone-screen-active {
    visibility: visible;
    pointer-events: auto;
    z-index: 2;
}

.preview-controls {
    display: flex;
    justify-content: center;
    gap: 0.5em;
    margin: 0.6em 0 0.4em;
}

.replay-btn {
    background: #2a9d8f;
    color: #fff;
    border: 0;
    padding: 0.5em 1em;
    border-radius: 0.4em;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.replay-btn:hover { background: #264653; }

/* ===== Export ===== */

#htmlOutput {
    width: 100%;
    min-height: 200px;
    padding: 1em;
    background: #264653;
    color: #e9c46a;
    font-family: monospace;
    font-size: 0.8em;
    border: none;
    border-radius: 0.5em;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 0.8em;
}

.export-actions {
    display: flex;
    gap: 0.6em;
    flex-wrap: wrap;
    margin-bottom: 1.5em;
}

.export-actions button {
    background: #e76f51;
    color: #fff;
    border: none;
    padding: 0.75em 1em;
    border-radius: 0.5em;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: background 0.15s;
}
.export-actions button:hover { background: #c2503a; }

/* ===== Background option blocks ===== */

.bg-opt-block { display: none; }
.bg-opt-block.active { display: block; }

/* Sous-titre dans une section */
.sub-h {
    margin: 1.4em 0 0.6em;
    font-size: 0.95em;
    color: #264653;
    font-weight: 700;
    display: flex;
    align-items: baseline;
    gap: 0.5em;
}
.hint-inline {
    font-size: 0.8em;
    color: #888;
    font-weight: 400;
}

/* Grille de miniatures images de fond */
.bg-images-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5em;
    margin: 0.5em 0 1.2em;
}
.bg-image-thumb {
    position: relative;
    aspect-ratio: 1;
    background: #eee center/cover no-repeat;
    border-radius: 0.4em;
    overflow: hidden;
    border: 1px solid #ddd;
    cursor: grab;
}
.bg-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.bg-image-thumb .thumb-del {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    background: rgba(231, 111, 81, 0.92);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95em;
    line-height: 1;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.bg-image-thumb:hover .thumb-del { opacity: 1; }
.bg-image-thumb .thumb-num {
    position: absolute;
    bottom: 3px;
    left: 3px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.7em;
    padding: 1px 5px;
    border-radius: 0.3em;
}

/* Bouton icone custom dans les rows social */
.soc-icon-btn {
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: border-color 0.15s, transform 0.15s;
}
.soc-icon-btn:hover { border-color: #2a9d8f; transform: scale(1.05); }
.soc-icon-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.soc-icon-btn svg {
    width: 28px;
    height: 28px;
}
.soc-icon-btn.has-custom::after {
    content: '✓';
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #2a9d8f;
    color: #fff;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 0.7em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ===== Saved colors popover ===== */

.saved-popover {
    position: fixed;
    background: #fff;
    border-radius: 0.6em;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2), 0 0 0 1px #eee;
    padding: 0.8em;
    width: 240px;
    z-index: 9999;
}

.saved-popover-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6em;
}

.saved-popover-head strong {
    color: #264653;
    font-size: 0.9em;
}

#closeSavedBtn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4em;
    line-height: 1;
    color: #888;
    padding: 0;
}
#closeSavedBtn:hover { color: #e76f51; }

#savedColorsGrid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.4em;
}

.saved-color-tile {
    aspect-ratio: 1;
    border-radius: 0.3em;
    cursor: pointer;
    border: 1px solid #ddd;
    transition: transform 0.1s;
}
.saved-color-tile:hover { transform: scale(1.1); border-color: #264653; }

/* ===== Toast ===== */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #e76f51;
    color: #fff;
    padding: 0.9em 1.6em;
    border-radius: 0.6em;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    z-index: 9999;
    font-weight: 600;
    font-size: 0.95em;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 600px) {
    .tabs { gap: 0.2em; }
    .tab { padding: 0.55em 0.8em; font-size: 0.8em; }
    .sw-config, .sw-preview-sticky { padding: 1.2em; }
    .phone-mockup { width: 280px; height: 560px; }
    .cfg-row.two { flex-direction: column; }
    .list-row, .list-row.link-row, .list-row.social-row { grid-template-columns: 1fr; }
}
