/* =====================================================
   CEA — Design System (layout CSA, colori logo CEA)
   Colors: Verde #76B742 | Grigio #6F6F6E | Light #F8F9FB
   ===================================================== */

:root {
    --cea-grey:       #4a4b4a;
    --cea-grey-dark:  #2f302f;
    --cea-grey-light: #6f6f6e;
    --cea-green:       #76b742;
    --cea-green-dark:  #5a9a2c;
    --cea-green-light: #a9d67f;
    --cea-green-deep: #4c8a1f;
    --cea-text:       #1e293b;
    --cea-text-muted: #64748b;
    --cea-bg:         #f8f9fb;
    --cea-surface:    #ffffff;
    --cea-border:     #e2e8f0;
    --cea-radius:     8px;
    --cea-radius-lg:  12px;
    --cea-shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
    --cea-shadow-md:  0 4px 16px rgba(74,75,74,.12);
}

/* ── Base ────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background-color: var(--cea-bg);
    color: var(--cea-text);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

.container { flex: 1; }

/* ── Navbar ──────────────────────────────────────── */

.cea-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.cea-navbar {
    background: var(--cea-grey) !important;
    padding: .75rem 0;
    min-height: 64px;
}

.cea-brand {
    padding: 0;
    margin-right: 1.5rem;
}

.cea-logo-img {
    height: 44px;
    width: auto;
    /* SVG on dark bg: invert text, keep gold icon */
    filter: brightness(0) invert(1) drop-shadow(0 0 0 transparent);
    /* Override: use a white-adapted version by targeting SVG directly */
    filter: none;
    background: rgba(255,255,255,.92);
    border-radius: 6px;
    padding: 4px 10px;
}

.cea-nav-link {
    color: rgba(255,255,255,.85) !important;
    font-weight: 500;
    font-size: .92rem;
    padding: .5rem .9rem !important;
    border-radius: 6px;
    transition: color .2s, background .2s;
    display: flex;
    align-items: center;
}

.cea-nav-link:hover,
.cea-nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,.12);
}

.cea-nav-link svg { opacity: .8; }

.cea-toggler {
    border-color: rgba(255,255,255,.3);
}

.cea-toggler:focus { box-shadow: 0 0 0 3px rgba(118,183,66,.4); }

/* Dropdown */
.cea-dropdown {
    border: none;
    border-radius: var(--cea-radius);
    box-shadow: var(--cea-shadow-md);
    padding: .4rem;
    min-width: 200px;
}

.cea-dropdown .dropdown-item {
    border-radius: 5px;
    font-size: .9rem;
    padding: .5rem .75rem;
    color: var(--cea-text);
    transition: background .15s;
}

.cea-dropdown .dropdown-item:hover {
    background: #eef6e8;
    color: var(--cea-grey);
}

/* Gold accent bar */
.cea-accent-bar {
    height: 3px;
    background: linear-gradient(90deg, var(--cea-green) 0%, var(--cea-green-light) 60%, transparent 100%);
}

/* ── Auth buttons (LoginPartial) ──────────────────── */

.navbar-dark .btn-outline-light {
    border-color: rgba(255,255,255,.4);
    color: rgba(255,255,255,.9);
    font-size: .88rem;
    padding: .35rem .9rem;
    border-radius: 6px;
    transition: all .2s;
}

.navbar-dark .btn-outline-light:hover {
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.7);
    color: #fff;
}

.navbar-dark .btn-light {
    background: var(--cea-green);
    border-color: var(--cea-green);
    color: var(--cea-grey-dark);
    font-weight: 600;
    font-size: .88rem;
    padding: .35rem .9rem;
    border-radius: 6px;
    transition: all .2s;
}

.navbar-dark .btn-light:hover {
    background: var(--cea-green-dark);
    border-color: var(--cea-green-dark);
}

/* ── Cards ───────────────────────────────────────── */

.card {
    border: 1px solid var(--cea-border);
    border-radius: var(--cea-radius-lg);
    box-shadow: var(--cea-shadow);
    background: var(--cea-surface);
    transition: box-shadow .2s, transform .2s;
}

.card:hover { box-shadow: var(--cea-shadow-md); }

.card-header {
    background: linear-gradient(135deg, var(--cea-grey) 0%, var(--cea-grey-light) 100%);
    color: #fff;
    border-radius: var(--cea-radius-lg) var(--cea-radius-lg) 0 0 !important;
    border: none;
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body { padding: 1.25rem; }

/* ── Tables ──────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--cea-surface);
    border-radius: var(--cea-radius);
    overflow: hidden;
    box-shadow: var(--cea-shadow);
}

thead {
    background: linear-gradient(135deg, var(--cea-grey) 0%, var(--cea-grey-light) 100%);
}

th {
    color: #fff;
    font-weight: 600;
    font-size: .85rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: .85rem 1rem;
    border: none;
    text-align: left;
}

td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--cea-border);
    font-size: .92rem;
    text-align: left;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #f1f7ec; }

/* Gold accent on first column header */
thead th:first-child { border-left: 3px solid var(--cea-green); }

/* ── Responsive tables (no-more-tables) ──────────── */

@media only screen and (max-width: 767px) {
    #no-more-tables table,
    #no-more-tables thead,
    #no-more-tables tbody,
    #no-more-tables th,
    #no-more-tables td,
    #no-more-tables tr { display: block; }

    #no-more-tables thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    #no-more-tables tr {
        border: 1px solid var(--cea-border);
        border-radius: var(--cea-radius);
        margin-bottom: .75rem;
        box-shadow: var(--cea-shadow);
    }

    #no-more-tables td {
        border: none;
        border-bottom: 1px solid var(--cea-border);
        position: relative;
        padding: .65rem 1rem .65rem 48%;
        white-space: normal;
        text-align: left;
    }

    #no-more-tables td:before {
        position: absolute;
        top: .65rem;
        left: 1rem;
        width: 44%;
        padding-right: .5rem;
        white-space: nowrap;
        font-weight: 600;
        font-size: .8rem;
        color: var(--cea-grey);
        content: attr(data-title);
    }

    #no-more-tables td:last-child { border-bottom: none; }
}

/* ── Forms ───────────────────────────────────────── */

label {
    font-size: .88rem;
    font-weight: 500;
    color: var(--cea-text);
    margin-bottom: .35rem;
    display: block;
    letter-spacing: .01em;
}

.form-control, .form-select {
    border: 1px solid var(--cea-border);
    border-radius: var(--cea-radius);
    font-size: .92rem;
    padding: .55rem .85rem;
    transition: border-color .2s, box-shadow .2s;
    background: var(--cea-surface);
    color: var(--cea-text);
}

.form-control:focus, .form-select:focus {
    border-color: var(--cea-grey-light);
    box-shadow: 0 0 0 3px rgba(74,75,74,.12);
    outline: none;
}

textarea {
    padding: .65rem .85rem;
    border: 1px solid var(--cea-border);
    border-radius: var(--cea-radius);
    font-size: .92rem;
    line-height: 1.6;
    max-width: 100%;
    resize: vertical;
    transition: border-color .2s, box-shadow .2s;
}

textarea:focus {
    border-color: var(--cea-grey-light);
    box-shadow: 0 0 0 3px rgba(74,75,74,.12);
    outline: none;
}

/* ── Buttons ─────────────────────────────────────── */

.btn-primary {
    background: var(--cea-green-deep);
    border-color: var(--cea-green-deep);
    font-weight: 600;
    border-radius: var(--cea-radius);
    transition: all .2s;
}

.btn-primary:hover, .btn-primary:focus {
    background: #3f7219;
    border-color: #3f7219;
    box-shadow: 0 4px 12px rgba(74,75,74,.25);
}

.btn-warning {
    background: var(--cea-green);
    border-color: var(--cea-green);
    color: var(--cea-grey-dark);
    font-weight: 600;
    border-radius: var(--cea-radius);
}

.btn-warning:hover {
    background: var(--cea-green-dark);
    border-color: var(--cea-green-dark);
    color: var(--cea-grey-dark);
}

.btn { border-radius: var(--cea-radius); font-weight: 500; }

/* ── Alerts ──────────────────────────────────────── */

.cea-alert-success {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
    border-radius: var(--cea-radius);
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}

.cea-alert-danger {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
    border-radius: var(--cea-radius);
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}

/* ── Radios & Checkboxes ─────────────────────────── */

.radio-container,
.checkbox-container {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.radio-container label,
.checkbox-container label {
    margin-bottom: 0;
    font-weight: 400;
}

.form-check-input:checked {
    background-color: var(--cea-green-deep);
    border-color: var(--cea-green-deep);
}

/* ── Gallery ─────────────────────────────────────── */

#galeria {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

#galeria img {
    width: 130px;
    height: 130px;
    object-fit: cover;
    border-radius: var(--cea-radius);
    box-shadow: var(--cea-shadow);
    transition: transform .2s, box-shadow .2s;
}

#galeria img:hover {
    transform: scale(1.05);
    box-shadow: var(--cea-shadow-md);
}

/* ── Page headings ───────────────────────────────── */

h1, h2, h3 { color: var(--cea-grey); font-weight: 700; }

h1 {
    font-size: 1.75rem;
    border-left: 4px solid var(--cea-green);
    padding-left: .75rem;
    margin-bottom: 1.25rem;
}

/* ── Breadcrumb ──────────────────────────────────── */

.breadcrumb-item + .breadcrumb-item::before { color: var(--cea-text-muted); }
.breadcrumb-item a { color: var(--cea-grey-light); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--cea-grey); text-decoration: underline; }

/* ── Misc utility ────────────────────────────────── */

.features {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.features img { width: 220px; }

.preference {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin: .5rem 0;
}

/* ── Footer ──────────────────────────────────────── */

.cea-footer {
    background: var(--cea-grey-dark);
    margin-top: auto;
    border-top: 3px solid var(--cea-green);
}

.cea-footer-logo {
    opacity: .9;
}

.cea-footer-text {
    color: rgba(255,255,255,.6);
    font-size: .85rem;
}

.cea-footer-link {
    color: var(--cea-green-light);
    font-size: .85rem;
    text-decoration: none;
    transition: color .2s;
}

.cea-footer-link:hover { color: var(--cea-green); text-decoration: underline; }

/* ── Info blocks (Conferma testata) ─────────────── */

.cea-info-block {
    background: var(--cea-bg);
    border: 1px solid var(--cea-border);
    border-left: 4px solid var(--cea-green);
    border-radius: var(--cea-radius);
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.cea-info-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--cea-text-muted);
}

.cea-info-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--cea-grey);
}

/* ── Incarichi table (many columns) ─────────────── */

.table-responsive-wrapper {
    /* tablet: horizontal scroll before stacking */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--cea-radius);
}

/* On mobile: full stack via #no-more-tables rules above */
@media only screen and (max-width: 767px) {
    .table-responsive-wrapper {
        overflow-x: visible;
    }

    /* Each stacked row gets gold left border accent */
    #no-more-tables tr {
        border-left: 3px solid var(--cea-green);
    }

    /* Conferma button full-width in stacked row */
    #no-more-tables td:last-child {
        padding-left: 1rem;
        text-align: center;
    }

    #no-more-tables td:last-child::before {
        display: none;
    }
}

/* ── Autocomplete ────────────────────────────────── */

.autocomplete-items {
    position: absolute;
    border: 1px solid var(--cea-border, #dee2e6);
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 0 0 var(--cea-radius, 6px) var(--cea-radius, 6px);
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    max-height: 220px;
    overflow-y: auto;
}

.autocomplete-items div {
    padding: .5rem .75rem;
    cursor: pointer;
    font-size: .9rem;
}

.autocomplete-items div:hover,
.autocomplete-active {
    background-color: var(--cea-grey, #4a4b4a);
    color: #fff;
}

/* ── Scrollbar (Webkit) ──────────────────────────── */

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--cea-bg); }
::-webkit-scrollbar-thumb { background: #c4cfe0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--cea-grey-light); }

/* ── Compatibilità pagine CEA esistenti ──────────── */

#chart_wrap {
    position: relative;
    padding-bottom: 100%;
    height: 0;
    overflow: hidden;
}

#chart_div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
