/*
 * Portale WP Dashboard PBI — login e dashboard.
 * I colori tematizzabili sono variabili CSS: il valore di :root lo stampa
 * WDPBI_Theme::print_portal_styles(). I default vivono in
 * WDPBI_Theme::TOKENS (includes/class-theme.php), non qui.
 */

/* ── Comuni ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--wdpbi-bg);
    color: var(--wdpbi-text);
}

/* ── Login ── */
.wdpbi-login {
    background: var(--wdpbi-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.wdpbi-login::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 50%, var(--wdpbi-glow-1) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, var(--wdpbi-glow-2) 0%, transparent 50%),
                radial-gradient(circle at 50% 80%, var(--wdpbi-glow-3) 0%, transparent 50%);
    animation: bgShift 12s ease-in-out infinite alternate;
    z-index: 0;
}
@keyframes bgShift {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-3%, 2%) scale(1.05); }
    100% { transform: translate(2%, -2%) scale(1); }
}
.login-container {
    position: relative;
    z-index: 1;
    background: var(--wdpbi-surface);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--wdpbi-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.07);
    padding: 48px 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
}
.login-header {
    text-align: center;
    margin-bottom: 32px;
}
.login-header h1 {
    color: var(--wdpbi-text);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.login-header p {
    color: var(--wdpbi-text-muted);
    font-size: 14px;
    font-weight: 400;
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    color: var(--wdpbi-text-muted);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 10px 12px;
    background: var(--wdpbi-input-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: var(--wdpbi-text);
    font-size: 14px;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
    font-family: inherit;
}
.form-group input:focus {
    border-color: var(--wdpbi-accent);
    background: rgba(9, 9, 11, 0.7);
}
.form-group input::placeholder {
    color: #71717b;
}
.btn-login {
    width: 100%;
    padding: 10px;
    background: var(--wdpbi-btn-bg);
    color: var(--wdpbi-btn-text);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    font-family: inherit;
    margin-top: 4px;
}
.btn-login:hover {
    background: rgba(250, 250, 250, 1);
    transform: translateY(-1px);
}
.btn-login:active {
    transform: translateY(0);
}
.login-credits {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 11px;
    color: #71717a;
}
.login-credits a {
    color: var(--wdpbi-link);
    text-decoration: none;
}
.login-credits a:hover {
    color: var(--wdpbi-link-hover);
}
.error-message {
    background: rgba(45, 18, 21, 0.7);
    border: 1px solid rgba(92, 43, 46, 0.6);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}
.privacy-consent {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.privacy-consent input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--wdpbi-text);
    flex-shrink: 0;
}
.privacy-consent label {
    font-size: 13px;
    line-height: 1.6;
    color: var(--wdpbi-text-muted);
    font-weight: 400;
}
.privacy-consent a {
    color: var(--wdpbi-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.privacy-consent a:hover {
    color: var(--wdpbi-link-hover);
}

/* ── Dashboard ── */
html.wdpbi-dashboard {
    height: 100%;
    overflow: hidden;
    background: var(--wdpbi-bg);
}
.wdpbi-dashboard {
    height: 100%;
    overflow: hidden;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--wdpbi-surface);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    height: 52px;
    padding: 0 20px;
    border-bottom: 1px solid var(--wdpbi-border);
    position: relative;
    z-index: 10;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Tabs ── */
.tab-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #a1a1aa;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    font-family: inherit;
    position: relative;
}
.tab-btn:hover {
    color: var(--wdpbi-text);
    background: rgba(255, 255, 255, 0.06);
}
.tab-btn.active {
    color: var(--wdpbi-text);
    background: var(--wdpbi-border);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ── Dashboard title (single) ── */
.dashboard-title {
    color: var(--wdpbi-text);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ── User avatar ── */
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* ── Topbar buttons ── */
.topbar-btn {
    padding: 6px 12px;
    background: transparent;
    color: #a1a1aa;
    border: 1px solid var(--wdpbi-border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.topbar-btn:hover {
    color: var(--wdpbi-text);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.18);
}
.topbar-btn.btn-bug-report:hover {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.06);
}
.topbar-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ── Iframe area ── */
.iframe-container {
    height: calc(100vh - 52px);
    position: relative;
}
.iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: relative;
    z-index: 1;
}

/* ── Loading skeleton ── */
.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: var(--wdpbi-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loading-shimmer {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.shimmer-bar {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #18181b 25%, #27272a 50%, #18181b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.shimmer-bar:nth-child(1) { width: 100%; }
.shimmer-bar:nth-child(2) { width: 75%; animation-delay: 0.1s; }
.shimmer-bar:nth-child(3) { width: 60%; animation-delay: 0.2s; }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.loading-text {
    color: #52525b;
    font-size: 13px;
    font-weight: 400;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ── Empty state ── */
.no-dashboards {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100vh - 52px);
    gap: 16px;
    padding: 32px;
}
.no-dashboards-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--wdpbi-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}
.no-dashboards-icon svg {
    width: 28px;
    height: 28px;
    color: #52525b;
}
.no-dashboards h3 {
    color: var(--wdpbi-text-muted);
    font-size: 16px;
    font-weight: 600;
}
.no-dashboards p {
    color: #71717a;
    font-size: 14px;
    max-width: 320px;
    text-align: center;
    line-height: 1.5;
}

/* ── Bug modal ── */
.bug-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.bug-modal-overlay.active {
    display: flex;
}
.bug-modal {
    background: rgba(39, 39, 42, 0.85);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--wdpbi-border);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    padding: 32px;
    position: relative;
}
.bug-modal h2 {
    color: var(--wdpbi-text);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.bug-modal h2 svg {
    width: 20px;
    height: 20px;
    color: #fbbf24;
}
.bug-modal label {
    display: block;
    color: var(--wdpbi-text-muted);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}
.bug-modal input[type="text"],
.bug-modal textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--wdpbi-input-bg);
    border: 1px solid var(--wdpbi-border);
    border-radius: 8px;
    color: var(--wdpbi-text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}
.bug-modal input[type="text"]:focus,
.bug-modal textarea:focus {
    border-color: var(--wdpbi-accent);
    background: rgba(9, 9, 11, 0.7);
}
.bug-modal input[type="text"]::placeholder,
.bug-modal textarea::placeholder {
    color: #52525b;
}
.bug-modal textarea {
    min-height: 120px;
    resize: vertical;
}
.bug-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}
.bug-modal .btn-send {
    padding: 8px 20px;
    background: var(--wdpbi-btn-bg);
    color: var(--wdpbi-btn-text);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, transform 0.15s;
}
.bug-modal .btn-send:hover {
    background: rgba(250, 250, 250, 1);
    transform: translateY(-1px);
}
.bug-modal .btn-send:active {
    transform: translateY(0);
}
.bug-modal .btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.bug-modal .btn-cancel {
    padding: 8px 20px;
    background: transparent;
    color: var(--wdpbi-text-muted);
    border: 1px solid var(--wdpbi-border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}
.bug-modal .btn-cancel:hover {
    border-color: rgba(255, 255, 255, 0.20);
    color: var(--wdpbi-text);
}
.bug-modal-feedback {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    margin-bottom: 16px;
    display: none;
}
.bug-modal-feedback.success {
    display: block;
    background: rgba(5, 46, 22, 0.7);
    border: 1px solid rgba(22, 101, 52, 0.6);
    color: #86efac;
}
.bug-modal-feedback.error {
    display: block;
    background: rgba(45, 18, 21, 0.7);
    border: 1px solid rgba(92, 43, 46, 0.6);
    color: #fca5a5;
}
