/* FIX ULTIMATIVO LAYOUT (NO FLEX) */
html,
body {
    height: 100%;
    width: 100%;
    background-color: #0f0f0f;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Blocca tutto */
    position: fixed;
    /* Inchioda la pagina */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    font-family: 'Montserrat', sans-serif;
    background-color: #0f0f0f;
    color: #e0e0e0;

    -webkit-font-smoothing: antialiased;
    /* Per Chrome/Safari/Mac */
    -moz-osx-font-smoothing: grayscale;
    /* Per Firefox */
    text-rendering: optimizeLegibility;
    /* Ottimizza la leggibilità */
}

#canvas-wrapper {
    /* Disabilito completamente le azioni touch native del browser 
            per gestire manualmente le gesture (zoom/pan) via JS */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    /* Prevengo il pull-to-refresh su mobile */
    overscroll-behavior: none;
}

#prop-bar {
    touch-action: pan-x;
}

.canvas-bg {
    background-image:
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.tool-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-btn:active {
    transform: scale(0.95);
}

.tool-btn.active {
    background-color: #e31937;
    color: white;
    box-shadow: 0 0 15px rgba(227, 25, 55, 0.4);
    border-color: transparent;
}

.view-btn {
    font-size: 11px;
    padding: 6px 10px;
    background: #262626;
    border-radius: 6px;
    color: #a3a3a3;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    background: #404040;
    color: white;
}

/* Context Menu Style */
#context-menu-custom {
    animation: fadeIn 0.1s ease-out;
    position: fixed;
    z-index: 9999;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: #e5e5e5;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
}

.ctx-item:hover {
    background-color: #e31937;
    color: white;
}

.ctx-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.ctx-divider {
    height: 1px;
    background-color: #404040;
    margin: 4px 0;
}

.ctx-shortcut {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

.style-btn.active {
    color: #e31937;
    background-color: rgba(227, 25, 55, 0.1);
    border-color: #e31937;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.desktop-only {
    display: none !important;
}

@media (min-width: 768px) {
    .desktop-only {
        display: block !important;
    }
}

/* Tab Styles */
.tab-btn {
    padding-bottom: 0.5rem;
    border-bottom-width: 2px;
    border-color: transparent;
    color: #a3a3a3;
    transition: all 0.2s;
}

.tab-btn.active {
    border-color: #e31937;
    color: white;
    font-weight: bold;
}

/* Info Modal Tabs */
.info-tab-btn {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    color: #666;
    border-bottom: 2px solid transparent;
    text-transform: uppercase;
    transition: all 0.2s;
}

.info-tab-btn.active {
    color: white;
    border-bottom-color: #e31937;
}

.info-tab-btn:hover:not(.active) {
    color: #aaa;
    background-color: rgba(255, 255, 255, 0.05);
}

.color-sel-btn {
    transition: all 0.2s;
}

.color-sel-btn.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #0f0f0f, 0 0 0 4px #e31937;
}

/* Ad Container Transition */
#ads-mobile {
    transition: opacity 0.3s ease;
}

/* Property Bar Transition */
#prop-bar {
    transition: bottom 0.3s ease, opacity 0.3s ease;
}

#prop-bar.hidden-bar {
    bottom: -100px !important;
    opacity: 0;
    pointer-events: none;
}

/* Plate Preset Button */
.plate-preset-btn {
    transition: all 0.2s;
    filter: grayscale(0.5);
    opacity: 0.7;
}

.plate-preset-btn:hover {
    filter: grayscale(0);
    opacity: 1;
}

.plate-preset-btn.active {
    filter: grayscale(0);
    opacity: 1;
    border-color: #e31937;
    box-shadow: 0 0 0 4px rgba(227, 25, 55, 0.2);
}

/* SUPPORTO RTL (Ebraico) */
html[dir="rtl"] body {
    font-family: 'Rubik', 'Segoe UI', Tahoma, sans-serif; /* Font leggibile per ebraico */
}

/* Fix per la sidebar strumenti che deve restare a sinistra o spostarsi a destra */
/* In questo caso, forziamo la direzione LTR per l'area di lavoro grafica per non confondere le coordinate */
#workspace-area {
    direction: ltr; 
}

/* Però i menu modali devono seguire la direzione della lingua */
#modal-start, #modal-info, #modal-export, #modal-donate {
    direction: inherit; /* Segue dir="rtl" dell'html */
}

/* Fix specifico per input range che si invertono in RTL */
html[dir="rtl"] input[type=range] {
    direction: ltr; 
}

@font-face {
    font-family: 'FE-Schrift';
    src: url('./font/FE.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Driver Gothic';
    src: url('./font/DriverGothic.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Charles Wright';
    src: url('./font/charles-wright.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* --- TEX GYRE ADVENTOR (Famiglia Completa) --- */

/* 1. REGULAR (Normale) */
@font-face {
    font-family: 'Tex Gyre Adventor';
    src: url('./font/texgyreadventor-regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* 2. BOLD (Grassetto) */
@font-face {
    font-family: 'Tex Gyre Adventor';
    src: url('./font/texgyreadventor-bold.otf') format('opentype');
    font-weight: bold;  /* <--- Qui dici al browser: "Usa questo file quando è grassetto" */
    font-style: normal;
    font-display: swap;
}

/* 3. ITALIC (Corsivo) */
@font-face {
    font-family: 'Tex Gyre Adventor';
    src: url('./font/texgyreadventor-italic.otf') format('opentype');
    font-weight: normal;
    font-style: italic; /* <--- Qui dici al browser: "Usa questo file quando è corsivo" */
    font-display: swap;
}

/* 4. BOLD ITALIC (Grassetto + Corsivo) */
@font-face {
    font-family: 'Tex Gyre Adventor';
    src: url('./font/texgyreadventor-bolditalic.otf') format('opentype');
    font-weight: bold;
    font-style: italic;
    font-display: swap;
}

/* Forza le emoji colorate anche su Windows */
.flag-emoji {
    font-family: 'Noto Color Emoji', sans-serif;
}

/* Animazione "Battito" per il tasto Dona */
@keyframes heartbeat-glow {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(227, 25, 55, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 10px 10px rgba(227, 25, 55, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(227, 25, 55, 0); }
}

.btn-donate-highlight {
    animation: heartbeat-glow 2s infinite;
    background: linear-gradient(135deg, #e31937 0%, #ff4d6d 100%); /* Gradiente per renderlo più "3D" */
    border: 1px solid rgba(255,255,255,0.2);
}

.btn-donate-highlight:hover {
    animation: none; /* Ferma l'animazione quando ci passi sopra */
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(227, 25, 55, 0.8);
}

/* --- SUPPORTO LINGUA ARABA --- */
/* Usa un font di sistema pulito per l'Arabo (Segoe UI/Tahoma) al posto di Montserrat */
html[lang="ar"] body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Forza l'allineamento a destra per i testi nei menu quando si usa una lingua RTL (Arabo/Ebraico) */
html[lang="ar"] .text-right, 
html[lang="he"] .text-right {
    text-align: right;
}