/*
 * Responsive Previewer
 * Prefix: rp-
 * Theme: Teal / Cyan
 */

:root {
    --rp-primary: #0ea5e9;
    --rp-primary-d: #0284c7;
    --rp-primary-l: #38bdf8;
    --rp-primary-bg: #f0f9ff;
    --rp-accent: #06b6d4;
    --rp-bg: #f8fafc;
    --rp-card: #ffffff;
    --rp-text: #0f172a;
    --rp-text-m: #64748b;
    --rp-border: #e2e8f0;
    --rp-shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
    --rp-radius: 12px;
    --rp-radius-s: 8px;
}

#pageWrap {
    background-color: transparent !important;
}

.rp-container {
    width: 100%;
    margin: 40px auto;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
    color: var(--rp-text);
}

/* ═══════════════════════════════════════
   URL Input
   ═══════════════════════════════════════ */
.rp-url-card {
    background: var(--rp-card);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    box-shadow: var(--rp-shadow);
    padding: 20px 24px;
    margin-bottom: 14px;
}

.rp-url-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rp-url-input {
    flex: 1;
    font-size: 0.9rem;
    padding: 10px 14px;
    border: 2px solid var(--rp-border);
    border-radius: var(--rp-radius-s);
    outline: none;
    transition: border-color 0.15s;
    font-family: 'Consolas', monospace;
    color: var(--rp-text);
    min-width: 0;
}

.rp-url-input:focus {
    border-color: var(--rp-primary);
}

.rp-url-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--rp-radius-s);
    background: var(--rp-primary);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.rp-url-btn:hover {
    background: var(--rp-primary-d);
}

.rp-url-btn:active {
    transform: scale(0.97);
}

.rp-url-btn .material-icons {
    font-size: 18px;
}

.rp-url-hint {
    margin-top: 8px;
    font-size: 0.73rem;
    color: var(--rp-text-m);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.rp-sample-link {
    color: var(--rp-primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
}

.rp-sample-link:hover {
    text-decoration: underline;
}

/* ═══════════════════════════════════════
   Device Tab Bar
   ═══════════════════════════════════════ */
.rp-device-card {
    background: var(--rp-card);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    box-shadow: var(--rp-shadow);
    padding: 16px 20px;
    margin-bottom: 14px;
}

.rp-device-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--rp-text-m);
    margin-bottom: 10px;
}

.rp-device-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--rp-primary-l) transparent;
}

.rp-device-tabs::-webkit-scrollbar {
    height: 4px;
}

.rp-device-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.rp-device-tabs::-webkit-scrollbar-thumb {
    background: var(--rp-primary-l);
    border-radius: 99px;
}

.rp-sep {
    width: 1px;
    background: var(--rp-border);
    margin: 0 6px;
    flex-shrink: 0;
    align-self: stretch;
}

.rp-device-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    border: 2px solid var(--rp-border);
    border-radius: var(--rp-radius-s);
    background: var(--rp-bg);
    color: var(--rp-text-m);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.rp-device-tab:hover {
    border-color: var(--rp-primary-l);
    color: var(--rp-primary);
}

.rp-device-tab.active {
    border-color: var(--rp-primary);
    background: var(--rp-primary-bg);
    color: var(--rp-primary-d);
}

.rp-device-tab .material-icons {
    font-size: 18px;
}

.rp-device-tab-name {
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}

.rp-device-tab-size {
    font-size: 0.62rem;
    color: var(--rp-text-m);
    font-family: 'Consolas', monospace;
}

.rp-device-tab.active .rp-device-tab-size {
    color: var(--rp-primary);
}

/* Custom tab add button */
.rp-device-add {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: 2px dashed var(--rp-border);
    border-radius: var(--rp-radius-s);
    background: transparent;
    color: var(--rp-text-m);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.rp-device-add:hover {
    border-color: var(--rp-primary);
    color: var(--rp-primary);
}

.rp-device-add .material-icons {
    font-size: 16px;
}

/* Custom device modal */
.rp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9990;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.rp-modal-overlay.open {
    display: flex;
}

.rp-modal {
    background: var(--rp-card);
    border-radius: var(--rp-radius);
    padding: 28px 28px 24px;
    width: min(440px, 90vw);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.rp-modal h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--rp-text);
}

.rp-modal-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.rp-modal-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rp-modal-field label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--rp-text-m);
}

.rp-modal-field input {
    padding: 8px 10px;
    border: 1px solid var(--rp-border);
    border-radius: 6px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s;
}

.rp-modal-field input:focus {
    border-color: var(--rp-primary);
}

.rp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.rp-modal-cancel {
    padding: 8px 18px;
    border: 1px solid var(--rp-border);
    border-radius: 6px;
    background: var(--rp-bg);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rp-text-m);
    cursor: pointer;
    transition: all 0.15s;
}

.rp-modal-ok {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    background: var(--rp-primary);
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}

.rp-modal-ok:hover {
    background: var(--rp-primary-d);
}

/* ═══════════════════════════════════════
   Preview Controls
   ═══════════════════════════════════════ */
.rp-ctrl-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.rp-ctrl-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rp-device-info {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--rp-text);
}

.rp-scale-info {
    font-size: 0.72rem;
    color: var(--rp-text-m);
    font-family: 'Consolas', monospace;
}

.rp-scale-btns {
    display: flex;
    gap: 4px;
    background: var(--rp-bg);
    border: 1px solid var(--rp-border);
    padding: 3px;
    border-radius: 8px;
}

.rp-scale-btn {
    padding: 5px 11px;
    border: none;
    border-radius: 5px;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--rp-text-m);
    cursor: pointer;
    transition: all 0.12s;
}

.rp-scale-btn.active {
    background: var(--rp-primary);
    color: #fff;
}

.rp-ctrl-actions {
    display: flex;
    gap: 6px;
}

.rp-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 13px;
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius-s);
    background: var(--rp-bg);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--rp-text-m);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.rp-action-btn:hover {
    background: var(--rp-primary);
    border-color: var(--rp-primary);
    color: #fff;
}

.rp-action-btn .material-icons {
    font-size: 15px;
}

/* ═══════════════════════════════════════
   Preview Area
   ═══════════════════════════════════════ */
.rp-preview-card {
    background: var(--rp-card);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    box-shadow: var(--rp-shadow);
    padding: 20px;
    margin-bottom: 16px;
    min-height: 200px;
}

/* Empty state */
.rp-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--rp-text-m);
}

.rp-empty-state .material-icons {
    font-size: 56px;
    color: var(--rp-primary-l);
    margin-bottom: 14px;
}

.rp-empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--rp-text);
}

.rp-empty-state p {
    font-size: 0.88rem;
    line-height: 1.7;
    max-width: 380px;
}

/* Preview wrapper */
.rp-preview-outer {
    position: relative;
}

/* Loading overlay */
.rp-loading {
    position: absolute;
    inset: 0;
    background: rgba(248, 250, 252, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: var(--rp-radius-s);
    z-index: 10;
}

.rp-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--rp-primary-bg);
    border-top-color: var(--rp-primary);
    border-radius: 50%;
    animation: rp-spin 0.8s linear infinite;
}

@keyframes rp-spin {
    to {
        transform: rotate(360deg);
    }
}

.rp-loading p {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--rp-primary);
}

/* Error state */
.rp-error-overlay {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: #fff8f8;
    border: 2px dashed #fca5a5;
    border-radius: var(--rp-radius-s);
    gap: 10px;
}

.rp-error-overlay.visible {
    display: flex;
}

.rp-error-overlay .material-icons {
    font-size: 36px;
    color: #f87171;
}

.rp-error-overlay h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #b91c1c;
    margin: 0;
}

.rp-error-overlay p {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.6;
    margin: 0;
}

.rp-error-open-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--rp-primary);
    border-radius: 6px;
    background: var(--rp-primary-bg);
    color: var(--rp-primary-d);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.rp-error-open-btn:hover {
    background: var(--rp-primary);
    color: #fff;
}

.rp-error-open-btn .material-icons {
    font-size: 15px;
}

/* Iframe wrapper */
.rp-iframe-clip {
    position: relative;
    overflow: hidden;
    border-radius: var(--rp-radius-s);
    border: 1px solid var(--rp-border);
    background: #fff;
    margin: 0 auto;
    /* width & height set by JS */
}

.rp-iframe-inner {
    transform-origin: top left;
    /* width / height / transform set by JS */
}

.rp-iframe-inner iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
}

/* ═══════════════════════════════════════
   Actual-Size Lightbox
   ═══════════════════════════════════════ */
.rp-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9980;
    display: none;
    flex-direction: column;
    backdrop-filter: blur(3px);
}

.rp-lightbox.visible {
    display: flex;
}

.rp-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
    flex-shrink: 0;
}

.rp-lightbox-title {
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Consolas', monospace;
}

.rp-lightbox-close {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.rp-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.rp-lightbox-close .material-icons {
    font-size: 16px;
}

.rp-lightbox-scroll {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.rp-lightbox-scroll iframe {
    border: none;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

/* Scale bar (bottom) */
.rp-scale-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    font-size: 0.72rem;
    color: var(--rp-text-m);
    font-family: 'Consolas', monospace;
}

.rp-scale-bar .rp-scale-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--rp-primary);
    display: inline-block;
}

/* ═══════════════════════════════════════
   Toast
   ═══════════════════════════════════════ */
.rp-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--rp-text);
    color: #fff;
    padding: 11px 22px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}

.rp-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

/* ═══════════════════════════════════════
   SEO Content
   ═══════════════════════════════════════ */
.rp-seo {
    margin-top: 52px;
}

.rp-seo-section {
    margin-bottom: 32px;
}

.rp-seo-section h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--rp-text);
    border-left: 4px solid var(--rp-primary);
    padding-left: 12px;
    margin: 0 0 12px;
}

.rp-seo-section p,
.rp-seo-section li {
    font-size: 0.92rem;
    color: var(--rp-text-m);
    line-height: 1.85;
}

.rp-seo-section ul {
    padding-left: 1.4em;
    margin: 8px 0;
}

.rp-device-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 10px;
}

.rp-device-table th,
.rp-device-table td {
    padding: 9px 12px;
    border: 1px solid var(--rp-border);
    text-align: left;
}

.rp-device-table th {
    background: var(--rp-primary-bg);
    color: var(--rp-primary-d);
    font-weight: 700;
}

.rp-device-table tr:nth-child(even) td {
    background: var(--rp-bg);
}

/* ═══════════════════════════════════════
   Responsive
   ═══════════════════════════════════════ */
@media (max-width: 600px) {
    .rp-ctrl-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .rp-scale-btns,
    .rp-ctrl-actions {
        width: 100%;
    }

    .rp-url-row {
        flex-wrap: wrap;
    }

    .rp-url-btn {
        width: 100%;
        justify-content: center;
    }
}