/* ===========================
   SMART AUTO-ADJUST
   Profile buttons + analysis popup
   =========================== */

/* ── Profile Button Group ── */

.saa-profile-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 10px;
    padding: 6px 0;
    background: linear-gradient(90deg, #3b82f6, #a78bfa, #3b82f6);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.saa-guide-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid rgba(96, 165, 250, 0.5);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    -webkit-text-fill-color: #60a5fa;
    transition: all 0.2s;
    flex-shrink: 0;
}

.saa-guide-tip:hover {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
    transform: scale(1.1);
}

.saa-profile-btn {
    position: relative;
    padding: 10px 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(30, 41, 59, 0.7);
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.saa-profile-btn:hover {
    transform: translateY(-2px);
}

.saa-profile-btn.saa-hd {
    border-color: rgba(245, 158, 11, 0.3);
}
.saa-profile-btn.saa-hd:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.2);
}

.saa-profile-btn.saa-sd {
    border-color: rgba(139, 92, 246, 0.3);
}
.saa-profile-btn.saa-sd:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.2);
}

.saa-profile-name {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #e2e8f0;
}

.saa-hd .saa-profile-name { color: #fbbf24; }
.saa-sd .saa-profile-name { color: #a78bfa; }

/* ── Tooltips ── */

.saa-profile-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    position: relative;
    z-index: 10;
}

.saa-profile-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    width: calc(200% + 6px);
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.97);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    color: #cbd5e1;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
}

/* Position tooltip to span full width of the group */
.saa-profile-btn:nth-child(1) .saa-profile-tooltip { left: 0; right: auto; }
.saa-profile-btn:nth-child(2) .saa-profile-tooltip { right: 0; left: auto; }

.saa-profile-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(15, 23, 42, 0.97);
}

/* Adjust arrow to point at the hovered button */
.saa-profile-btn:nth-child(1) .saa-profile-tooltip::before { left: 25%; }
.saa-profile-btn:nth-child(2) .saa-profile-tooltip::before { left: 75%; }

.saa-profile-btn:hover .saa-profile-tooltip {
    display: block;
}

/* ── Popup Container ── */

#smart-adjust-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}
#smart-adjust-popup.saa-visible {
    opacity: 1;
    pointer-events: auto;
}
#smart-adjust-popup.saa-closing {
    opacity: 0;
    transition: opacity 0.35s ease;
}

.saa-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.saa-card {
    position: relative;
    width: 320px;
    background: linear-gradient(165deg, rgba(15, 23, 42, 0.97) 0%, rgba(30, 41, 59, 0.95) 100%);
    border: 1px solid rgba(96, 165, 250, 0.25);
    border-radius: 16px;
    padding: 28px 24px 22px;
    box-shadow: 0 0 60px rgba(59, 130, 246, 0.15), 0 25px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transform: scale(0.92) translateY(12px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.saa-visible .saa-card { transform: scale(1) translateY(0); }
.saa-closing .saa-card { transform: scale(0.95) translateY(8px); }
.saa-card.saa-done {
    border-color: rgba(52, 211, 153, 0.4);
    box-shadow: 0 0 60px rgba(52, 211, 153, 0.12), 0 25px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* ── Close Button ── */

.saa-close-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1;
}

.saa-close-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
    transform: scale(1.1);
}

/* ── Popup Header ── */

.saa-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}
.saa-laser-icon { flex-shrink: 0; }
.saa-header-text { display: flex; flex-direction: column; gap: 2px; }

.saa-ring {
    animation: saaRingSpin 2.4s linear infinite;
    transform-origin: 20px 20px;
}
@keyframes saaRingSpin { to { transform: rotate(360deg); } }

.saa-core { animation: saaCorePulse 1.2s ease-in-out infinite alternate; }
@keyframes saaCorePulse {
    from { r: 3; opacity: 0.7; }
    to   { r: 5; opacity: 1; }
}

.saa-done .saa-ring { animation: none; stroke: #34d399; }
.saa-done .saa-core { animation: none; fill: #34d399; r: 4; }

.saa-title {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: #e2e8f0;
}
.saa-subtitle {
    font-size: 11px;
    color: #64748b;
    letter-spacing: 0.3px;
}
.saa-done .saa-title::after { content: ' ✓'; color: #34d399; }

/* ── Histogram ── */

.saa-histogram-area {
    position: relative;
    height: 80px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.1);
    overflow: hidden;
}
#saa-histogram-canvas { display: block; width: 100%; height: 100%; }

.saa-scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    animation: saaScanSweep 1.6s ease-in-out infinite;
}
@keyframes saaScanSweep {
    0%   { left: -2px; opacity: 0; }
    5%   { opacity: 1; }
    95%  { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}
.saa-done .saa-scan-line { animation: none; opacity: 0; }

/* ── Metrics ── */

.saa-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin-bottom: 18px;
}
.saa-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.08);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.saa-metric.saa-revealed { opacity: 1; transform: translateY(0); }
.saa-metric-label {
    font-size: 11px; font-weight: 500; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.saa-metric-value {
    font-size: 13px; font-weight: 700; color: #60a5fa;
    font-variant-numeric: tabular-nums;
}
.saa-done .saa-metric-value { color: #34d399; }

/* ── Progress ── */

.saa-progress-track {
    height: 3px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 2px;
    margin-bottom: 14px;
    overflow: hidden;
}
.saa-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    transition: width 0.3s ease;
}
.saa-done .saa-progress-fill { background: linear-gradient(90deg, #34d399, #10b981) !important; }

/* ── Status ── */

.saa-status {
    font-size: 12px;
    color: #64748b;
    text-align: center;
    letter-spacing: 0.3px;
}
.saa-done .saa-status { color: #34d399; }

/* ── CLAIRE Toggle Button ── */

.claire-btn {
    position: relative;
    width: 100%;
    padding: 10px 20px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 6px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.claire-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.97);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.5;
    color: #cbd5e1;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: none;
}

.claire-tooltip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(15, 23, 42, 0.97);
}

.claire-btn:hover .claire-tooltip {
    display: block;
}

.claire-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #e2e8f0;
}

.claire-btn.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
    border-color: #60a5fa;
    color: #60a5fa;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.2);
}

.claire-btn.active:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.35) 0%, rgba(139, 92, 246, 0.35) 100%);
}

/* ── Responsive ── */

@media (max-width: 400px) {
    .saa-card { width: calc(100vw - 40px); padding: 22px 18px 18px; }
    .saa-profile-tooltip { width: 180px; }
}
