/*
 * Scopo: stile comune del portale documentazione API e della pagina di accesso.
 * Chiamante: controller privato, azione asset con file=style.css.
 * Input: classi HTML del renderer; nessun nome endpoint, dato o segreto.
 * Output: layout responsive coerente con backend/documentation del dominio.
 * Esempio: indice endpoint -> card chiare, dettagli apribili e codice scuro.
 */

/* ========================= */
/*         LIBRERIE          */
/* ========================= */

/* Manrope Latin e locale, distribuito con licenza SIL OFL: Manrope-OFL.txt. */

@font-face {
    font-family: 'Manrope';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/api/documentation/?action=asset&file=manrope-latin.woff2') format('woff2');
}

/* ========================= */
/*     CONFIG E COSTANTI     */
/* ========================= */

:root {
    --bg: #f6f8fb;
    --bg-soft: #eef3f1;
    --panel: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d7dde5;
    --text: #0f172a;
    --muted: #4b5563;
    --muted-soft: #64748b;
    --accent: #2fb57d;
    --accent-dark: #238b60;
    --warning: #d6a100;
    --danger: #c2413b;
    --accent-2: #2563eb;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.07);
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.045);
    --radius: 10px;
    --radius-sm: 8px;
}

/* ========================= */
/*           MAIN            */
/* ========================= */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: 'Manrope', 'Segoe UI', Arial, sans-serif; background: linear-gradient(180deg, var(--bg-soft) 0, var(--bg) 320px); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(35, 139, 96, 0.36); outline-offset: 4px; }
[hidden] { display: none !important; }
h1 { margin: 0 0 10px; font-size: clamp(24px, 2.4vw, 34px); line-height: 1.15; text-align: center; }
h2 { margin: 0; font-size: 24px; line-height: 1.2; }
code { font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace; }

/* ========================= */
/*         ACCESSO          */
/* ========================= */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(100%, 470px); padding: 34px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); text-align: center; }
.login-brand { margin: 0 0 12px; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-dark); }
.login-panel h1 { font-size: 26px; }
.login-intro { margin: 0 0 22px; color: var(--muted); }
.login-panel label { display: block; margin-bottom: 8px; text-align: left; font-size: 14px; font-weight: 700; }
.login-panel input[type="password"] { width: 100%; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--text); background: var(--panel); outline: none; }
.login-panel input[type="password"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 181, 125, 0.16); }
.primary-button { min-height: 44px; padding: 10px 18px; border: 0; border-radius: 6px; background: var(--accent-dark); color: #ffffff; font-weight: 700; }
.login-button { width: 100%; margin-top: 14px; text-transform: uppercase; }
.login-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.message { border-radius: 6px; padding: 10px 12px; margin: 16px 0; font-size: 14px; }
.message.error { background: #fef3f2; color: #b42318; border: 1px solid #fecdca; }
.message.suspended { background: #fff8e6; color: #805b00; border: 1px solid #ead89f; }
.back-link, .text-link { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px; }
.back-link { display: block; text-align: center; font-weight: 600; }

/* ========================= */
/*      PAGINA E INDICE      */
/* ========================= */

.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, 0.94); border-bottom: 1px solid var(--border); padding: 14px clamp(16px, 3vw, 36px); display: flex; align-items: center; gap: 16px; justify-content: space-between; backdrop-filter: blur(14px); }
.brand { font-weight: 700; letter-spacing: 0.2px; display: flex; align-items: center; gap: 7px; }
.brand span { color: var(--accent-dark); }
.topbar-meta { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 13px; }
.secondary-button { min-height: 36px; padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; }
.secondary-button:hover { border-color: var(--accent-dark); }
.page { max-width: 1320px; margin: 0 auto; padding: 36px 16px 72px; }
.hero { background: var(--panel); border: 1px solid var(--border); padding: clamp(24px, 4vw, 44px); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr; gap: 26px; align-items: center; }
.hero-copy { min-width: 0; max-width: 840px; margin: 0 auto; text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-size: 12px; margin: 0 0 8px; font-weight: 700; }
.lede { color: var(--muted); margin: 0 auto; max-width: 720px; text-align: center; font-size: 17px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: 900px; width: 100%; margin: 0 auto; }
.meta-card { background: #fbfcfd; border: 1px solid var(--border); padding: 14px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-soft); text-align: center; }
.meta-card .label { color: var(--muted-soft); font-size: 12px; margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.meta-card .value { margin: 0; font-weight: 700; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.section { margin-top: 34px; }
.endpoint-index, .empty-panel { background: rgba(255, 255, 255, 0.58); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 2vw, 24px); box-shadow: var(--shadow-soft); text-align: center; }
.empty-panel p { margin-bottom: 0; color: var(--muted); }
.index-heading h2 { margin: 4px 0 0; font-size: 22px; }
.endpoint-filter { width: min(100%, 720px); margin: 16px auto 0; }
.filter-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.filter-control { display: flex; gap: 8px; align-items: stretch; }
.filter-input { flex: 1; width: 100%; min-width: 0; height: 44px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 13px; color: var(--text); background: var(--panel); outline: none; box-shadow: var(--shadow-soft); }
.filter-input:focus { border-color: rgba(35, 139, 96, 0.58); box-shadow: 0 0 0 3px rgba(47, 181, 125, 0.16); }
.filter-clear { min-height: 44px; padding: 0 14px; border: 1px solid rgba(194, 65, 59, 0.28); border-radius: var(--radius-sm); background: #fff6f5; color: var(--danger); font-size: 13px; font-weight: 700; }
.filter-summary { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.empty-results { margin: 16px 0 0; color: var(--muted); font-weight: 700; }
.index-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.index-links:has(> :only-child) { grid-template-columns: 1fr; }
.index-link { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-soft); }
.index-link:hover { border-color: rgba(35, 139, 96, 0.42); box-shadow: var(--shadow); }
.index-link strong, .index-link small { display: block; }
.index-link strong { font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace; overflow-wrap: anywhere; }
.index-link small { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.index-link .suspended-text { color: #805b00; font-weight: 700; }

/* ========================= */
/*       SCHEDE API         */
/* ========================= */

.endpoint-detail { background: rgba(255, 255, 255, 0.58); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 2vw, 24px); box-shadow: var(--shadow-soft); position: relative; overflow: hidden; text-align: center; scroll-margin-top: 86px; }
.endpoint-detail::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--accent-dark); }
.endpoint-header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-bottom: 10px; }
.endpoint-toggle { width: 100%; border: 0; background: transparent; color: inherit; padding: 0; }
.endpoint-toggle:hover .endpoint-path { border-color: rgba(35, 139, 96, 0.42); }
.endpoint-detail:not(.is-open) .endpoint-header { margin-bottom: 0; }
.endpoint-content { padding-top: 10px; }
.method-badge { flex-shrink: 0; background: rgba(47, 181, 125, 0.12); color: var(--accent-dark); padding: 8px 12px; border-radius: 999px; font-weight: 700; }
.endpoint-path { font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace; font-size: 14px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.tag { color: var(--muted); font-size: 14px; font-weight: 600; }
.status-badge { padding: 5px 9px; background: #fff3cb; color: #805b00; border: 1px solid #ead89f; border-radius: 999px; font-size: 12px; font-weight: 700; }
.toggle-label { display: inline-flex; align-items: center; gap: 8px; color: #ffffff; background: var(--accent-dark); border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 700; line-height: 1; }
.toggle-label::after { content: ''; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-1px); }
.endpoint-detail.is-open .toggle-label { background: var(--danger); }
.endpoint-detail.is-open .toggle-label::after { transform: rotate(225deg) translate(-1px, -1px); }
.description { color: var(--muted); max-width: 820px; margin: 0 auto; }
.document-meta { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0 20px; }
.chip { background: rgba(47, 181, 125, 0.12); color: var(--accent-dark); border: 1px solid rgba(47, 181, 125, 0.2); padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.endpoint-card-set { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.card { min-width: 0; width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px 16px; box-shadow: var(--shadow-soft); position: relative; overflow: hidden; text-align: center; }
.params-card::before, .example-card::before, .errors-card::before, .rules-card::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; }
.params-card::before { background: var(--accent-2); }
.rules-card::before { background: var(--accent-dark); }
.example-card::before { background: var(--warning); }
.errors-card::before { background: var(--danger); }
.card h3 { margin: 0 0 12px; font-size: 17px; }
.card h4 { margin: 14px 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.card-description { color: var(--muted); font-size: 14px; max-width: 960px; margin: 0 auto 16px; }
.table-scroll { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: #fbfcfd; }
td { font-size: 14px; }
td:last-child { text-align: left; min-width: 230px; }
td code { font-size: 12px; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
.rule-list { text-align: left; max-width: 1050px; margin: 0 auto; padding-left: 22px; color: var(--muted); font-size: 14px; }
.rule-list li + li { margin-top: 9px; }
.limit-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.limit-item { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fbfcfd; }
.limit-item span { display: block; color: var(--muted); font-size: 12px; }
.limit-item strong { display: block; margin-top: 4px; font-size: 16px; }
.function-list { margin-top: 18px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: left; }
.function-list summary { cursor: pointer; color: var(--accent-dark); font-size: 14px; font-weight: 600; }
.function-list p { margin-bottom: 0; line-height: 2.2; }
.function-list code { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 6px; background: #f1f5f9; border-radius: 4px; font-size: 11px; }
.note { margin: 10px 0 0; background: #f8fafc; border: 1px solid var(--border); border-left: 3px solid var(--accent-dark); border-right: 3px solid var(--accent-dark); padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; text-align: center; }

/* ========================= */
/*       CODICE E MODALE     */
/* ========================= */

pre { max-width: 100%; background: #141a22; border: 1px solid #364152; color: #d7e0ea; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; font-size: 12.5px; line-height: 1.6; margin: 0 0 16px; text-align: left; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 24px rgba(15, 23, 42, 0.12); }
pre code { color: #c9d1d9; }
pre:last-child { margin-bottom: 0; }
.code-token-key { color: #7ee787; }
.code-token-string { color: #a5d6ff; }
.code-token-number { color: #ffa657; }
.code-token-keyword { color: #ff7b72; }
.code-token-punctuation { color: #d2a8ff; }
.response-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 16px; color: #ffffff; font-size: 14px; font-weight: 700; background: var(--accent-dark); border: 1px solid rgba(35, 139, 96, 0.24); border-radius: var(--radius-sm); box-shadow: 0 10px 20px rgba(35, 139, 96, 0.14); }
.response-button:hover { background: #1b754f; }
.response-dialog { width: min(960px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 28px 80px rgba(15, 23, 42, 0.26); }
.response-dialog::backdrop { background: rgba(15, 23, 42, 0.58); backdrop-filter: blur(3px); }
.response-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.response-dialog-header h2 { margin: 0; font-size: 17px; text-align: center; }
.modal-close { min-height: 34px; padding: 7px 12px; color: #ffffff; font-size: 13px; font-weight: 700; background: var(--danger); border: 1px solid rgba(194, 65, 59, 0.35); border-radius: var(--radius-sm); }
.response-dialog-body { max-height: calc(100vh - 140px); overflow: auto; padding: 16px; }
.response-dialog-body pre { margin: 0; }
.footer { display: flex; justify-content: center; padding: 18px 24px; color: var(--muted); border-top: 1px solid var(--border); background: rgba(255, 255, 255, 0.82); margin-top: 32px; text-align: center; font-size: 14px; }

/* ========================= */
/*       ACCESSIBILITA       */
/* ========================= */

@media (max-width: 700px) {
    .topbar { flex-wrap: wrap; gap: 8px; }
    .topbar-meta { gap: 12px; }
    .topbar-meta > span { display: none; }
    .page { padding: 24px 12px 48px; }
    .hero { padding: 22px; }
    .meta-grid, .index-links { grid-template-columns: 1fr; }
    .filter-control { flex-direction: column; }
    .filter-input { flex: auto; }
    .endpoint-path { width: 100%; font-size: 12px; }
    .index-link { flex-direction: column; }
    .index-link strong { font-size: 13px; }
    .limit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-panel { padding: 28px; }
    .login-panel h1 { font-size: 24px; }
    .card { padding-left: 12px; padding-right: 12px; }
    th, td { padding: 9px 8px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
