/**
 * DFN Mobile App & PWA Hub — Stylesheet (Flat Light Mode Default)
 * 
 * Interfaccia Mobile-First touch-optimized per gestione eventi,
 * QR scanner live, botteghino e tessere FAI.
 *
 * @package DFN_Theme
 * @since   2.1.3
 */

:root {
    --dfn-mobile-bg: #f8fafc;
    --dfn-mobile-card-bg: #ffffff;
    --dfn-mobile-card-border: #e2e8f0;
    --dfn-mobile-green: #004b23;
    --dfn-mobile-green-light: #059669;
    --dfn-mobile-red: #e74f30;
    --dfn-mobile-text-main: #0f172a;
    --dfn-mobile-text-sub: #64748b;
    --dfn-mobile-radius: 14px;
    --dfn-mobile-tab-height: 64px;
    --dfn-mobile-header-bg: #ffffff;
    --dfn-mobile-tabbar-bg: #ffffff;
    --dfn-mobile-tab-color: #64748b;
    --dfn-mobile-tab-active: #004b23;
    --dfn-mobile-input-bg: #ffffff;
    --dfn-mobile-input-border: #cbd5e1;
    --dfn-mobile-input-color: #0f172a;
    --dfn-mobile-icon-btn-bg: #f1f5f9;
    --dfn-mobile-icon-btn-color: #334155;
    --dfn-mobile-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --dfn-mobile-bg: #0f172a;
    --dfn-mobile-card-bg: #1e293b;
    --dfn-mobile-card-border: #334155;
    --dfn-mobile-green-light: #10b981;
    --dfn-mobile-text-main: #f8fafc;
    --dfn-mobile-text-sub: #94a3b8;
    --dfn-mobile-header-bg: rgba(15, 23, 42, 0.95);
    --dfn-mobile-tabbar-bg: rgba(15, 23, 42, 0.96);
    --dfn-mobile-tab-color: #64748b;
    --dfn-mobile-tab-active: #38bdf8;
    --dfn-mobile-input-bg: #0f172a;
    --dfn-mobile-input-border: #334155;
    --dfn-mobile-input-color: #ffffff;
    --dfn-mobile-icon-btn-bg: #334155;
    --dfn-mobile-icon-btn-color: #ffffff;
    --dfn-mobile-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* NASCONDI COMPONENTI INTRUSIVI IN MOBILE APP (WP Admin Bar, Cookiebot, Recaptcha) */
#wpadminbar,
.grecaptcha-badge,
#cookiebot-widget,
.cookiebot-banner,
#CookiebotWidget,
.cookie-bar,
#CybotCookiebotDialog,
#CybotCookiebotDialogBodyUnderlay,
#dfn-cookie-manage-link,
#dfn-cookie-banner-overlay,
#dfn-cookie-banner,
.dfn-privacy-consent-wrapper + .dfn-privacy-error-msg {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

html {
    margin-top: 0 !important;
}

/* Base Root Container */
#dfn-mobile-app-root,
.dfn-mobile-app-root {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--dfn-mobile-bg);
    color: var(--dfn-mobile-text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    padding-bottom: calc(var(--dfn-mobile-tab-height) + 24px + env(safe-area-inset-bottom));
    box-sizing: border-box;
}

/* HEADER MOBILE */
.dfn-mobile-app-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--dfn-mobile-header-bg);
    border-bottom: 1px solid var(--dfn-mobile-card-border);
    box-shadow: var(--dfn-mobile-shadow);
}

.dfn-mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dfn-mobile-logo-img {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.dfn-mobile-brand-titles h1 {
    font-size: 16px;
    font-weight: 800;
    margin: 0;
    color: var(--dfn-mobile-text-main);
    line-height: 1.2;
}

.dfn-mobile-brand-titles span {
    font-size: 11px;
    color: var(--dfn-mobile-text-sub);
    display: block;
}

.dfn-mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dfn-mobile-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--dfn-mobile-icon-btn-bg);
    color: var(--dfn-mobile-icon-btn-color);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

/* MAIN CONTAINER & TAB PANES */
.dfn-mobile-app-main {
    padding: 16px;
}

.dfn-mobile-tab-pane {
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.dfn-mobile-tab-pane.active {
    display: block;
    opacity: 1;
}

/* SCHEDE MOBILE (CARDS) */
.dfn-mobile-card {
    background: var(--dfn-mobile-card-bg);
    border: 1px solid var(--dfn-mobile-card-border);
    border-radius: var(--dfn-mobile-radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--dfn-mobile-shadow);
}

.dfn-mobile-card h3 {
    margin: 0 0 4px 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--dfn-mobile-text-main);
}

.dfn-mobile-card p.dfn-subtitle {
    margin: 0 0 16px 0;
    font-size: 12px;
    color: var(--dfn-mobile-text-sub);
}

/* RIEPILOGO UTENTE */
.dfn-user-summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--dfn-mobile-card-bg);
    border: 1px solid var(--dfn-mobile-card-border);
    border-left: 4px solid var(--dfn-mobile-green);
}

.dfn-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--dfn-mobile-green);
    color: #ffffff;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dfn-user-avatar.large {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

.dfn-user-info {
    flex: 1;
}

.dfn-user-info h2 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--dfn-mobile-text-main);
}

.dfn-user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 75, 35, 0.1);
    padding: 2px 8px;
    border-radius: 20px;
}

.dfn-role-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dfn-mobile-green);
}

.dfn-role-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--dfn-mobile-green);
}

.dfn-user-profile-btn {
    background: transparent;
    border: none;
    color: var(--dfn-mobile-text-sub);
    font-size: 20px;
    cursor: pointer;
}

/* STATISTICHE RAPIDE */
.dfn-mobile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.dfn-stat-pill {
    background: var(--dfn-mobile-card-bg);
    border: 1px solid var(--dfn-mobile-card-border);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--dfn-mobile-shadow);
    transition: transform 0.15s ease;
}

.dfn-stat-pill:active {
    transform: scale(0.96);
}

.dfn-stat-val {
    display: block;
    font-size: 20px;
    font-weight: 800;
    color: var(--dfn-mobile-text-main);
    line-height: 1.1;
}

.dfn-stat-lbl {
    display: block;
    font-size: 10px;
    color: var(--dfn-mobile-text-sub);
    margin-top: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

/* SEZIONI E BADGE */
.dfn-mobile-section {
    margin-bottom: 24px;
}

.dfn-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dfn-section-title h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--dfn-mobile-text-main);
}

.dfn-badge-count {
    background: var(--dfn-mobile-card-border);
    color: var(--dfn-mobile-text-main);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.dfn-mobile-cards-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* CARD ELEMENTI */
.dfn-event-card-item {
    padding: 14px;
    margin-bottom: 0;
}

.dfn-event-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.dfn-event-date-badge {
    font-size: 11px;
    font-weight: 700;
    color: #0284c7;
}

.dfn-event-status-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.dfn-event-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--dfn-mobile-text-main);
}

.dfn-event-location {
    font-size: 12px;
    color: var(--dfn-mobile-text-sub);
    margin: 0 0 12px 0;
}

.dfn-event-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.dfn-event-card-actions.three-col {
    grid-template-columns: repeat(3, 1fr);
}

.dfn-event-card-actions.three-col .dfn-mobile-btn {
    font-size: 11px;
    padding: 0 4px;
    height: 38px;
}

/* MODAL MOBILE CHECK-IN EVENTO (FULL SCREEN) */
.dfn-mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--dfn-mobile-bg);
    z-index: 20000;
    display: flex;
    flex-direction: column;
}

.dfn-mobile-modal-content {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom)) 16px;
    box-shadow: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.dfn-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--dfn-mobile-card-border);
}

.dfn-modal-header h3 {
    margin: 0;
    font-size: 17px;
    color: var(--dfn-mobile-text-main);
}

.dfn-modal-subtitle {
    font-size: 12px;
    color: var(--dfn-mobile-text-sub);
}

.dfn-modal-close-btn {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--dfn-mobile-text-sub);
    cursor: pointer;
    line-height: 1;
}

.dfn-mci-stats-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 14px 0 10px 0;
}

.dfn-mci-stat {
    background: var(--dfn-mobile-card-bg);
    border: 1px solid var(--dfn-mobile-card-border);
    border-radius: 10px;
    padding: 8px;
    text-align: center;
}

.dfn-mci-stat .val {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: var(--dfn-mobile-text-main);
}

.dfn-mci-stat.success .val { color: #059669; }
.dfn-mci-stat.warning .val { color: #d97706; }

.dfn-mci-stat .lbl {
    display: block;
    font-size: 10px;
    color: var(--dfn-mobile-text-sub);
    font-weight: 600;
}

.dfn-mci-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--dfn-mobile-card-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.dfn-mci-progress-fill {
    height: 100%;
    background: #059669;
    transition: width 0.3s ease;
}

.dfn-mci-search-box input {
    width: 100%;
    height: 42px;
    border-radius: 10px;
    background: var(--dfn-mobile-input-bg);
    border: 1px solid var(--dfn-mobile-input-border);
    color: var(--dfn-mobile-input-color);
    padding: 0 12px;
    font-size: 13px;
    box-sizing: border-box;
}

/* PRENOTAZIONI CARD */
.dfn-booking-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--dfn-mobile-card-border);
}

.dfn-customer-name {
    font-size: 15px;
    color: var(--dfn-mobile-text-main);
}

.dfn-booking-details p {
    font-size: 12px;
    margin: 3px 0;
    color: var(--dfn-mobile-text-sub);
}

.dfn-booking-actions,
.dfn-fai-actions {
    margin-top: 12px;
}

/* PULSANTI MOBILE */
.dfn-mobile-btn {
    width: 100%;
    height: 44px;
    border-radius: 10px;
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.15s ease, opacity 0.15s ease;
    box-sizing: border-box;
}

.dfn-mobile-btn:active {
    transform: scale(0.97);
}

.dfn-mobile-btn.large {
    height: 50px;
    font-size: 15px;
}

.dfn-mobile-btn.primary {
    background: var(--dfn-mobile-green);
    color: #ffffff;
}

.dfn-mobile-btn.secondary {
    background: #e2e8f0;
    color: #334155;
}

[data-theme="dark"] .dfn-mobile-btn.secondary {
    background: #334155;
    color: #ffffff;
}

.dfn-mobile-btn.success {
    background: #059669;
    color: #ffffff;
}

.dfn-mobile-btn.danger {
    background: var(--dfn-mobile-red);
    color: #ffffff;
}

/* FORM MOBILE */
.dfn-mobile-form .dfn-form-group {
    margin-bottom: 14px;
}

.dfn-mobile-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dfn-mobile-text-main);
    margin-bottom: 6px;
}

.dfn-mobile-form input[type="text"],
.dfn-mobile-form input[type="email"],
.dfn-mobile-form input[type="password"],
.dfn-mobile-form input[type="tel"],
.dfn-mobile-form input[type="number"],
.dfn-mobile-form select {
    width: 100%;
    height: 46px;
    border-radius: 10px;
    background: var(--dfn-mobile-input-bg);
    border: 1px solid var(--dfn-mobile-input-border);
    color: var(--dfn-mobile-input-color);
    padding: 0 12px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
}

.dfn-mobile-form input:focus,
.dfn-mobile-form select:focus {
    border-color: var(--dfn-mobile-green);
}

.dfn-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* SCANNER VIEWPORT COMPATTO & OTTIMIZZATO PER iOS/ANDROID */
.dfn-scanner-card {
    padding: 10px 12px;
}

.dfn-scanner-header {
    margin-bottom: 6px;
}

.dfn-scanner-header h3 {
    font-size: 15px;
    margin: 0 0 2px 0;
}

.dfn-scanner-header p {
    font-size: 11px;
    margin: 0;
    color: var(--dfn-mobile-text-sub);
}

.dfn-scanner-camera-viewport {
    position: relative;
    width: 100%;
    min-height: 250px;
    background: #000000;
    border-radius: 14px;
    overflow: hidden;
    margin: 6px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#dfn-mobile-qr-reader {
    width: 100% !important;
    border-radius: 14px;
    overflow: hidden;
    border: none !important;
}

#dfn-mobile-qr-reader video {
    width: 100% !important;
    height: auto !important;
    max-height: 380px !important;
    object-fit: contain !important;
    border-radius: 14px;
    display: block;
}

#dfn-mobile-qr-reader canvas {
    border-radius: 14px;
}

#dfn-mobile-qr-reader__scan_region {
    border-radius: 12px;
}

#dfn-mobile-qr-reader__dashboard_section {
    padding: 4px 0 !important;
}

/* SCANNER RESULT BOX & CARDS */
.dfn-scanner-result-box {
    margin-top: 8px;
}

.dfn-scan-card {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    text-align: left;
}

.dfn-scan-card.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    color: #065f46;
}

.dfn-scan-card.warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: #f59e0b;
    color: #78350f;
}

.dfn-scan-card.info {
    background: rgba(2, 132, 199, 0.1);
    border-color: #0284c7;
    color: #075985;
}

.dfn-scan-card.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #991b1b;
}

.dfn-scan-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.dfn-scan-badge.success { background: #10b981; color: #ffffff; }
.dfn-scan-badge.warning { background: #f59e0b; color: #ffffff; }
.dfn-scan-badge.info { background: #0284c7; color: #ffffff; }
.dfn-scan-badge.danger { background: #ef4444; color: #ffffff; }

.dfn-scan-card h4 {
    margin: 4px 0;
    font-size: 16px;
    font-weight: 700;
}

.dfn-scan-card p {
    margin: 3px 0;
    font-size: 13px;
}

.dfn-scan-amount-due {
    margin-top: 10px;
    padding: 10px 12px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px dashed #f59e0b;
    font-size: 14px;
    color: #b45309;
}

.dfn-scan-amount-due strong {
    font-size: 19px;
    color: #92400e;
}

/* PROFILE CARD */
.dfn-profile-card-header {
    text-align: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--dfn-mobile-card-border);
}

.dfn-profile-card-header .dfn-user-avatar {
    margin: 0 auto 10px auto;
}

.dfn-profile-card-header h3 {
    font-size: 18px;
    margin: 0 0 4px 0;
    color: var(--dfn-mobile-text-main);
}

.dfn-user-email {
    font-size: 12px;
    color: var(--dfn-mobile-text-sub);
    margin: 0 0 8px 0;
}

.dfn-role-name-tag {
    display: inline-block;
    background: var(--dfn-mobile-green);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
}

/* BOTTOM TAB BAR */
.dfn-mobile-tab-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: calc(var(--dfn-mobile-tab-height) + env(safe-area-inset-bottom));
    background: var(--dfn-mobile-tabbar-bg);
    border-top: 1px solid var(--dfn-mobile-card-border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 9999;
}

.dfn-tab-btn {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--dfn-mobile-tab-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dfn-tab-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.dfn-tab-lbl {
    font-size: 10px;
    font-weight: 600;
}

.dfn-tab-btn.active,
.dfn-tab-btn:hover {
    background-color: var(--dfn-mobile-green) !important;
    color: #ffffff !important;
}

.dfn-tab-btn.active .dashicons,
.dfn-tab-btn:hover .dashicons,
.dfn-tab-btn.active .dfn-tab-lbl,
.dfn-tab-btn:hover .dfn-tab-lbl {
    color: #ffffff !important;
}

/* LOGIN MOBILE SCREEN (FLAT LIGHT STYLING) */
.dfn-mobile-login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--dfn-mobile-bg);
    box-sizing: border-box;
}

.dfn-mobile-login-card {
    width: 100%;
    max-width: 380px;
    background: var(--dfn-mobile-card-bg);
    border: 1px solid var(--dfn-mobile-card-border);
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: var(--dfn-mobile-shadow);
}

.dfn-login-header {
    text-align: center;
    margin-bottom: 22px;
}

.dfn-login-logo-img {
    height: 52px;
    width: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto 14px auto;
}

.dfn-login-header h2 {
    font-size: 19px;
    font-weight: 800;
    margin: 0 0 6px 0;
    color: var(--dfn-mobile-text-main);
}

.dfn-login-header p {
    font-size: 12px;
    color: var(--dfn-mobile-text-sub);
    margin: 0;
}

/* EMPTY STATES */
.dfn-mobile-empty-state {
    text-align: center;
    padding: 20px;
    background: var(--dfn-mobile-card-bg);
    border: 1px dashed var(--dfn-mobile-card-border);
    border-radius: 10px;
    color: var(--dfn-mobile-text-sub);
    font-size: 13px;
}

/* TOAST */
.dfn-mobile-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: #0f172a;
    color: #ffffff;
    border: 1px solid #38bdf8;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
