/* ==========================================================================
   enhancements.css
   Additive UI/motion layer — loaded AFTER style.css.
   Nothing here renames or removes existing classes/IDs, so app.js / login.js
   keep working exactly as before. This file only adds nicer motion, depth,
   and a few opt-in utility classes (.reveal, .ripple, .skeleton, .btn-loading).
   ========================================================================== */

/* ---------- Global feel ---------- */
* {
    -webkit-tap-highlight-color: transparent;
}

body {
    animation: page-fade-in 0.5s ease both;
}

@keyframes page-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Smoother, springier screen transitions (overrides the ease-curve only) */
.screen {
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.45s cubic-bezier(0.16, 1, 0.3, 1) !important;
    filter: blur(6px);
}

.screen.active {
    filter: blur(0);
}

/* ---------- Cards: soft rise + glow on hover, gentle entrance ---------- */
.glass-card,
.stat-card,
.session-row {
    animation: card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
    will-change: transform;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Stagger cards that share a parent, purely via nth-child so no markup changes are needed */
.dashboard-content .glass-card:nth-child(1) { animation-delay: 0.02s; }
.dashboard-content .glass-card:nth-child(2) { animation-delay: 0.08s; }
.dashboard-content .glass-card:nth-child(3) { animation-delay: 0.14s; }
.dashboard-content .glass-card:nth-child(4) { animation-delay: 0.20s; }
.stat-card:nth-child(1) { animation-delay: 0.02s; }
.stat-card:nth-child(2) { animation-delay: 0.07s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.17s; }

.glass-card:hover {
    transform: translateY(-3px) !important;
    box-shadow:
        0 14px 36px rgba(0, 0, 0, 0.45),
        0 0 0 1px var(--glass-border),
        0 0 24px rgba(212, 212, 216, 0.06) !important;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(120px 80px at 50% 0%, rgba(255, 255, 255, 0.08), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-4px) scale(1.015) !important;
}

.stat-card i {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card:hover i {
    transform: scale(1.15) translateY(-2px);
}

/* ---------- Buttons: tactile press, sheen sweep, loading state ---------- */
.btn-primary,
.btn-icon,
.config-toggle-btn,
.tab {
    position: relative;
    overflow: hidden;
}

.btn-primary {
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease,
                opacity 0.2s ease,
                filter 0.2s ease !important;
}

.btn-primary::before {
    content: "";
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.22), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn-primary:hover::before {
    left: 130%;
}

.btn-primary:hover {
    box-shadow: 0 8px 26px var(--primary-glow), 0 0 0 1px rgba(255, 255, 255, 0.06);
    filter: brightness(1.06);
}

.btn-primary:active {
    transform: scale(0.965) !important;
}

.btn-icon:hover {
    transform: rotate(6deg) scale(1.08);
}

.btn-icon:active {
    transform: scale(0.9);
}

/* Optional loading state: add class="btn-loading" from JS while a request is in flight */
.btn-primary.btn-loading {
    color: transparent !important;
    pointer-events: none;
}

.btn-primary.btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--accent-text);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Ripple utility — enable by adding class="ripple" in markup or via JS */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-dot {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(255, 255, 255, 0.35);
    animation: ripple-out 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-out {
    to { transform: scale(2.6); opacity: 0; }
}

/* ---------- Tabs: sliding active indicator feel ---------- */
.tab {
    transition: color 0.25s ease, background 0.25s ease, transform 0.15s ease !important;
}

.tab:active {
    transform: scale(0.96);
}

.tab.active {
    animation: tab-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tab-pop {
    0%   { transform: scale(0.94); }
    60%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* ---------- Inputs: focus glow + label float feel ---------- */
.input-group,
.cfg-input,
input,
select,
textarea {
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease !important;
}

input:focus,
select:focus,
textarea:focus,
.cfg-input:focus {
    transform: translateY(-1px);
    box-shadow: 0 0 0 3px var(--primary-glow), 0 6px 18px rgba(0, 0, 0, 0.3) !important;
}

/* ---------- Status badges: subtle live pulse when online ---------- */
.status-badge.online {
    position: relative;
    padding-left: 22px !important;
}

.status-badge.online::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 50%;
    width: 7px;
    height: 7px;
    margin-top: -3.5px;
    border-radius: 50%;
    background: var(--status-online-color);
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6);
    animation: pulse-dot 1.8s ease-out infinite;
}

@keyframes pulse-dot {
    0%   { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* ---------- Modal: scale + blur entrance instead of a hard cut ---------- */
.modal-overlay {
    animation: overlay-in 0.25s ease both;
}

.modal-overlay .modal-card {
    animation: modal-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes overlay-in {
    from { opacity: 0; backdrop-filter: blur(0); }
    to   { opacity: 1; backdrop-filter: blur(4px); }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Toast: nicer spring ---------- */
#toast-stack > * {
    animation: toast-in-spring 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both,
               toast-out 0.3s ease forwards 2.7s !important;
}

@keyframes toast-in-spring {
    from { opacity: 0; transform: translateY(-14px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Avatar: subtle breathing glow ---------- */
.avatar,
.profile-avatar {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.avatar:hover,
.profile-avatar:hover {
    transform: scale(1.04);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ---------- Hamburger menu items already animate in; add a touch of easing ---------- */
.hamburger-menu a {
    transition: background 0.2s ease, transform 0.15s ease, padding-left 0.2s ease;
}

.hamburger-menu a:hover {
    padding-left: 6px;
}

/* ---------- Skeleton loading shimmer (opt-in via class="skeleton") ---------- */
.skeleton {
    position: relative;
    color: transparent !important;
    background: linear-gradient(
        100deg,
        var(--glass-bg) 40%,
        rgba(255, 255, 255, 0.08) 50%,
        var(--glass-bg) 60%
    );
    background-size: 200% 100%;
    animation: skeleton-sweep 1.4s ease-in-out infinite;
    border-radius: 8px;
    pointer-events: none;
}

@keyframes skeleton-sweep {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ---------- Scroll reveal utility (paired with enhancements.js) ---------- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Profile / pengguna info grid (ROLE, BERGABUNG, ID, BOT ACTIVE) ---------- */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
}

.info-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 14px 10px;
    border-radius: 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, border-color 0.25s ease;
    animation: card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.info-grid .info-cell:nth-child(1) { animation-delay: 0.02s; }
.info-grid .info-cell:nth-child(2) { animation-delay: 0.07s; }
.info-grid .info-cell:nth-child(3) { animation-delay: 0.12s; }
.info-grid .info-cell:nth-child(4) { animation-delay: 0.17s; }

.info-cell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
    opacity: 0.9;
}

.info-cell:hover {
    transform: translateY(-3px);
    border-color: var(--glass-border);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.info-cell > i {
    font-size: 1.05rem;
    color: var(--nebula-cyan);
    margin-bottom: 2px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.info-cell:hover > i {
    transform: scale(1.15) translateY(-1px);
}

.info-label {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.info-value {
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-value-mono {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: -0.01em;
}

.info-value-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.info-value-badges .role-badge-sm {
    animation: card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.info-value-online {
    color: var(--status-online-color);
}

.info-value-online::before {
    content: "●";
    font-size: 0.6em;
    margin-right: 5px;
    vertical-align: middle;
    animation: pulse-dot 1.8s ease-out infinite;
}

.info-value-offline {
    color: var(--text-muted);
}

@media (max-width: 340px) {
    .info-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .info-cell {
        padding: 12px 8px;
    }
}

/* ---------- Keyboard focus: visible ring on every interactive element ----------
   style.css only styled :focus on text inputs; buttons, tabs, links and the
   hamburger menu had no visible state at all for keyboard/switch users. */
button:focus-visible,
a:focus-visible,
.tab:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-icon:focus-visible,
.config-toggle-btn:focus-visible,
.session-select:focus-visible,
.hamburger-btn:focus-visible,
.hamburger-menu a:focus-visible,
.switch input:focus-visible + .slider {
    outline: 2px solid var(--nebula-violet);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Native select/inputs already get a focus ring via border-color, this just
   removes the default browser outline so it doesn't double up */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
}

/* ---------- Password visibility toggle ---------- */
.input-group.has-toggle input {
    padding-right: 44px;
}

.pw-toggle-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.18s ease, background 0.18s ease;
}

.pw-toggle-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

/* ---------- Password strength meter ---------- */
.pw-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -8px 0 16px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, max-height 0.2s ease;
}

.pw-strength.is-visible {
    opacity: 1;
    max-height: 30px;
}

.pw-strength-bar {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.pw-strength-bar span {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 4px;
    background: var(--danger, #ef4444);
    transition: width 0.25s ease, background 0.25s ease;
}

.pw-strength-label {
    font-size: 0.74rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 58px;
    text-align: right;
}

.pw-match-msg {
    font-size: 0.78rem;
    margin: -10px 0 14px;
    min-height: 0;
}

.pw-match-msg.pw-match-ok { color: #22c55e; }
.pw-match-msg.pw-match-bad { color: var(--danger, #ef4444); }

/* ==========================================================================
   Mobile bottom navigation — Dashboard / Bot Config / Connect / Feedback / Profile
   Fixed tab bar for small screens (hidden ≥900px, where the hamburger
   already covers navigation comfortably). "Connect" floats slightly above
   the bar as a raised circular button, per request ("atasan dikit").
   ========================================================================== */
.mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 150;
    display: none;
    align-items: flex-end;
    justify-content: space-around;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(0, 0, 0, .96);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-top: 1px solid var(--g-700, rgba(255, 255, 255, .16));
    gap: 0;
}

@media (max-width: 899px) {
    .mobile-bottom-nav { display: flex; }
    /* Keep page content from hiding behind the fixed bar */
    .dashboard-content,
    #config-content,
    #about-content,
    #pengguna-content,
    #admin-content {
        padding-bottom: 94px !important;
    }
    #toast-stack { bottom: 96px; }
}

.mbn-item {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 2px 4px;
    color: var(--text-muted);
    font-family: inherit;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color .25s ease;
}

.mbn-item .mbn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 1.02rem;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.mbn-item .mbn-label {
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
    opacity: .8;
    transition: opacity .25s ease;
}

/* Active tab: icon lifts + scales up, label brightens, small dot appears */
.mbn-item.is-active { color: var(--text-main); }
.mbn-item.is-active .mbn-icon { transform: translateY(-2px) scale(1.08); }
.mbn-item.is-active .mbn-label { opacity: 1; }
.mbn-item.is-active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--nebula-violet, #fff);
    transform: translateX(-50%) scale(0);
    animation: mbn-dot-in .3s cubic-bezier(.34, 1.56, .64, 1) forwards;
}

@keyframes mbn-dot-in {
    to { transform: translateX(-50%) scale(1); }
}

.mbn-item:active .mbn-icon { transform: scale(.86); }

/* Feedback / Profile open modals instead of switching tabs -- give them a
   quick tap-bounce instead of a persistent active state. */
.mbn-item.mbn-tapped .mbn-icon {
    animation: mbn-icon-tap .45s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes mbn-icon-tap {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.3) translateY(-4px); }
    100% { transform: scale(1) translateY(0); }
}

/* ---- Connect: raised center FAB ("atasan dikit") ---- */
.mbn-item-connect {
    flex: 0 0 auto;
    width: 68px;
    padding: 0;
    margin-top: -10px;
}

.mbn-connect-fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.08rem;
    color: var(--on-accent, #000);
    background: var(--nebula-violet, #fff);
    box-shadow: 0 0 0 5px rgba(0, 0, 0, .88), 0 6px 14px rgba(0, 0, 0, .45);
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
    animation: mbn-fab-pulse 2.6s ease-in-out infinite;
}

.mbn-item-connect .mbn-label {
    margin-top: 6px;
    color: var(--text-muted);
}

.mbn-item-connect:active .mbn-connect-fab { transform: scale(.9); }
.mbn-item-connect.mbn-tapped .mbn-connect-fab {
    animation: mbn-fab-tap .5s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes mbn-fab-pulse {
    0%, 100% { box-shadow: 0 0 0 5px rgba(0, 0, 0, .88), 0 6px 14px rgba(0, 0, 0, .45); }
    50%      { box-shadow: 0 0 0 5px rgba(0, 0, 0, .88), 0 6px 14px rgba(0, 0, 0, .45), 0 0 0 9px rgba(255, 255, 255, .06); }
}

@keyframes mbn-fab-tap {
    0%   { transform: scale(1) rotate(0); }
    40%  { transform: scale(.82) rotate(-8deg); }
    70%  { transform: scale(1.12) rotate(4deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Briefly outline the Connect card/panel when the FAB scrolls to it */
.mbn-pulse-target {
    animation: mbn-target-glow 1.5s ease;
    border-radius: 16px;
}

@keyframes mbn-target-glow {
    0%, 100% { outline: 2px solid rgba(255, 255, 255, 0); outline-offset: 6px; }
    20%      { outline: 2px solid rgba(255, 255, 255, .55); outline-offset: 3px; }
}

.mbn-item:focus-visible {
    outline: 2px solid var(--nebula-violet);
    outline-offset: 2px;
    border-radius: 10px;
}

@media (prefers-reduced-motion: reduce) {
    .mbn-connect-fab { animation: none; }
    .mbn-item, .mbn-icon, .mbn-label, .mbn-connect-fab { transition: none !important; }
}

/* ---------- Respect reduced-motion users ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .screen { filter: none !important; }
}
