/* ============================================================
   🎨 CONFIGURAZIONE GRAFICA
   ============================================================ */
:root {
    --primary-color: #005b8e;
    --secondary-color: #6c757d;
    --error-color: #dc3545;
    --page-bg-color: #e9ecef;
    --font-ui: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --font-doc: 'Times New Roman', Times, serif;

    /* NOTA: --rtm-tablet-text-color è iniettata da PHP.
       Qui NON la definiamo per evitare conflitti di priorità CSS. */
}

/* =========================================
   ADMIN STYLES (Backend)
   ========================================= */
.description{margin: 2px 0 5px; color: #000 !important; background-color: #ffffff !important; padding: 5px !important;}
.rtm-field-row { background: #fff; padding: 15px; border: 1px solid #ddd; margin-bottom: 10px; display: flex; gap: 20px; border-radius: 4px; align-items: flex-start; }
.rtm-field-left { flex: 2; }
.rtm-field-right { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.rtm-field-statement { width: 100%; height: 80px; border: 1px solid #ccc; padding: 5px; font-family: sans-serif; }

/* TABELLA DARK */
.rtm-dark-table.widefat { border: none; box-shadow: none; background: transparent; }
.rtm-dark-table.widefat thead th { background-color: #1e1e2f; color: #f0f0f1; border-bottom: 2px solid #4d4d6e; }
.rtm-dark-table.widefat tbody td { background-color: #2c2c4a; color: #a0a0b8; border-bottom: 1px solid #4d4d6e; }
.rtm-dark-table strong { color: #fff; }
.button-delete { background-color: #d63638!important; color: #fff!important; border-color: #d63638!important; }

/* =========================================
   FRONTEND / KIOSK STYLES
   ========================================= */

body {
    background-color: var(--page-bg-color);
    background-image: var(--bg-image, none);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    margin: 0;

    /* Applica colore personalizzato al body generale con fallback nero */
    color: var(--rtm-tablet-text-color, #000000);
}

.rtm-tablet-wrapper {
    font-family: var(--font-doc);
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px; /* Spazio per il footer */
}

/* --- BURGER MENU STYLES --- */
#rtm-burger-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.rtm-burger-icon {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    color: var(--primary-color);
}

#rtm-burger-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--error-color);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    font-family: var(--font-ui);
}

#rtm-burger-list {
    position: absolute;
    top: 60px;
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    display: none; /* Nascosto di default */
    overflow: hidden;
    font-family: var(--font-ui);
}

#rtm-burger-list.open {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.rtm-burger-header {
    background: var(--primary-color);
    color: #fff;
    padding: 12px 15px;
    font-weight: bold;
    font-size: 16px;
    text-transform: uppercase;
}

#rtm-pending-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
}

#rtm-pending-list li {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    color: #333;
}

#rtm-pending-list li:hover {
    background-color: #f8f9fa;
}

#rtm-pending-list li strong {
    display: block;
    font-size: 16px;
    margin-bottom: 4px;
}

#rtm-pending-list li span {
    display: block;
    font-size: 13px;
    color: #666;
    font-style: italic;
    line-height: 1.3;
}

#rtm-no-pending {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* -------------------------------------------------------------------------- */

.rtm-step { min-height: 80vh; }

/* STEP 1: RICERCA */
.rtm-search-container {
    text-align: center;
    padding-top: 15vh;
    font-family: var(--font-ui);
}

/* Forza il colore scelto su Titoli e Paragrafi delle schermate UI */
.rtm-search-container h1,
.rtm-search-container p,
#rtm-step-success h2,
#rtm-step-success p {
    color: var(--rtm-tablet-text-color, #000000) !important;
}

.rtm-logo-tablet { max-width: 200px; margin-bottom: 20px; }
.rtm-search-box { margin-top: 30px; position: relative; max-width: 600px; margin-left: auto; margin-right: auto; }

#rtm-speaker-search {
    width: 100%;
    font-size: 24px;
    padding: 20px;
    border: 2px solid var(--primary-color);
    border-radius: 50px;
    box-sizing: border-box;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    outline: none;
    transition: all 0.3s ease;

    /* L'input search meglio lasciarlo sempre leggibile (sfondo bianco, testo scuro) */
    background: rgba(255, 255, 255, 0.9);
    color: #333 !important;
}

#rtm-speaker-search:focus { box-shadow: 0 8px 25px rgba(0,0,0,0.15); transform: scale(1.02); }

#rtm-search-results {
    list-style: none;
    margin: 15px 0 0;
    padding: 0;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    text-align: left;
    border-radius: 12px;
    overflow: hidden;
    color: #333 !important; /* Dropdown sempre scuro */
}

#rtm-search-results li { padding: 20px 25px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 18px; transition: background 0.2s; color: #333; }
#rtm-search-results li:hover { background: #f8f9fa; }

/* STEP 2: FOGLIO A4 (IL PDF) */
.rtm-form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-family: var(--font-ui); }

/* --- IMPORTANTE: IL FOGLIO DEVE RIMANERE NERO PER LA STAMPA --- */
.rtm-paper-sheet {
    background: #fff;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    margin-bottom: 40px;
    border: 1px solid #ddd;
    font-size: 13px;
    line-height: 1.4;
    position: relative;

    /* FORZA COLORE NERO */
    color: #000000 !important;
}

/* Assicuriamo che anche i titoli dentro il PDF siano neri */
.rtm-paper-sheet h1,
.rtm-paper-sheet h2,
.rtm-paper-sheet h3,
.rtm-paper-sheet p,
.rtm-paper-sheet label {
    color: #000000 !important;
}

/* Header & Footer Doc */
.rtm-doc-header { margin-bottom: 20px; text-align: center; }
.rtm-doc-header img { max-width: 100%; height: auto; } /* Fix Altezza Immagini */

.rtm-doc-header h1 { font-size: 24px; text-transform: uppercase; margin: 10px 0; }
.rtm-doc-footer { margin-top: 30px; padding-top: 15px; border-top: 1px solid #000; text-align: center; font-size: 10px; color: #666; }
.rtm-doc-body { margin-bottom: 20px; text-align: justify; }

/* PAGE BREAK MARKER */
.rtm-page-break-marker {
    display: block;
    width: 100%;
    clear: both;
    background: transparent;
}

/* Privacy */
.rtm-privacy-block { margin: 15px 0; padding: 15px; background: #f8f9fa; border-left: 4px solid var(--primary-color); border-radius: 4px; transition: all 0.3s; color: #000; }
.rtm-privacy-text { font-weight: bold; margin-bottom: 10px; font-size: 12px; text-align: justify; }
.rtm-privacy-options { display: flex; justify-content: flex-start; gap: 20px; }
.rtm-privacy-options label { cursor: pointer; display: flex; align-items: center; font-size: 13px; }
.rtm-privacy-options input { margin-right: 8px; transform: scale(1.3); cursor: pointer; }

/* Firma */
.rtm-signature-block { margin-top: 50px; }
.sig-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; }
.sig-col-left { display: flex; flex-direction: column; flex: 0 0 auto; width: fit-content; min-width: 150px; }
.sig-col-right { display: flex; flex-direction: column; flex: 1; }
.sig-input-wrapper { border-bottom: 1px solid #000; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; margin-bottom: 5px; position: relative; width: 100%; transition: border-color 0.3s; }
.rtm-place-prefix, #rtm-place-date-fill { font-size: 16px; white-space: nowrap; color: #000; }
canvas#rtm-signature-pad { display: block; width: 100%; height: 120px; background-color: #0000000f !important; border: none; vertical-align: bottom; }
.sig-label { text-align: center; font-weight: bold; font-size: 14px; color: #333; margin: 0; }

/* Action Bar */
.rtm-actions-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; padding: 15px 20px; border-top: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 -5px 20px rgba(0,0,0,0.1); font-family: var(--font-ui); z-index: 1000; }
.button { padding: 12px 25px; border-radius: 6px; font-size: 16px; cursor: pointer; font-weight: 600; text-transform: uppercase; transition: all 0.2s; }
.button-large { font-size: 18px !important; padding: 15px 40px !important; }
.button-primary { background: var(--primary-color); color: #fff; border: none; }
.button-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.button-primary:disabled { background: #ccc; cursor: not-allowed; transform: none; }
.button-secondary { background: #fff; border: 2px solid var(--secondary-color); color: var(--secondary-color); }
.button-secondary:hover { background: var(--secondary-color); color: #fff; }

/* Loading */
#rtm-loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.95); z-index: 99999; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.rtm-spinner { width: 60px; height: 60px; border: 5px solid #e0e0e0; border-top: 5px solid var(--primary-color); border-radius: 50%; animation: rtm-spin 1s linear infinite; }
.rtm-loading-text { margin-top: 25px; font-size: 22px; color: var(--primary-color); font-family: var(--font-ui); text-align: center; font-weight: bold; }
#rtm-step-success { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; font-family: var(--font-ui); }
.rtm-success-icon { font-size: 80px; margin-bottom: 20px; animation: bounce 0.5s; }
@keyframes rtm-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes bounce { 0%, 20%, 50%, 80%, 100% {transform: translateY(0);} 40% {transform: translateY(-30px);} 60% {transform: translateY(-15px);} }

/* VALIDAZIONE ERRORI */
.rtm-error-border { border: 2px solid var(--error-color) !important; background-color: #fff5f5 !important; border-radius: 4px; }
.sig-input-wrapper.rtm-error-border { border-bottom: 2px solid var(--error-color) !important; border-top: none !important; border-left: none !important; border-right: none !important; background: transparent !important; }
.rtm-error-text { color: var(--error-color); font-size: 12px; margin-top: 5px; font-weight: bold; display: block; animation: fadeIn 0.3s; }

/* TOAST NOTIFICATION */
#rtm-toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 2px;
    padding: 16px;
    position: fixed;
    z-index: 99999;
    left: 50%;
    bottom: 80px;
    font-size: 17px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
#rtm-toast.show {
    visibility: visible;
    -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 80px; opacity: 1;} }
@keyframes fadeout { from {bottom: 80px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* --- FIX PER SFONDO MOBILE --- */
body {
    background-image: none !important;
    background-color: transparent !important;
}

#rtm-background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -10;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    pointer-events: none;
    transform: translateZ(0);
    will-change: transform;
}

/* ============================================================
   REDIRECT ANIMATION
   ============================================================ */
.rtm-redirect-loader {
    width: 200px;
    height: 6px; /* Aumentato per visibilità */
    background: #dcdcdc; /* Grigio chiaro visibile */
    margin: 20px auto;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.1); /* Bordo per delimitare l'area */
}

.rtm-redirect-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color, #005b8e); /* Fallback colore */
    animation: rtmProgress 3s linear forwards;
}

@keyframes rtmProgress {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* ============================================================
   SPONSORED & POWERED FOOTER (CSS ROBUSTO)
   ============================================================ */
.rtm-kiosk-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw; /* Usa l'intera larghezza dello schermo */
    box-sizing: border-box;
    display: flex !important;
    flex-direction: row !important; /* Forza sempre riga */
    justify-content: space-between !important; /* Estremi opposti */
    align-items: flex-end !important;
    padding: 10px 20px;
    z-index: 999;
    pointer-events: none;
    background: transparent;
}

.rtm-sponsored-by,
.rtm-powered-by {
    display: flex;
    flex-direction: column;
    font-family: var(--font-ui);
    color: var(--rtm-tablet-text-color, #000);
    font-size: 12px;
    opacity: 0.8;
    flex: 0 0 auto !important; /* Non crescere/restringere in modo anomalo */
    max-width: 45%; /* Evita sovrapposizioni al centro */
}

.rtm-sponsored-by {
    text-align: left;
    align-items: flex-start;
}

.rtm-powered-by {
    text-align: right;
    align-items: flex-end;
    margin-left: auto; /* Push forzato a destra */
}

.rtm-sponsored-by img,
.rtm-powered-by img {
    margin-top: 5px;
    display: block;
    max-width: 100%;
    height: auto;
}
