:root {
    --blue: #1F3971;
    --red: #ed1c24;
    --dark: #2d3e50;
    --gray: #f5f5f5;
    --text: #444;
    --font: 'Montserrat', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 15px;
    color: var(--text);
    line-height: 1.7;
}

a { color: inherit; text-decoration: none; transition: color .25s; }
img { max-width: 100%; height: auto; display: block; }

/* ── Topbar ── */
#topbar {
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    padding: 10px 0;
    text-align: center;
}
#topbar span { margin: 0 15px; }
#topbar i { margin-right: 6px; }

/* ── Header ── */
#header {
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
#header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
}
#header .logo img { height: 38px; }

nav ul { list-style: none; display: flex; gap: 30px; }
nav a { font-weight: 600; font-size: 14px; color: var(--dark); text-transform: uppercase; letter-spacing: .5px; }
nav a:hover, nav a.active { color: var(--red); }

.hamburger { display: none; background: none; border: none; font-size: 22px; color: var(--dark); cursor: pointer; }

/* ── Mobile menu ── */
#mobile-menu {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--blue);
    z-index: 2000;
    padding: 40px 30px;
    flex-direction: column;
}
#mobile-menu.open { display: flex; }
#mobile-menu .close-btn { color: #fff; font-size: 28px; align-self: flex-end; cursor: pointer; margin-bottom: 30px; }
#mobile-menu ul { list-style: none; }
#mobile-menu li { border-bottom: 1px solid rgba(255,255,255,.15); }
#mobile-menu a { color: #fff; font-size: 18px; font-weight: 600; display: block; padding: 14px 0; }

/* ── Hero slider ── */
#hero { position: relative; overflow: hidden; }
.slide { position: relative; display: none; }
.slide.active { display: block; }
.slide img { width: 100%; height: 600px; object-fit: cover; }
.slide-caption {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 60px 80px;
    background: linear-gradient(transparent, rgba(0,0,0,.55));
    color: #fff;
    font-size: 46px;
    font-weight: 800;
    line-height: 1.2;
}
.slide-dots { position: absolute; bottom: 20px; right: 30px; display: flex; gap: 8px; }
.slide-dots span {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: rgba(255,255,255,.5);
    cursor: pointer;
    transition: background .3s;
}
.slide-dots span.active { background: var(--red); }

/* ── Sections ── */
.section { padding: 90px 0; }
.section-gray { background: var(--gray); }
.section-blue { background: var(--blue); color: #fff; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.section-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    text-transform: uppercase;
    margin-bottom: 10px;
}
.section-subtitle { font-size: 14px; color: #666; margin-bottom: 40px; }

/* ── Chi siamo (home) ── */
.about-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 60px; align-items: center; }
.about-grid h2 { font-size: 32px; font-weight: 700; color: var(--blue); line-height: 1.2; margin-bottom: 20px; }
.about-grid h2 span { color: var(--red); }
.about-grid p { color: #555; line-height: 1.8; text-align: justify; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .5px;
    transition: all .3s;
    cursor: pointer;
    border: none;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--red); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--blue); color: #fff; }
.btn-outline { background: transparent; border: 2px solid #fff; color: #fff; }
.btn-outline:hover { background: #fff; color: var(--blue); }
.mt-20 { margin-top: 20px; }

/* ── News cards ── */
.news-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.news-card {
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    transition: box-shadow .3s, transform .3s;
}
.news-card:hover { box-shadow: 0 8px 30px rgba(0,0,0,.15); transform: translateY(-4px); }
.news-card img { width: 100%; height: 200px; object-fit: cover; }
.news-card-body { padding: 22px 22px 18px; }
.news-card-body h3 { font-size: 17px; font-weight: 600; color: var(--dark); margin-bottom: 8px; }
.news-card-body h3 a:hover { color: var(--red); }
.news-meta { font-size: 12px; color: #999; margin-bottom: 10px; }
.news-meta i { margin-right: 5px; }
.news-intro { font-size: 14px; color: #666; line-height: 1.6; margin-bottom: 14px; }
.news-card .btn { font-size: 13px; padding: 8px 20px; }

/* ── Counters ── */
.counters-section {
    background: url('../img/slider/patenti02.jpg') center/cover no-repeat;
    position: relative;
    padding: 80px 0;
}
.counters-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.65);
}
.counters-grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.counter-box {
    border: 1px solid rgba(255,255,255,.25);
    background: rgba(0,0,0,.5);
    text-align: center;
    padding: 40px 20px;
    transition: border-color .3s;
}
.counter-box:hover { border-color: var(--red); }
.counter-num {
    font-size: 56px;
    font-weight: 700;
    color: var(--red);
    line-height: 1;
    display: block;
}
.counter-label { font-size: 22px; color: #fff; font-weight: 500; margin-top: 14px; }

/* ── Flip boxes ── */
.flip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.flip-card { height: 260px; perspective: 1000px; cursor: pointer; }
.flip-inner {
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform .6s;
    position: relative;
}
.flip-card:hover .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border-radius: 6px;
}
.flip-front { background: var(--gray); }
.flip-front img { max-height: 140px; object-fit: contain; }
.flip-back {
    background: var(--blue);
    color: #fff;
    transform: rotateY(180deg);
    text-align: center;
    font-size: 14px;
    line-height: 1.7;
    flex-direction: column;
    gap: 16px;
}
.flip-back .btn { margin-top: 8px; }

/* ── Page header ── */
.page-header {
    background: var(--blue);
    color: #fff;
    padding: 50px 0 40px;
    text-align: center;
}
.page-header h1 { font-size: 36px; font-weight: 700; }

/* ── Servizi ── */
.servizi-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 60px; align-items: start; }
.servizi-list { list-style: none; }
.servizi-list li {
    padding: 14px 0;
    border-bottom: 1px solid #e8e8e8;
    font-size: 15px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.servizi-list li i { color: var(--red); margin-top: 4px; flex-shrink: 0; }

/* ── Contatti ── */
.contatti-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.contatti-info {
    background: var(--blue);
    color: #fff;
    padding: 70px 60px;
}
.contatti-info h2 { font-size: 28px; font-weight: 700; margin-bottom: 40px; }
.contatti-item { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
.contatti-item i { font-size: 20px; color: rgba(255,255,255,.7); margin-top: 2px; }
.contatti-item p { font-size: 15px; line-height: 1.6; }
.contatti-form {
    background: var(--red);
    padding: 70px 60px;
}
.contatti-form h2 { font-size: 28px; font-weight: 900; color: #fff; margin-bottom: 30px; }
.form-group { margin-bottom: 16px; }
.form-control {
    width: 100%;
    background: #f2f2f2;
    border: none;
    height: 46px;
    padding: 0 16px;
    font-family: var(--font);
    font-size: 14px;
    border-radius: 0;
    outline: none;
}
.form-control:focus { background: #e8e8e8; }
textarea.form-control { height: auto; padding: 14px 16px; resize: vertical; }
#contact-status { padding: 12px 16px; border-radius: 4px; margin-top: 12px; font-size: 14px; display: none; }

/* ── Articolo news ── */
.article-content { max-width: 800px; margin: 0 auto; }
.article-content h1 { font-size: 30px; font-weight: 700; color: var(--dark); margin-bottom: 12px; }
.article-date { font-size: 13px; color: #999; margin-bottom: 30px; }
.article-body { font-size: 15px; line-height: 1.8; color: #555; }
.article-body p { margin-bottom: 16px; }
.article-pdf {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--gray);
    border: 1px solid #ddd;
    padding: 14px 22px;
    border-radius: 6px;
    margin-top: 24px;
    font-weight: 600;
    color: var(--dark);
    transition: background .3s;
}
.article-pdf:hover { background: #e8e8e8; }
.article-pdf img { width: 28px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--blue); font-weight: 600; margin-bottom: 30px; font-size: 14px; }
.back-link:hover { color: var(--red); }

/* ── Map ── */
.map-container { width: 100%; height: 420px; border: 0; display: block; }

/* ── Footer ── */
#footer {
    background: var(--blue);
    color: #fff;
    padding: 70px 0 50px;
}
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.footer-logo { height: 50px; margin-bottom: 16px; }
.footer-tagline { font-size: 14px; opacity: .8; margin-bottom: 16px; }
.footer-legal { font-size: 13px; opacity: .7; margin-top: 8px; }
.footer-legal a:hover { color: var(--red); }
.footer-title { font-size: 18px; font-weight: 800; text-transform: uppercase; margin-bottom: 24px; }
.footer-contact { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; font-size: 14px; }
.footer-contact i { opacity: .7; margin-top: 3px; }
.social-icons { display: flex; gap: 10px; flex-wrap: wrap; }
.social-icons a {
    width: 34px; height: 34px;
    background: #fff;
    color: var(--dark);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: background .3s, color .3s;
    border-radius: 2px;
}
.social-icons a:hover { background: var(--red); color: #fff; }
.footer-bottom {
    border-top: 1px solid rgba(255,255,255,.15);
    margin-top: 40px;
    padding-top: 20px;
    font-size: 13px;
    opacity: .6;
    text-align: center;
}

/* ── Back to top ── */
#back-top {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 40px; height: 40px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    transition: background .3s;
    z-index: 999;
}
#back-top.visible { display: flex; }
#back-top:hover { background: var(--red); }

/* ── Admin ── */
.admin-body { background: #f0f2f5; min-height: 100vh; font-family: var(--font); }
.admin-header { background: var(--blue); color: #fff; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }
.admin-header h1 { font-size: 18px; font-weight: 700; }
.admin-header a { color: rgba(255,255,255,.8); font-size: 13px; }
.admin-header a:hover { color: #fff; }
.admin-main { max-width: 900px; margin: 30px auto; padding: 0 20px; }
.admin-card { background: #fff; border-radius: 8px; padding: 28px; box-shadow: 0 2px 8px rgba(0,0,0,.07); margin-bottom: 20px; }
.admin-card h2 { font-size: 18px; font-weight: 700; color: var(--dark); margin-bottom: 20px; border-bottom: 2px solid var(--gray); padding-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { background: var(--gray); padding: 10px 14px; text-align: left; font-weight: 600; color: var(--dark); }
.admin-table td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.admin-table tr:hover td { background: #fafafa; }
.badge-red { background: #fee2e2; color: #b91c1c; padding: 3px 8px; border-radius: 4px; font-size: 12px; }
.badge-green { background: #dcfce7; color: #15803d; padding: 3px 8px; border-radius: 4px; font-size: 12px; }
.admin-form label { display: block; font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 6px; }
.admin-form input, .admin-form textarea, .admin-form select {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 14px;
    margin-bottom: 18px;
    outline: none;
    transition: border-color .2s;
}
.admin-form input:focus, .admin-form textarea:focus { border-color: var(--blue); }
.admin-form textarea { min-height: 140px; resize: vertical; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 4px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.login-wrap { max-width: 380px; margin: 80px auto; padding: 0 20px; }
.login-wrap .admin-card { text-align: center; }
.login-wrap h1 { font-size: 22px; font-weight: 700; color: var(--blue); margin-bottom: 6px; }
.login-wrap p { font-size: 13px; color: #999; margin-bottom: 24px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    nav { display: none; }
    .hamburger { display: block; }

    .slide img { height: 320px; }
    .slide-caption { font-size: 26px; padding: 30px 24px; }

    .about-grid, .servizi-grid, .flip-grid, .contatti-grid, .footer-grid { grid-template-columns: 1fr; }
    .news-grid { grid-template-columns: 1fr; }
    .counters-grid { grid-template-columns: 1fr; }

    .contatti-info, .contatti-form { padding: 50px 28px; }
    .section { padding: 60px 0; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .news-grid { grid-template-columns: repeat(2, 1fr); }
}
