/* === CSS Variables === */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --border-color: #2a2a3a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --accent-gold: #f0b90b;
    --accent-gold-dark: #c9960a;
    --accent-green: #00d395;
    --accent-green-dark: #00a876;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
    --gradient-gold: linear-gradient(135deg, #f0b90b 0%, #e6a800 100%);
    --gradient-green: linear-gradient(135deg, #00d395 0%, #00a876 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at top, rgba(240, 185, 11, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

.app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* === Header === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 7px;
}

.logo-icon {
    font-size: 36px;
    animation: float 3s ease-in-out infinite;
    color: var(--accent-gold);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo-text {
    font-size: 27px;
    font-weight: 700;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.network-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 14px;
    color: var(--text-secondary);
}

.network-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-red);
}

.network-badge.connected .network-dot {
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.connect-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--gradient-gold);
    border: none;
    border-radius: var(--radius-lg);
    color: #000;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.connect-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(240, 185, 11, 0.4);
}

.connect-btn.connected {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* === Stats Bar === */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease;
}

.stat-item:hover {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* === Main Content === */
.main-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    padding-bottom: 40px;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(240, 185, 11, 0.3);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
}

.card-header h2 svg {
    color: var(--accent-gold);
}

/* === Badges === */
.badge {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.badge-gold {
    background: rgba(240, 185, 11, 0.15);
    color: var(--accent-gold);
}

.badge-green {
    background: rgba(0, 211, 149, 0.15);
    color: var(--accent-green);
}

/* === Block Info (Mining) === */
.block-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.block-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.block-number {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.block-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 8px;
}

.block-miner {
    font-size: 14px;
    color: var(--text-secondary);
    word-break: break-all;
}

.timer-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.timer-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.timer {
    font-size: 36px;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.progress-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-gold);
    border-radius: 3px;
    transition: width 1s linear;
    width: 0%;
}

/* === Volume Stats === */
.volume-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.volume-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.volume-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.volume-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* === Balance Grid === */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.balance-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.balance-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.balance-value {
    font-size: 20px;
    font-weight: 700;
}

.balance-value.highlight {
    color: var(--accent-green);
}

/* === Staking Info === */
.staking-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stake-stat {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
}

.stake-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stake-value {
    font-size: 18px;
    font-weight: 600;
}

.stake-value.highlight {
    color: var(--accent-green);
}

/* === Input Groups === */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-with-btn {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.input-with-btn:focus-within {
    border-color: var(--accent-gold);
}

.input-with-btn input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 14px 16px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
}

.input-with-btn input::placeholder {
    color: var(--text-muted);
}

.input-suffix {
    padding: 0 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.max-btn {
    padding: 8px 16px;
    margin-right: 8px;
    background: rgba(240, 185, 11, 0.15);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-gold);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.max-btn:hover {
    background: rgba(240, 185, 11, 0.25);
}

/* === Buttons === */
.btn-group {
    display: flex;
    gap: 12px;
}

.staking-btns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-gold);
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(240, 185, 11, 0.4);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-gold);
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--gradient-green);
    color: #000;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 211, 149, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.btn-gold {
    background: var(--gradient-gold);
    color: #000;
}

.btn-gold:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(240, 185, 11, 0.4);
}

.full-width {
    width: 100%;
}

/* === Reward Slot === */
.reward-slot-info {
    margin-bottom: 24px;
}

.current-holder {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.holder-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.holder-address {
    font-size: 14px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--accent-gold);
    word-break: break-all;
}

.reward-slot-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-color: var(--accent-green);
}

.toast.error {
    border-color: var(--accent-red);
}

.toast.info {
    border-color: var(--accent-blue);
}

.toast-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast.success .toast-icon {
    background: rgba(0, 211, 149, 0.15);
    color: var(--accent-green);
}

.toast.error .toast-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.toast.info .toast-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* === Loading States === */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Responsive === */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
    }

    .connect-btn {
        width: 100%;
        justify-content: center;
    }

    .block-info {
        grid-template-columns: 1fr;
    }

    .balance-grid {
        grid-template-columns: 1fr;
    }

    .staking-info {
        grid-template-columns: 1fr;
    }

    .staking-btns {
        grid-template-columns: 1fr;
    }

    .btn-group {
        flex-direction: column;
    }

    .volume-stats {
        grid-template-columns: 1fr;
    }
}




/* === Mobile Fixes (320px - 480px) === */
@media (max-width: 480px) {
    /* Загальні відступи */
    .app {
        padding: 0 12px;
    }
    
    .header {
        padding: 16px 0;
        margin-bottom: 20px;
    }
    
    .logo-text {
        font-size: 25px;
    }
    
    .logo-icon {
        font-size: 28px;
    }
    
    .network-badge {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .connect-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    /* Stats bar - компактніше */
    .stats-bar {
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .stat-item {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    /* Cards - менші відступи */
    .card {
        padding: 20px 16px;
        border-radius: var(--radius-md);
    }
    
    .card-header {
        margin-bottom: 20px;
        padding-bottom: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .card-header h2 {
        font-size: 16px;
    }
    
    /* Block info - великі числа */
    .block-info {
        gap: 16px;
        margin-bottom: 20px;
    }
    
    .block-preview,
    .timer-section {
        padding: 16px;
    }
    
    .block-value {
        font-size: 24px;
    }
    
    .timer {
        font-size: 28px;
        line-height: 1.2;
    }
    
    .timer-label,
    .block-number {
        font-size: 11px;
    }
    
    /* Balance grid - гарантовано 1 колонка */
    .balance-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .balance-item {
        padding: 14px 12px;
    }
    
    .balance-value {
        font-size: 18px;
    }
    
    /* Staking info */
    .staking-info {
        grid-template-columns: 1fr !important;
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .stake-stat {
        padding: 14px;
    }
    
    .stake-value {
        font-size: 16px;
    }
    
    /* Inputs */
    .input-with-btn {
        align-items: stretch;
    }
    
    .input-with-btn input {
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .input-suffix {
        padding: 8px;
        text-align: center;
        font-size: 13px;
    }
    
    .max-btn {
        margin: 8px 8px;
        width: fit-content;
    }
    
    /* Buttons */
    .btn {
        padding: 12px 20px;
        font-size: 13px;
        width: 100%;
    }
    
    .btn-group,
    .staking-btns {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    
    /* Volume stats */
    .volume-stats {
        grid-template-columns: 1fr !important;
        gap: 10px;
        margin-top: 16px;
        padding-top: 16px;
    }
    
    .volume-item {
        padding: 10px;
    }
    
    .volume-value {
        font-size: 16px;
    }
    
    /* Reward slot */
    .holder-address {
        font-size: 12px;
    }
    
    .reward-slot-desc {
        font-size: 13px;
    }
    
    /* Toast */
    .toast {
        padding: 14px 16px;
        max-width: calc(100vw - 24px);
    }
    
    .toast-message {
        font-size: 13px;
    }
    
    /* Запобігання горизонтальному скролу */
    body, .app {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Довгі адреси та хеші */
    .block-miner,
    .holder-address,
    code,
    .monospace {
        word-break: break-all;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Градієнти та тіні - легші для продуктивності */
    .card:hover,
    .stat-item:hover {
        transform: none;
    }
    
    .connect-btn:hover,
    .btn-primary:hover:not(:disabled),
    .btn-success:hover:not(:disabled) {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* === Дуже вузькі екрани (320px) === */
@media (max-width: 360px) {
    .timer {
        font-size: 24px;
    }
    
    .block-value,
    .stat-value {
        font-size: 18px;
    }
    
    .logo-text {
        font-size: 25px;
    }
    
    .input-with-btn input {
        font-size: 14px;
    }
}

/* === Fix для Safari iOS (viewport fit) === */
@supports (-webkit-touch-callout: none) {
    .app {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .toast-container {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

.has-name {
    color: #00d395;
    font-weight: 700;
    font-size: 16px;
}

.has-vipname {
    color: gold;
    font-weight: 700;
    font-size: 16px;
}

.logo-badge {
    padding: 4px 8px;
    background: rgb(240 185 11 / 7%);
    /* border: 1px solid rgba(240, 185, 11, 0.3); */
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Відступ зверху, щоб відділити від контенту */
    padding: 12px 0px;
    border-top: 1px solid var(--border-color);
}

.footer-left {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.footer-right {
    opacity: 0.3; /* Версія зазвичай ще менш помітна */
}