/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #d82b2b;
    --primary-red-light: #ff4444;
    --primary-red-dark: #b91c1c;
    --black: #000000;
    --dark-gray: #111111;
    --gray: #333333;
    --light-gray: #666666;
    --white: #ffffff;
    --accent-gold: #ffd700;
    
    --font-primary: 'Inter', sans-serif;
    --font-heading: 'Rajdhani', sans-serif;
    
    --container-max: 1400px;
    --section-padding: 6rem 0;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius: 5px;
    --border-radius-lg: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ===== КРИТИЧЕСКИЙ FIX ДЛЯ ГОРИЗОНТАЛЬНОЙ ПРОКРУТКИ ===== */
html {
    scroll-behavior: smooth;
    font-size: 16px;
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative;
}

body {
    font-family: var(--font-primary);
    background: var(--black);
    color: var(--white);
    line-height: 1.6;
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative;
}

/* Все элементы не должны выходить за viewport */
* {
    max-width: 100%;
}

img, video, iframe, canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* ===== КОНТЕЙНЕРЫ ===== */
.container {
    max-width: var(--container-max);
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

/* FIX для row - БЕЗ отрицательных margins */
.row {
    margin-left: 0;
    margin-right: 0;
}

/* ===== УБИРАЕМ ВСЕ ПСЕВДОЭЛЕМЕНТЫ С OVERFLOW НА ВСЕХ УСТРОЙСТВАХ ===== */
section::after,
section::before,
.section-separator::before,
.footer::before {
    display: none !important;
}

/* ===== CUSTOM BOOTSTRAP OVERRIDES ===== */
.dropdown-menu-dark {
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
}

.dropdown-menu-dark .dropdown-item {
    color: var(--white);
    transition: var(--transition);
}

.dropdown-menu-dark .dropdown-item:hover {
    background: rgba(216, 43, 43, 0.1);
    color: var(--primary-red);
}

/* ===== UTILITY CLASSES ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-red), var(--primary-red-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-gradient {
    border: 2px solid;
    border-image: linear-gradient(135deg, var(--primary-red), var(--primary-red-light)) 1;
}

.shadow-red {
    box-shadow: 0 4px 20px rgba(216, 43, 43, 0.3);
}

.shadow-red-lg {
    box-shadow: 0 20px 60px rgba(216, 43, 43, 0.2);
}

.bg-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.text-glow {
    text-shadow: 0 0 10px var(--primary-red);
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-red), var(--primary-red-light));
}

.bg-gradient-dark {
    background: linear-gradient(135deg, var(--black), var(--dark-gray));
}

.bg-gradient-overlay {
    background: linear-gradient(135deg, rgba(0,0,0,0.8), rgba(216,43,43,0.2));
}

.min-vh-100 {
    min-height: 100vh;
}

.position-relative {
    position: relative;
}

.overflow-hidden {
    overflow: hidden;
}

.z-index-1 {
    z-index: 1;
}

.z-index-2 {
    z-index: 2;
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--dark-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-red);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-red-light);
}

html {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-red) var(--dark-gray);
}

/* ===== SELECTION STYLES ===== */
::selection {
    background: var(--primary-red);
    color: var(--white);
}

::-moz-selection {
    background: var(--primary-red);
    color: var(--white);
}

/* ===== TOOLTIP STYLES ===== */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--black);
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1000;
    margin-bottom: 5px;
}

.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ===== ACCESSIBILITY ===== */
.btn:focus,
.form-control:focus,
.nav-link:focus,
.social-link:focus,
.settore-link:focus {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(216, 43, 43, 0.5);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.carousel-item,
.fade-in,
.settore-card,
.prodotto-card,
.news-card {
    will-change: transform;
}

.btn,
.nav-link,
.social-link {
    will-change: transform, box-shadow;
}

.carousel-item {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    h1, h2, h3, h4, h5, h6, p, span, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
    
    section {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
    
    .container {
        max-width: 100vw !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}

/* ===== PREVENT OVERSCROLL ===== */
html {
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overscroll-behavior-y: contain;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}