/* ==========================================
   TEZOS.SYSTEMS - MINIMAL & ELEGANT
   Sophisticated Dashboard Design
   ========================================== */

/* ==========================================
   CSS Variables
   ========================================== */

:root {
    /* Refined dark theme */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;

    /* Minimal glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.02);
    --glass-border: rgba(255, 255, 255, 0.06);

    /* Elegant typography */
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-tertiary: #707080;
    --text-muted: #505060;

    /* Refined accent colors */
    --accent-cyan: #00d4ff;
    --accent-purple: #b794f6;
    --accent-pink: #ff6b9d;
    --accent-blue: #5b8def;

    /* Subtle effects */
    --blur-amount: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --glass-bg: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.12);
    --text-primary: #1a1a2e;
    --text-secondary: #3d3d4e;
    --text-tertiary: #5a5a6e;
    --text-muted: #8888a0;
    
    /* Light mode accent adjustments for better contrast */
    --accent-cyan: #0099cc;
    --accent-purple: #8b5cf6;
    --accent-pink: #db2777;
    --accent-blue: #2563eb;
}

/* ==========================================
   Reset & Base
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Subtle ambient gradient */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(at 20% 30%, rgba(0, 212, 255, 0.03) 0px, transparent 50%),
        radial-gradient(at 80% 70%, rgba(183, 148, 246, 0.03) 0px, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* ==========================================
   Header
   ========================================== */

.header {
    padding: 4rem 2rem 3rem;
    position: relative;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.75rem, 4vw, 3rem);
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.2;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(0, 212, 255, 0.3);
    position: relative;
}

.controls {
    display: flex;
    gap: 0.75rem;
}

.glass-button {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.glass-button:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.theme-icon {
    font-size: 1.2rem;
}

.refresh-icon {
    font-size: 1.3rem;
    display: inline-block;
    transition: transform 0.3s ease;
}

.glass-button.spinning .refresh-icon {
    animation: spin 1s ease-in-out;
}

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

/* ==========================================
   Main Content
   ========================================== */

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.stats-section {
    margin-bottom: 5rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.info-button {
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: var(--transition);
}

.info-button:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: scale(1.1);
}

.info-button svg {
    width: 16px;
    height: 16px;
}

/* ==========================================
   Stats Grid
   ========================================== */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==========================================
   Stat Cards - Minimal & Elegant
   ========================================== */

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 0;
    perspective: 1000px;
    min-height: 200px;
    position: relative;
    overflow: visible;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Subtle accent glow on hover */
.stat-card[data-stat="total-bakers"]:hover {
    box-shadow: 0 12px 40px rgba(0, 212, 255, 0.08);
}

.stat-card[data-stat="tz4-bakers"]:hover {
    box-shadow: 0 12px 40px rgba(183, 148, 246, 0.08);
}

.stat-card[data-stat="tz4-adoption"]:hover {
    box-shadow: 0 12px 40px rgba(255, 107, 157, 0.08);
}

.stat-card[data-stat="issuance-rate"]:hover {
    box-shadow: 0 12px 40px rgba(91, 141, 239, 0.08);
}

.stat-card[data-stat="tx-volume"]:hover {
    box-shadow: 0 12px 40px rgba(183, 148, 246, 0.08);
}

.stat-card[data-stat="staking-ratio"]:hover {
    box-shadow: 0 12px 40px rgba(0, 212, 255, 0.08);
}

.stat-card[data-stat="total-supply"]:hover {
    box-shadow: 0 12px 40px rgba(255, 107, 157, 0.08);
}

/* Card Info Button */
.card-info-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-tertiary);
    cursor: pointer;
    z-index: 50;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.6;
    pointer-events: auto;
}

.card-info-btn:hover {
    opacity: 1;
    background: rgba(0, 212, 255, 0.15);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: scale(1.15) rotate(15deg);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.card-info-btn:hover svg {
    animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 2px currentColor); }
    50% { filter: drop-shadow(0 0 8px currentColor); }
}

/* Card Tooltip */
.card-tooltip {
    position: absolute;
    top: 3rem;
    right: 0.5rem;
    width: 280px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transform-origin: top right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.card-info-btn:hover + .card-tooltip,
.card-tooltip:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.tooltip-content {
    padding: 1.25rem;
}

.tooltip-content h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tooltip-content p {
    margin: 0 0 1rem 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.tooltip-content a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: var(--accent-cyan);
    text-decoration: none;
    transition: all 0.2s ease;
}

.tooltip-content a:hover {
    color: var(--accent-purple);
    text-decoration: underline;
}

/* Tooltip Arrow */
.card-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 1rem;
    width: 12px;
    height: 12px;
    background: var(--bg-secondary);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

/* Light theme tooltip adjustments */
[data-theme="light"] .card-tooltip {
    background: white;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .card-tooltip::before {
    background: white;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .card-info-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .card-info-btn:hover {
    background: rgba(0, 153, 204, 0.15);
}

/* Light mode card enhancements */
[data-theme="light"] .stat-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .stat-card:hover {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .stat-label {
    color: #4a4a5a;
    font-weight: 600;
}

[data-theme="light"] .stat-description {
    color: #6a6a7a;
}

/* Light mode section titles */
[data-theme="light"] .section-title {
    color: #2a2a3a;
}

/* Light mode header */
[data-theme="light"] .header {
    background: linear-gradient(135deg, #f8f9fc 0%, #e8ebf0 100%);
}

[data-theme="light"] .title {
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

/* Light mode glass buttons */
[data-theme="light"] .glass-button {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #3d3d4e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .glass-button:hover {
    background: #f0f2f5;
    border-color: rgba(0, 0, 0, 0.2);
}

/* Light mode info buttons */
[data-theme="light"] .info-button {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #5a5a6e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .info-button:hover {
    background: #f0f2f5;
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

/* Light mode footer */
[data-theme="light"] .footer {
    background: #f0f2f5;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .footer a {
    color: var(--accent-cyan);
}

/* Light mode modal */
[data-theme="light"] .modal-content {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .modal-title {
    color: #1a1a2e;
}

[data-theme="light"] .modal-body p,
[data-theme="light"] .modal-body li {
    color: #3d3d4e;
}

[data-theme="light"] .modal-note {
    background: rgba(0, 153, 204, 0.08);
    border-color: var(--accent-cyan);
}

[data-theme="light"] .modal-links a {
    background: #f8f9fc;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #3d3d4e;
}

[data-theme="light"] .modal-links a:hover {
    background: #f0f2f5;
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Flip animation system */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    z-index: 1;
    pointer-events: none;
}

.card-front, .card-back {
    pointer-events: auto;
}

.stat-card.flipping .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 2.5rem 2rem;
    text-align: left;
}

.card-back {
    transform: rotateY(180deg);
    /* Hide from screen readers when not visible */
    visibility: hidden;
}

.stat-card.flipping .card-back {
    visibility: visible;
}

.stat-card.flipping .card-front {
    visibility: hidden;
}

/* Card content */
.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-value {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.75rem;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

/* Dual value styling for progress indicators (e.g., "37 / 130") */
.stat-value-dual {
    font-size: clamp(1.6rem, 3.5vw, 2.2rem);
}

/* Text-based stat values (proposal names, voting periods) */
.stat-value-text {
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    font-weight: 600;
    text-transform: capitalize;
}

/* Elegant accent colors for each stat */
.stat-card[data-stat="total-bakers"] .stat-value {
    color: var(--accent-cyan);
}

.stat-card[data-stat="tz4-bakers"] .stat-value {
    color: var(--accent-purple);
}

.stat-card[data-stat="tz4-adoption"] .stat-value {
    color: var(--accent-pink);
}

.stat-card[data-stat="issuance-rate"] .stat-value {
    color: var(--accent-blue);
}

.stat-card[data-stat="tx-volume"] .stat-value {
    color: var(--accent-purple);
}

.stat-card[data-stat="staking-ratio"] .stat-value {
    color: var(--accent-cyan);
}

.stat-card[data-stat="total-supply"] .stat-value {
    color: var(--accent-pink);
}

/* Governance colors */
.stat-card[data-stat="proposal"] .stat-value {
    color: var(--accent-cyan);
}

.stat-card[data-stat="voting-period"] .stat-value {
    color: var(--accent-purple);
}

.stat-card[data-stat="participation"] .stat-value {
    color: var(--accent-pink);
}

/* Economy additional colors */
.stat-card[data-stat="staking-apy"] .stat-value {
    color: #10b981;
}

.stat-card[data-stat="delegated"] .stat-value {
    color: var(--accent-purple);
}

.stat-card[data-stat="total-burned"] .stat-value {
    color: #f59e0b;
}

/* Network Activity colors */
.stat-card[data-stat="contract-calls"] .stat-value {
    color: var(--accent-cyan);
}

.stat-card[data-stat="funded-accounts"] .stat-value {
    color: var(--accent-pink);
}

/* Ecosystem colors */
.stat-card[data-stat="smart-contracts"] .stat-value {
    color: var(--accent-purple);
}

.stat-card[data-stat="tokens"] .stat-value {
    color: #f59e0b;
}

.stat-card[data-stat="rollups"] .stat-value {
    color: #10b981;
}

/* Cycle progress color */
.stat-card[data-stat="cycle-progress"] .stat-value {
    color: var(--accent-pink);
}

.stat-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: auto;
}

/* Loading state */
.loading {
    animation: pulse 2s ease-in-out infinite;
    color: var(--text-muted);
}

@keyframes pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

.error-state {
    color: #ff6b6b !important;
    font-size: 1.25rem !important;
}

/* Browser fallback */
@supports not (backdrop-filter: blur(24px)) {
    .stat-card {
        background: rgba(26, 26, 46, 0.95);
    }
}

/* ==========================================
   Modal - Minimal Design
   ========================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    padding: 3rem;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.modal-body {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.95rem;
}

.modal-body p {
    margin-bottom: 1rem;
}

.modal-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.modal-body ul {
    margin: 1.5rem 0;
    list-style: none;
}

.modal-body li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
}

.modal-body li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent-cyan);
    font-weight: 700;
}

.modal-note {
    background: rgba(0, 212, 255, 0.05);
    border-left: 2px solid var(--accent-cyan);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

.modal-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    transition: var(--transition);
    border: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.modal-links a:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

/* ==========================================
   Footer
   ========================================== */

.footer {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-tertiary);
    position: relative;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 300px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.update-info,
.countdown-info {
    font-weight: 400;
}

.highlight {
    color: var(--accent-cyan);
    font-weight: 500;
}

.attribution {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.attribution a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.attribution a:hover {
    color: var(--accent-cyan);
}

.error-message {
    color: #ff6b6b;
    margin-top: 1rem;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 107, 107, 0.2);
}

/* ==========================================
   Responsive
   ========================================== */

@media (min-width: 768px) {
    .header {
        padding: 5rem 2rem 4rem;
    }

    .footer-content {
        flex-direction: row;
        justify-content: center;
        gap: 2rem;
    }
}

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .stat-card {
        min-height: 180px;
    }

    .stat-value {
        font-size: 2.5rem;
    }

    .card-front,
    .card-back {
        padding: 2rem 1.5rem;
    }

    .modal-content {
        padding: 2rem;
    }

    .modal-title {
        font-size: 1.25rem;
    }
}

/* ==========================================
   Accessibility
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }

    .card-inner {
        transition: none !important;
    }
}

.glass-button:focus,
.info-button:focus,
.modal-close:focus {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

@media (prefers-contrast: high) {
    .stat-card {
        border: 2px solid var(--text-primary);
    }
}

/* Hidden elements */
.svg-defs {
    display: none;
}
