/* ==============================================
   device-preview.css - Responsive Preview Mode
   ============================================== */

/* Device Preview Token Set (self-contained, independent of theme) */
:root {
    /* Preview chrome colors */
    --preview-bg: hsl(220, 15%, 18%);
    --preview-bg-deep: hsl(220, 15%, 12%);
    --preview-bg-dark: hsl(220, 15%, 15%);
    --preview-surface: hsl(220, 15%, 20%);
    --preview-surface-hover: hsl(220, 15%, 28%);
    --preview-border: hsl(220, 10%, 30%);
    --preview-border-subtle: hsl(220, 10%, 25%);
    --preview-border-dark: hsl(220, 10%, 22%);
    --preview-border-input: hsl(220, 10%, 28%);
    --preview-border-hover: hsl(220, 10%, 40%);
    --preview-text: hsl(220, 10%, 70%);
    --preview-text-muted: hsl(220, 10%, 60%);
    --preview-text-dim: hsl(220, 10%, 50%);
    --preview-frame: #000;
    --preview-accent: hsl(262, 83%, 58%);
    --preview-accent-hover: hsl(262, 83%, 50%);
    --preview-danger: hsl(0, 84%, 60%);
    --preview-close: hsl(0, 60%, 50%);
    --preview-close-hover: hsl(0, 60%, 40%);
    --preview-white: #fff;
}

/* --- Toggle Button --- */
.device-preview-toggle {
    position: fixed;
    bottom: 80px;
    left: 1rem;
    z-index: var(--z-preview);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--preview-accent);
    color: var(--preview-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: transform 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.device-preview-toggle:hover {
    transform: scale(1.1);
    background: var(--preview-accent-hover);
}

.device-preview-toggle.active {
    background: var(--preview-danger);
}

/* --- Preview Overlay --- */
.device-preview-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-toast);
    background: var(--preview-bg);
    flex-direction: column;
}

.device-preview-overlay.open {
    display: flex;
}

/* --- Toolbar --- */
.device-preview-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--preview-bg-deep);
    border-bottom: 1px solid var(--preview-border-subtle);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.device-preview-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.device-preview-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.device-preview-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--preview-text);
    white-space: nowrap;
    margin-right: 0.5rem;
}

/* Device Buttons */
.device-btn-group {
    display: flex;
    background: var(--preview-surface);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.device-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--preview-text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.device-btn:hover {
    color: var(--preview-white);
    background: var(--preview-surface-hover);
}

.device-btn.active {
    color: var(--preview-white);
    background: var(--preview-accent);
}

.device-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.device-btn-size {
    font-size: 0.625rem;
    opacity: 0.7;
}

/* Custom Size Input */
.device-custom-size {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.device-size-input {
    width: 56px;
    padding: 0.25rem 0.375rem;
    background: var(--preview-surface);
    border: 1px solid var(--preview-border);
    border-radius: 4px;
    color: var(--preview-white);
    font-size: 0.75rem;
    text-align: center;
    outline: none;
    font-family: var(--font-mono, monospace);
}

.device-size-input:focus {
    border-color: var(--preview-accent);
}

.device-size-x {
    color: var(--preview-text-dim);
    font-size: 0.75rem;
}

.device-size-label {
    color: var(--preview-text-dim);
    font-size: 0.6875rem;
    margin-left: 0.25rem;
}

/* Orientation Toggle */
.device-rotate-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--preview-surface);
    border: 1px solid var(--preview-border);
    border-radius: 6px;
    color: var(--preview-text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.device-rotate-btn:hover {
    color: var(--preview-white);
    border-color: var(--preview-border-hover);
}

/* Close Button */
.device-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--preview-close);
    border: none;
    border-radius: 6px;
    color: var(--preview-white);
    cursor: pointer;
    transition: background 0.15s;
}

.device-close-btn:hover {
    background: var(--preview-close-hover);
}

/* URL Bar */
.device-url-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 1rem;
    background: var(--preview-bg-dark);
    border-bottom: 1px solid var(--preview-border-dark);
    flex-shrink: 0;
}

.device-url-input {
    flex: 1;
    padding: 0.375rem 0.625rem;
    background: var(--preview-surface);
    border: 1px solid var(--preview-border-input);
    border-radius: 100px;
    color: var(--preview-text);
    font-size: 0.75rem;
    outline: none;
    font-family: var(--font-mono, monospace);
}

.device-url-input:focus {
    border-color: var(--preview-accent);
    color: var(--preview-white);
}

.device-url-go {
    padding: 0.25rem 0.625rem;
    background: var(--preview-accent);
    border: none;
    border-radius: 4px;
    color: var(--preview-white);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.device-url-go:hover {
    background: var(--preview-accent-hover);
}

/* --- Frame Area --- */
.device-preview-frame-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow: auto;
    min-height: 0;
}

/* Device Frame */
.device-frame {
    position: relative;
    background: var(--preview-frame);
    border-radius: 36px;
    padding: 12px;
    box-shadow: 0 0 0 2px var(--preview-border), 0 8px 32px rgba(0,0,0,0.5);
    transition: width 0.3s ease, height 0.3s ease;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

.device-frame.no-frame {
    border-radius: 0;
    padding: 0;
    box-shadow: 0 0 0 1px var(--preview-border);
    background: transparent;
}

/* Notch */
.device-notch {
    display: none;
    width: 120px;
    height: 24px;
    background: var(--preview-frame);
    border-radius: 0 0 16px 16px;
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-content);
}

.device-frame.show-notch .device-notch {
    display: block;
}

/* Iframe */
.device-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 24px;
    background: var(--preview-white);
    flex: 1;
}

.device-frame.no-frame .device-preview-iframe {
    border-radius: 0;
}

/* Status bar text */
.device-status-text {
    color: var(--preview-text-dim);
    font-size: 0.6875rem;
    text-align: center;
    padding: 0.5rem 0 0;
    flex-shrink: 0;
}

/* --- Zoom Controls --- */
.device-zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.device-zoom-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--preview-surface);
    border: 1px solid var(--preview-border);
    border-radius: 4px;
    color: var(--preview-text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.15s;
}

.device-zoom-btn:hover {
    color: var(--preview-white);
    border-color: var(--preview-border-hover);
}

.device-zoom-label {
    color: var(--preview-text-muted);
    font-size: 0.6875rem;
    min-width: 36px;
    text-align: center;
    font-family: var(--font-mono, monospace);
}

/* Dark mode toggle in preview */
.device-theme-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--preview-surface);
    border: 1px solid var(--preview-border);
    border-radius: 6px;
    color: var(--preview-text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.device-theme-btn:hover {
    color: var(--preview-white);
    border-color: var(--preview-border-hover);
}

/* Responsive toolbar */
@media (max-width: 768px) {
    .device-preview-toolbar {
        padding: 0.375rem 0.5rem;
        gap: 0.375rem;
    }

    .device-btn {
        padding: 0.375rem 0.5rem;
    }

    .device-btn-size {
        display: none;
    }

    .device-custom-size {
        display: none;
    }

    .device-preview-frame-area {
        padding: 0.5rem;
    }

    .device-frame {
        border-radius: 0;
        padding: 0;
    }

    .device-preview-iframe {
        border-radius: 0;
    }
}
