/* ==========================================================================
   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(34, 197, 94, 0.6);
    animation: pulse-dot 1.8s ease-out infinite;
}

@keyframes pulse-dot {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 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;
}

/* ---------- 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; }
}
