/* CMS Device Preview - Multi-Device Preview Mode */

/* Preview Container */
.device-preview-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    position: relative;
}

/* Preview Toolbar */
.device-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background-color: white;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 10;
    flex-wrap: wrap;
    gap: 12px;
}

.device-preview-toolbar-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-preview-toolbar-center {
    flex: 1;
    justify-content: center;
}

/* Zoom Controls */
.device-preview-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

/* Preview Stage (scrollable container) */
.device-preview-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    overflow: auto;
    position: relative;
}

/* Device Frame */
.device-preview-frame {
    position: relative;
    background-color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top center;
    margin: auto;
}

/* Device Frame Variants */
.device-frame-desktop {
    border: 16px solid #2c3e50;
    border-top-width: 40px;
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

.device-frame-desktop::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.device-frame-tablet {
    border: 24px solid #34495e;
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}

.device-frame-tablet::before {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.device-frame-mobile {
    border: 12px solid #1c1c1e;
    border-radius: 36px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
    padding-top: 32px;
}

/* Mobile Device Chrome - Notch */
.device-chrome-notch {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 24px;
    background-color: #1c1c1e;
    border-radius: 0 0 16px 16px;
    z-index: 20;
}

.device-chrome-notch::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Viewport Container */
.device-preview-viewport {
    background-color: white;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    border-radius: 2px;
}

/* Custom scrollbar for viewport */
.device-preview-viewport::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.device-preview-viewport::-webkit-scrollbar-track {
    background-color: #f5f5f5;
}

.device-preview-viewport::-webkit-scrollbar-thumb {
    background-color: #bdbdbd;
    border-radius: 4px;
}

.device-preview-viewport::-webkit-scrollbar-thumb:hover {
    background-color: #9e9e9e;
}

/* Ruler */
.device-preview-ruler {
    position: absolute;
    top: 64px;
    left: 24px;
    right: 24px;
    height: 24px;
    background-color: white;
    border-bottom: 1px solid #e0e0e0;
    z-index: 5;
}

.device-preview-ruler-horizontal {
    position: relative;
    width: 100%;
    height: 100%;
}

.ruler-mark {
    position: absolute;
    top: 0;
    height: 24px;
    border-left: 1px solid #bdbdbd;
    pointer-events: none;
}

.ruler-mark span {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    font-family: monospace;
    color: #757575;
}

/* Zoom Animation */
.device-preview-frame {
    animation: frameZoomIn 0.3s ease-out;
}

@keyframes frameZoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Device Switch Animation */
.device-preview-frame.device-switching {
    animation: deviceSwitch 0.4s ease-in-out;
}

@keyframes deviceSwitch {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(0.9) rotateY(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

/* Loading State */
.device-preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.device-preview-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.device-preview-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #9e9e9e;
}

.device-preview-empty .mud-icon-root {
    font-size: 64px;
    color: #e0e0e0;
    margin-bottom: 16px;
}

/* Responsive Toolbar */
@media (max-width: 1279px) {
    .device-preview-toolbar {
        padding: 8px 16px;
    }

    .device-preview-toolbar-center {
        order: 3;
        flex-basis: 100%;
        justify-content: flex-start;
        margin-top: 8px;
    }
}

@media (max-width: 959px) {
    .device-preview-stage {
        padding: 24px 12px;
    }

    .device-frame-desktop,
    .device-frame-tablet,
    .device-frame-mobile {
        border-width: 8px;
    }

    .device-frame-desktop {
        border-top-width: 24px;
    }

    .device-frame-mobile {
        padding-top: 20px;
    }

    .device-chrome-notch {
        height: 16px;
        width: 80px;
    }
}

@media (max-width: 599px) {
    .device-preview-toolbar {
        padding: 8px;
        gap: 8px;
    }

    .device-preview-toolbar-section {
        gap: 8px;
    }

    .device-preview-zoom-controls {
        padding: 4px 8px;
        gap: 4px;
    }

    .device-preview-stage {
        padding: 16px 8px;
    }

    /* Remove device frames on small screens to save space */
    .device-frame-desktop,
    .device-frame-tablet,
    .device-frame-mobile {
        border: none !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }

    .device-chrome-notch {
        display: none;
    }
}

/* Focus States */
.device-preview-toolbar button:focus-visible,
.device-preview-toolbar .mud-button-root:focus-visible {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .device-preview-frame {
        border: 3px solid #000;
    }

    .device-preview-toolbar {
        border-bottom-width: 2px;
    }

    .ruler-mark {
        border-left-width: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .device-preview-frame,
    .device-preview-frame.device-switching {
        animation: none;
        transition: none;
    }

    .device-preview-loading-spinner {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .device-preview-toolbar,
    .device-preview-ruler {
        display: none;
    }

    .device-preview-stage {
        padding: 0;
    }

    .device-preview-frame {
        box-shadow: none;
        border: 1px solid #000;
        transform: none !important;
    }
}

/* Dark Mode Support (future enhancement) */
@media (prefers-color-scheme: dark) {
    .device-preview-container {
        background-color: #1e1e1e;
    }

    .device-preview-toolbar {
        background-color: #2d2d2d;
        border-bottom-color: #3d3d3d;
    }

    .device-preview-viewport {
        background-color: #1e1e1e;
    }

    .device-preview-zoom-controls {
        background-color: #2d2d2d;
        border-color: #3d3d3d;
    }
}

/* Utility Classes */
.device-preview-fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.device-preview-slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
