/* ============================================
   PharosGuard — Risk Analysis dApp
   Dark Theme | Web3 Aesthetic | Responsive
   ============================================ */

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

:root {
    --bg-primary: #0b0d17;
    --bg-secondary: #13162b;
    --bg-card: #1a1d35;
    --bg-card-hover: #22264a;
    --bg-input: #151932;
    --border-color: #2a2e52;
    --border-focus: #5b6ef5;
    --text-primary: #e8eaf0;
    --text-secondary: #8b8fa8;
    --text-muted: #5c6080;
    --accent: #5b6ef5;
    --accent-hover: #6f80ff;
    --accent-glow: rgba(91, 110, 245, 0.25);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.12);
    --green-border: rgba(34, 197, 94, 0.3);
    --yellow: #eab308;
    --yellow-bg: rgba(234, 179, 8, 0.12);
    --yellow-border: rgba(234, 179, 8, 0.3);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    --red-border: rgba(239, 68, 68, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 999px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Container --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.header {
    text-align: center;
    margin-bottom: 32px;
    padding-top: 16px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2rem;
    line-height: 1;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

/* --- Input Section --- */
.input-section {
    margin-bottom: 24px;
}

.input-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.input-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.input-row {
    display: flex;
    gap: 12px;
}

.wallet-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.wallet-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.wallet-input.error {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:active {
    transform: scale(0.97);
}

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

.btn-icon {
    font-size: 1.1rem;
}

.validation-error {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 0.85rem;
    font-weight: 500;
}

.validation-error.hidden {
    display: none;
}

/* --- Quick Links --- */
.quick-links {
    margin-top: 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}

.quick-btn {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(91, 110, 245, 0.1);
}

/* --- Loading --- */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Results Section --- */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeInUp 0.4s ease-out;
}

.results-section.hidden {
    display: none;
}

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

/* --- Risk Badge --- */
.risk-badge-container {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.risk-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid;
    transition: all 0.3s ease;
    position: relative;
}

.risk-badge::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    opacity: 0.15;
    filter: blur(12px);
    z-index: -1;
    transition: all 0.3s ease;
}

/* Low risk (green) */
.risk-badge.low {
    border-color: var(--green);
    background: var(--green-bg);
}
.risk-badge.low::after {
    background: var(--green);
}
.risk-badge.low .risk-score {
    color: var(--green);
}
.risk-badge.low .risk-level {
    color: var(--green);
}

/* Medium risk (yellow) */
.risk-badge.medium {
    border-color: var(--yellow);
    background: var(--yellow-bg);
}
.risk-badge.medium::after {
    background: var(--yellow);
}
.risk-badge.medium .risk-score {
    color: var(--yellow);
}
.risk-badge.medium .risk-level {
    color: var(--yellow);
}

/* High risk (red) */
.risk-badge.high {
    border-color: var(--red);
    background: var(--red-bg);
    animation: pulse 2s ease-in-out infinite;
}
.risk-badge.high::after {
    background: var(--red);
}
.risk-badge.high .risk-score {
    color: var(--red);
}
.risk-badge.high .risk-level {
    color: var(--red);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.risk-score {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1;
}

.risk-level {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 2px;
}

/* --- Summary Card --- */
.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.summary-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* --- Metrics Grid --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    transition: background 0.2s, transform 0.15s;
}

.metric-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.metric-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
    line-height: 1;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.metric-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Flags Section --- */
.flags-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.flags-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.flags-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flag-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.flag-item .flag-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    line-height: 1.4;
}

.flag-item .flag-content {
    flex: 1;
    min-width: 0;
}

.flag-item .flag-label {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.flag-item .flag-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Flag types */
.flag-item.critical {
    background: var(--red-bg);
    border-color: var(--red-border);
}
.flag-item.critical .flag-icon { color: var(--red); }
.flag-item.critical .flag-label { color: var(--red); }

.flag-item.warning {
    background: var(--yellow-bg);
    border-color: var(--yellow-border);
}
.flag-item.warning .flag-icon { color: var(--yellow); }
.flag-item.warning .flag-label { color: var(--yellow); }

.flag-item.info {
    background: rgba(91, 110, 245, 0.08);
    border-color: rgba(91, 110, 245, 0.2);
}
.flag-item.info .flag-icon { color: var(--accent); }
.flag-item.info .flag-label { color: var(--accent); }

.flag-item.positive {
    background: var(--green-bg);
    border-color: var(--green-border);
}
.flag-item.positive .flag-icon { color: var(--green); }
.flag-item.positive .flag-label { color: var(--green); }

.no-flags {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 12px;
}

.no-flags.hidden {
    display: none;
}

/* --- Address Display --- */
.address-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.address-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.address-value {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-secondary);
    word-break: break-all;
}

/* --- Footer --- */
.footer {
    margin-top: auto;
    padding-top: 40px;
    padding-bottom: 16px;
    text-align: center;
}

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

.footer code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
}

.footer-note {
    margin-top: 4px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container {
        padding: 16px 12px;
    }

    .input-row {
        flex-direction: column;
    }

    .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .metric-card {
        padding: 16px 12px;
    }

    .metric-value {
        font-size: 1.3rem;
    }

    .risk-badge {
        width: 100px;
        height: 100px;
    }

    .risk-score {
        font-size: 2rem;
    }

    .quick-links {
        justify-content: center;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .input-card {
        padding: 16px;
    }

    .flags-section {
        padding: 16px;
    }
}

@media (max-width: 400px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
