:root {
    --bg-main: #121212;
    --sidebar-bg: #1e1e1e;
    --sidebar-header-bg: #161616;
    --accent: #0b5f6b;
    --accent-hover: #0d7381;
    --border-color: rgba(255, 255, 255, 0.05);
    --device-frame-color: #2a2a2a;
    --text-main: #e0e0e0;
}

* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Montserrat', sans-serif;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* --- SIDEBAR & TRIGGER --- */
.trigger {
    position: fixed;
    top: 0;
    width: 20px;
    height: 100%;
    z-index: 1001;
}

#left-trigger {
    left: 0;
}

#right-trigger {
    right: 0;
}

.sidebar {
    position: fixed;
    top: 0;
    width: 260px;
    height: 100%;
    background: var(--sidebar-bg);
    z-index: 1000;
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

#sidebar-left {
    left: -260px;
    border-right: 1px solid var(--border-color);
}

#left-trigger:hover+#sidebar-left,
#sidebar-left:hover {
    left: 0;
}

#sidebar-right {
    right: -260px;
    border-left: 1px solid var(--border-color);
}

#right-trigger:hover+#sidebar-right,
#sidebar-right:hover {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    background: var(--sidebar-header-bg);
    border-bottom: 1px solid var(--border-color);
    color: #fff;
}

.project-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

.project-list li {
    padding: 16px 20px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    color: var(--text-main);
}

.project-list li i {
    margin-right: 12px;
    color: var(--accent);
}

.project-list li:hover {
    background: rgba(255, 255, 255, 0.03);
    border-left-color: var(--accent-hover);
    color: #fff;
}

.device-list {
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.device-list button {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 14px 15px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.9rem;
    transition: 0.2s;
}

.device-list button i {
    margin-right: 10px;
    color: var(--accent);
    width: 20px;
    text-align: center;
}

.device-list button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
    box-shadow: 0 0 15px rgba(11, 95, 107, 0.4);
}

.device-list button:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
}

#preview-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
    overflow: hidden;
}

#frame-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    transform-origin: center center;
    background: #000;
    transition: transform 0.3s ease;
}

/* --- RISOLUZIONI DISPOSITIVI (Dimensioni Logiche Reali) --- */
#frame-wrapper.desktop-large {
    width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
}

#frame-wrapper.desktop-medium {
    width: 1280px;
    height: 800px;
    border: 12px solid var(--device-frame-color);
    border-radius: 12px;
}

#frame-wrapper.tablet-portrait {
    width: 768px;
    height: 1024px;
    border: 16px solid var(--device-frame-color);
    border-radius: 20px;
}

#frame-wrapper.apple-pro-max {
    width: 430px;
    height: 932px;
    border: 14px solid var(--device-frame-color);
    border-radius: 40px;
}

#frame-wrapper.apple-standard {
    width: 393px;
    height: 852px;
    border: 14px solid var(--device-frame-color);
    border-radius: 38px;
}

#frame-wrapper.samsung-ultra {
    width: 412px;
    height: 915px;
    border: 12px solid var(--device-frame-color);
    border-radius: 32px;
}

#frame-wrapper.moto-edge {
    width: 412px;
    height: 914px;
    border: 10px solid var(--device-frame-color);
    border-radius: 30px;
}

#frame-wrapper.mobile-small {
    width: 375px;
    height: 667px;
    border: 14px solid var(--device-frame-color);
    border-radius: 28px;
}

/* --- REGOLA DI ROTAZIONE UNIVERSALE (LANDSCAPE) --- */
#frame-wrapper.tablet-portrait.landscape {
    width: 1024px;
    height: 768px;
}

#frame-wrapper.apple-pro-max.landscape {
    width: 932px;
    height: 430px;
}

#frame-wrapper.apple-standard.landscape {
    width: 852px;
    height: 393px;
}

#frame-wrapper.samsung-ultra.landscape {
    width: 915px;
    height: 412px;
}

#frame-wrapper.moto-edge.landscape {
    width: 914px;
    height: 412px;
}

#frame-wrapper.mobile-small.landscape {
    width: 667px;
    height: 375px;
}


#site-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
    border-radius: inherit;
    display: block;
}

#welcome-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
    pointer-events: none;
}

#welcome-message.hidden {
    opacity: 0;
    visibility: hidden;
}

.welcome-content h1 {
    font-size: 2.5rem;
    margin: 0;
    background: linear-gradient(135deg, #fff 0%, var(--accent-hover) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-hint {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 80px;
    background: #0d7381;
    box-shadow: 0 0 15px #0d7381;
    z-index: 999999 !important;
    pointer-events: none;
    animation: pulseHint 1.5s infinite;
    transition: opacity 0.8s ease;
}

.sidebar-hint.left {
    left: 0;
    border-radius: 0 8px 8px 0;
}

.sidebar-hint.right {
    right: 0;
    border-radius: 8px 0 0 8px;
}

@keyframes pulseHint {
    0% {
        opacity: 0.4;
        height: 60px;
    }

    50% {
        opacity: 1;
        height: 100px;
    }

    100% {
        opacity: 0.4;
        height: 60px;
    }
}

#current-url {
    padding: 20px;
    color: #0d7381;
    font-weight: bold;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.icon-rotated {
    transform: rotate(270deg);
}

.icon-small {
    font-size: 0.8em;
}

@media screen and (max-width: 768px) {
    #left-trigger {
        width: 30px;
    }

    #right-trigger,
    #sidebar-right {
        display: none !important;
    }

    .sidebar {
        width: 80vw;
    }

    #sidebar-left {
        left: -80vw;
    }

    .welcome-content h1 {
        font-size: 1.8rem;
    }

    /* --- TRUCCO PER L'ALTEZZA DELLE PWA SU ANDROID --- */
    body,
    html {
        position: fixed !important;
        /* Blocca il body ai bordi fisici */
        height: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    #preview-area,
    #frame-wrapper {
        position: absolute !important;
        top: 0 !important;
        bottom: 0 !important;
        /* Ancorato al fondo reale */
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        /* Passato a 100% invece di 100dvh */
        max-width: none !important;
        max-height: none !important;
        border: none !important;
        border-radius: 0 !important;
        transform: none !important;
    }

    .sidebar-hint.right {
        display: none;
    }
}