/* ==========================================================================
   TRUSTRA DYNAMIC ISLAND - LUXURY APPLE-STYLE UI SYSTEM
   ========================================================================== */

:root {
    --di-bg: #000000;
    --di-border: rgba(255, 255, 255, 0.12);
    --di-shadow: 0 12px 35px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    --di-glow-blue: 0 0 25px rgba(37, 99, 235, 0.35);
    --di-glow-green: 0 0 25px rgba(34, 197, 94, 0.35);
    --di-glow-amber: 0 0 25px rgba(245, 158, 11, 0.35);
    --di-glow-red: 0 0 25px rgba(239, 68, 68, 0.35);
    --di-spring: cubic-bezier(0.16, 1, 0.3, 1);
    --di-spring-bouncy: cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* Safe area support for notch and edge-to-edge screens */
body.pwa-standalone {
    padding-top: env(safe-area-inset-top, 0px);
}

/* Dynamic Island Wrapper Container */
#dynamic-island-container {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    pointer-events: none; /* Pill elements will capture pointer */
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    user-select: none;
    -webkit-user-select: none;
}

/* The Dynamic Island Main Pill */
.dynamic-island {
    pointer-events: auto;
    background-color: var(--di-bg);
    color: #ffffff;
    border-radius: 24px;
    box-shadow: var(--di-shadow);
    border: 1px solid var(--di-border);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: width 0.42s var(--di-spring-bouncy), 
                height 0.42s var(--di-spring-bouncy), 
                border-radius 0.42s var(--di-spring),
                box-shadow 0.3s ease,
                background-color 0.3s ease,
                transform 0.25s var(--di-spring);
    transform-origin: center top;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    will-change: width, height, border-radius, transform;
}

.dynamic-island:hover {
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.22);
}

.dynamic-island:active {
    transform: scale(0.98);
}

/* ── COMPACT STATE (DEFAULT PILL) ────────────────────────── */
.dynamic-island.state-compact {
    width: 200px;
    height: 38px;
    padding: 0 12px;
    border-radius: 20px;
}

.dynamic-island.state-compact .di-compact-view {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.dynamic-island.state-compact .di-expanded-view,
.dynamic-island.state-compact .di-alert-view {
    display: none;
    opacity: 0;
}

/* Compact Left & Right elements */
.di-compact-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.di-shield-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563EB, #06B6D4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.di-shield-badge svg {
    width: 11px;
    height: 11px;
    color: #ffffff;
}

.di-compact-title {
    font-size: 11.5px;
    font-weight: 600;
    color: #F3F4F6;
    letter-spacing: -0.01em;
}

.di-compact-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.di-live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    color: #34D399;
}

.di-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: diPulse 2s infinite ease-in-out;
}

@keyframes diPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
}

/* ── EXPANDED STATE (INTERACTIVE WIDGET) ─────────────────── */
.dynamic-island.state-expanded {
    width: 360px;
    height: 185px;
    padding: 16px 18px;
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    cursor: default;
}

.dynamic-island.state-expanded .di-compact-view,
.dynamic-island.state-expanded .di-alert-view {
    display: none;
    opacity: 0;
}

.dynamic-island.state-expanded .di-expanded-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    opacity: 1;
    animation: diFadeIn 0.3s var(--di-spring) forwards;
}

/* Expanded Top Bar */
.di-exp-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.di-exp-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.di-exp-brand img {
    width: 22px;
    height: 22px;
}

.di-exp-brand-text {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #ffffff, #93C5FD);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.di-exp-status {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    color: #93C5FD;
}

.di-exp-close {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.di-exp-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Expanded Quick Stats & Actions */
.di-exp-balance-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 10px 14px;
    margin-bottom: 12px;
}

.di-exp-label {
    font-size: 10px;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.di-exp-balance {
    font-size: 17px;
    font-weight: 800;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
}

.di-exp-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.di-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 8px 4px;
    color: #E5E7EB;
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.di-action-btn:hover {
    background: rgba(37, 99, 235, 0.25);
    border-color: rgba(37, 99, 235, 0.4);
    color: #ffffff;
    transform: translateY(-2px);
}

.di-action-btn svg {
    width: 15px;
    height: 15px;
    color: #60A5FA;
}

/* ── ALERT & MORPHING EVENT STATE ────────────────────────── */
.dynamic-island.state-alert {
    width: 340px;
    height: 64px;
    padding: 10px 16px;
    border-radius: 24px;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.8), var(--di-glow-blue);
}

.dynamic-island.state-alert.type-success {
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.8), var(--di-glow-green);
    border-color: rgba(34, 197, 94, 0.35);
}

.dynamic-island.state-alert.type-warning {
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.8), var(--di-glow-amber);
    border-color: rgba(245, 158, 11, 0.35);
}

.dynamic-island.state-alert.type-danger {
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.8), var(--di-glow-red);
    border-color: rgba(239, 68, 68, 0.35);
}

.dynamic-island.state-alert .di-compact-view,
.dynamic-island.state-alert .di-expanded-view {
    display: none;
    opacity: 0;
}

.dynamic-island.state-alert .di-alert-view {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    opacity: 1;
    animation: diFadeIn 0.25s ease-out forwards;
}

.di-alert-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.di-alert-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.di-alert-icon-wrap.bg-success {
    background: linear-gradient(135deg, #059669, #10B981);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.di-alert-icon-wrap.bg-info {
    background: linear-gradient(135deg, #2563EB, #06B6D4);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.5);
}

.di-alert-icon-wrap.bg-warning {
    background: linear-gradient(135deg, #D97706, #F59E0B);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5);
}

.di-alert-icon-wrap.bg-danger {
    background: linear-gradient(135deg, #DC2626, #EF4444);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.di-alert-icon-wrap svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

.di-alert-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.di-alert-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.di-alert-subtitle {
    font-size: 11px;
    color: #9CA3AF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.di-alert-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.di-alert-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.di-alert-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Animations */
@keyframes diFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .dynamic-island.state-compact {
        width: 180px;
        height: 35px;
    }
    .dynamic-island.state-expanded {
        width: calc(100vw - 32px);
        max-width: 360px;
    }
    .dynamic-island.state-alert {
        width: calc(100vw - 32px);
        max-width: 350px;
    }
}
