/* ============================================
   ECOSISTEMA WEB 3D - UI Styles
   Mobile First + Grigio Aziendale #849daa
   ============================================ */

/* Variables */
:root {
    --eco-primary: #849daa;
    --eco-primary-light: #a8bcc7;
    --eco-primary-dark: #667b85;
    --eco-bg: rgba(102, 123, 133, 0.95);          /* Grigio aziendale scuro */
    --eco-bg-light: rgba(132, 157, 170, 0.9);     /* Grigio aziendale */
    --eco-bg-solid: #5a6d78;                       /* Sfondo solido */
    --eco-border: rgba(255, 255, 255, 0.25);
    --eco-text: #ffffff;
    --eco-text-muted: rgba(255, 255, 255, 0.7);

    /* Category colors - più luminosi per contrasto su grigio */
    --color-iot: #5ee6dc;
    --color-server: #8899a6;
    --color-database: #a855f7;
    --color-api: #fbbf24;
    --color-cloud: #93c5fd;
    --color-webapp: #60a5fa;
    --color-pwa: #c084fc;
    --color-mobile: #2dd4bf;
    --color-desktop: #64748b;
}

/* Font */
@font-face {
    font-family: "Share-TechMono";
    src: url(../fonts/Share-TechMono.otf) format("opentype");
}

/* ============================================
   MOBILE FIRST - Base styles (< 768px)
   ============================================ */

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--eco-bg-solid);
    font-family: "Share-TechMono", monospace;
    font-size: 14px;
}

/* 3D Container */
#galaxy-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* UI Container */
#ecosystem-ui {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    font-family: "Share-TechMono", monospace;
    padding: 10px;
}

#ecosystem-ui > * {
    pointer-events: auto;
}

/* ============================================
   MOBILE: Main Panel - Bottom Sheet Style
   ============================================ */
.eco-panel {
    position: fixed;
    bottom: 95px;
    left: 0;
    right: 0;
    background: var(--eco-bg);
    border: 1px solid var(--eco-border);
    border-radius: 20px 20px 0 0;
    padding: 15px;
    backdrop-filter: blur(15px);
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.3);
    max-height: 35vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.eco-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--eco-border);
    border-radius: 2px;
    margin: 0 auto 12px;
}

.eco-panel h3 {
    display: none; /* Nascosto su mobile */
}

/* Filters - Scrollabile orizzontalmente su mobile */
.eco-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin: 0 -15px;
    padding-left: 15px;
    padding-right: 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.eco-filters::-webkit-scrollbar {
    display: none;
}

.eco-filter {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--eco-border);
    color: var(--eco-text);
    padding: 8px 14px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.eco-filter:hover,
.eco-filter:active {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--eco-text);
}

.eco-filter.active {
    background: var(--eco-text);
    border-color: var(--eco-text);
    color: var(--eco-primary-dark);
    font-weight: bold;
}

/* Filter colors when active */
.eco-filter[data-filter="iot"].active { background: var(--color-iot); border-color: var(--color-iot); color: #1a1a1a; }
.eco-filter[data-filter="server"].active { background: var(--color-server); border-color: var(--color-server); }
.eco-filter[data-filter="database"].active { background: var(--color-database); border-color: var(--color-database); }
.eco-filter[data-filter="api"].active { background: var(--color-api); border-color: var(--color-api); color: #1a1a1a; }
.eco-filter[data-filter="cloud"].active { background: var(--color-cloud); border-color: var(--color-cloud); color: #1a1a1a; }
.eco-filter[data-filter="webapp"].active { background: var(--color-webapp); border-color: var(--color-webapp); }
.eco-filter[data-filter="pwa"].active { background: var(--color-pwa); border-color: var(--color-pwa); }
.eco-filter[data-filter="mobile"].active { background: var(--color-mobile); border-color: var(--color-mobile); color: #1a1a1a; }
.eco-filter[data-filter="desktop"].active { background: var(--color-desktop); border-color: var(--color-desktop); }

/* Stats - Inline su mobile */
.eco-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding-top: 12px;
    border-top: 1px solid var(--eco-border);
    margin-top: 10px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.5rem;
    color: var(--eco-text);
    font-weight: bold;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--eco-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ============================================
   MOBILE: Info Panel - Card overlay
   ============================================ */
.eco-info {
    position: fixed;
    top: 60px;
    left: 10px;
    right: 10px;
    background: var(--eco-bg);
    border: 1px solid var(--eco-border);
    border-radius: 12px;
    padding: 15px;
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    max-height: 40vh;
    overflow-y: auto;
}

.eco-info .hint {
    color: var(--eco-text-muted);
    font-size: 0.8rem;
    margin: 0;
    text-align: center;
}

.node-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.node-icon {
    font-size: 1.8rem;
}

.node-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: normal;
    color: var(--eco-text);
    line-height: 1.2;
}

.node-type {
    margin: 0 0 8px 0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
}

.node-desc {
    margin: 0 0 10px 0;
    color: var(--eco-text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

.node-connections {
    padding-top: 8px;
    border-top: 1px solid var(--eco-border);
    font-size: 0.75rem;
    color: var(--eco-text);
}

/* ============================================
   MOBILE: Legend - Nascosta
   ============================================ */
.eco-legend {
    display: none;
}

/* ============================================
   MOBILE: Navigation - Top compact
   ============================================ */
.eco-nav {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 110;
}

.eco-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--eco-bg);
    border: 1px solid var(--eco-border);
    border-radius: 50%;
    color: var(--eco-text);
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.eco-nav a .nav-text-full {
    display: none;
}

.eco-nav a:hover,
.eco-nav a:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ============================================
   MOBILE: Title - Compact top left
   ============================================ */
.eco-title {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 110;
}

.eco-title h1 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: normal;
    color: var(--eco-text);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.eco-title p {
    display: none; /* Nascosto su mobile */
}

/* ============================================
   MOBILE: Instructions - Nascosto
   ============================================ */
.eco-instructions {
    display: none;
}

/* ============================================
   Loading screen
   ============================================ */
.eco-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--eco-bg-solid);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.eco-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.eco-loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--eco-border);
    border-top-color: var(--eco-text);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.eco-loading p {
    margin-top: 15px;
    color: var(--eco-text);
    font-size: 0.85rem;
    letter-spacing: 2px;
}

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

/* ============================================
   FOOTER
   ============================================ */
.cosmic-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(to top, var(--eco-bg-solid) 0%, transparent 100%);
    padding: 25px 15px 15px;
}

.footer-content {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.contact-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.footer-logo {
    width: 20px;
    height: auto;
    opacity: 0.8;
}

.info-item {
    color: var(--eco-text-muted);
}

.separator {
    color: var(--eco-text);
    opacity: 0.5;
}

.contact-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--eco-text);
    text-decoration: none;
    padding: 8px 14px;
    border: 1px solid var(--eco-border);
    border-radius: 20px;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    min-height: 40px;
    backdrop-filter: blur(10px);
}

.contact-link:hover,
.contact-link:active {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--eco-text);
}

.link-icon {
    color: var(--eco-text);
}

.testo_non_selezionabile {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ============================================
   TABLET (768px+)
   ============================================ */
@media screen and (min-width: 768px) {
    html, body {
        font-size: 15px;
    }

    #ecosystem-ui {
        padding: 15px;
    }

    .footer-content {
        flex-direction: row;
        justify-content: space-between;
    }

    .contact-info {
        font-size: 0.8rem;
    }

    .contact-link {
        font-size: 0.8rem;
        padding: 10px 18px;
    }

    /* Panel - Left sidebar style */
    .eco-panel {
        position: fixed;
        top: 15px;
        left: 15px;
        bottom: auto;
        right: auto;
        width: 300px;
        max-height: none;
        border-radius: 12px;
        padding: 20px;
    }

    .eco-panel::before {
        display: none;
    }

    .eco-panel h3 {
        display: block;
        margin: 0 0 15px 0;
        font-size: 1.1rem;
        font-weight: normal;
        color: var(--eco-text);
        letter-spacing: 2px;
        text-transform: uppercase;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--eco-border);
    }

    .eco-filters {
        flex-wrap: wrap;
        overflow-x: visible;
        margin: 0;
        padding: 0;
        padding-bottom: 15px;
    }

    .eco-filter {
        padding: 6px 12px;
    }

    /* Info panel */
    .eco-info {
        top: auto;
        bottom: 85px;
        left: 15px;
        right: auto;
        width: 300px;
        max-height: 250px;
    }

    /* Legend visible */
    .eco-legend {
        display: block;
        position: fixed;
        bottom: 85px;
        right: 15px;
        background: var(--eco-bg);
        border: 1px solid var(--eco-border);
        border-radius: 12px;
        padding: 15px;
        backdrop-filter: blur(15px);
    }

    .legend-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 4px 0;
        font-size: 0.7rem;
        color: var(--eco-text-muted);
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .legend-item .dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        box-shadow: 0 0 8px currentColor;
    }

    /* Nav expanded */
    .eco-nav a {
        width: auto;
        height: auto;
        padding: 10px 20px;
        border-radius: 25px;
        gap: 8px;
    }

    .eco-nav a .nav-text-full {
        display: inline;
        font-size: 0.8rem;
        letter-spacing: 2px;
        text-transform: uppercase;
    }

    /* Title */
    .eco-title {
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
    }

    .eco-title h1 {
        font-size: 1.2rem;
        letter-spacing: 3px;
    }

    .eco-title p {
        display: block;
        margin: 5px 0 0 0;
        font-size: 0.75rem;
        color: var(--eco-text-muted);
        letter-spacing: 2px;
    }

    /* Instructions */
    .eco-instructions {
        display: flex;
        position: fixed;
        bottom: 85px;
        left: 50%;
        transform: translateX(-50%);
        background: var(--eco-bg);
        border: 1px solid var(--eco-border);
        border-radius: 25px;
        padding: 8px 20px;
        backdrop-filter: blur(10px);
        gap: 15px;
        font-size: 0.7rem;
        color: var(--eco-text-muted);
    }

    .eco-instructions span {
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .eco-instructions .key {
        background: rgba(255, 255, 255, 0.15);
        padding: 2px 6px;
        border-radius: 4px;
        border: 1px solid var(--eco-border);
        color: var(--eco-text);
    }
}

/* ============================================
   DESKTOP (1024px+)
   ============================================ */
@media screen and (min-width: 1024px) {
    html, body {
        font-size: 16px;
    }

    #ecosystem-ui {
        padding: 20px;
    }

    .eco-panel {
        width: 320px;
        top: 20px;
        left: 20px;
    }

    .eco-panel h3 {
        font-size: 1.2rem;
    }

    .eco-stats {
        gap: 25px;
    }

    .stat-value {
        font-size: 1.8rem;
    }

    .eco-info {
        bottom: 85px;
        left: 20px;
        width: 320px;
    }

    .eco-legend {
        bottom: 85px;
        right: 20px;
    }

    .eco-nav {
        top: 20px;
        right: 20px;
    }

    .eco-nav a {
        padding: 12px 24px;
    }

    .eco-title h1 {
        font-size: 1.4rem;
        letter-spacing: 4px;
    }

    .eco-instructions {
        padding: 10px 25px;
        gap: 20px;
        font-size: 0.75rem;
    }
}

/* ============================================
   LARGE DESKTOP (1440px+)
   ============================================ */
@media screen and (min-width: 1440px) {
    .eco-panel {
        width: 350px;
    }

    .eco-info {
        width: 350px;
        max-height: 300px;
    }

    .eco-title h1 {
        font-size: 1.6rem;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.eco-panel {
    animation: slideUp 0.4s ease;
}

.eco-info,
.eco-legend,
.eco-nav {
    animation: fadeIn 0.4s ease;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .eco-filter {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .eco-nav a {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .eco-panel {
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
    }
}
