/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Light Theme */
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-sub: #6b7280;
    --accent: #3b82f6;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --code-bg: #f9fafb;
    --error: #ef4444;
    --success: #10b981;

    /* Switcher Variables */
    --switch-bg: #e5e7eb;
    --switch-active-bg: #ffffff;
    --switch-active-text: #000000;
    --switch-inactive-text: #6b7280;
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --accent: #60a5fa;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --code-bg: #0b1120;

    /* Switcher Variables Dark */
    --switch-bg: #1e293b;
    --switch-active-bg: #334155;
    --switch-active-text: #ffffff;
    --switch-inactive-text: #64748b;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

.app-wrapper {
    width: 100%;
    max-width: 680px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* =========================================
   2. HEADER & REFINED SWITCHER
   ========================================= */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
}

.logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

/* Refined Segmented Control Switcher */
.theme-switch-container {
    background: var(--switch-bg);
    padding: 3px;
    border-radius: 8px; /* Slightly more square */
    display: flex;
    gap: 2px;
}

.theme-btn {
    background: transparent;
    border: none;
    color: var(--switch-inactive-text);
    padding: 6px 12px;
    font-size: 11px; /* Smaller, cleaner */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 4px;
}

.theme-btn .icon {
    font-size: 12px;
    margin-bottom: 1px;
}

.theme-btn:hover { color: var(--text-main); }

.theme-btn.active {
    color: var(--switch-active-text);
    background: var(--switch-active-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* =========================================
   3. MAIN CONTENT
   ========================================= */
.main-ip-section {
    text-align: center;
    padding: 40px 20px;
    margin-bottom: 10px;
}

.main-ip-section .label {
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-sub);
    margin-bottom: 12px;
}

.hero-ip {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    transition: color 0.2s, transform 0.1s;
    word-break: break-all;
    line-height: 1.3;
}
.hero-ip:hover { color: var(--accent); transform: scale(1.01); }
.hero-ip:active { transform: scale(0.98); }

.hero-tag {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 12px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* Grid for v4 / v6 */
.grid-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 30px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 12px -3px rgba(0,0,0,0.1); }

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-sub);
    margin-bottom: 10px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.v4 { background: #10b981; }
.dot.v6 { background: #8b5cf6; }

.ip-display-sm {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    word-break: break-all;
    min-height: 24px;
    cursor: pointer;
}
.ip-display-sm:hover { color: var(--accent); }

.status-sm { font-size: 12px; margin-top: 6px; color: var(--text-sub); }
.status-sm.error { color: var(--error); }

/* =========================================
   4. API DOCS & FOOTER
   ========================================= */
.api-docs {
    border-top: 1px solid var(--border);
    padding-top: 30px;
}
.docs-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.docs-header h3 { font-size: 16px; font-weight: 600; }
.badge { background: var(--text-main); color: var(--bg-card); font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 700; }

.endpoint-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}
.method { background: var(--accent); color: white; padding: 8px 12px; font-size: 12px; font-weight: 700; }
.url { padding: 8px 12px; font-family: var(--font-mono); font-size: 13px; color: var(--text-sub); width: 100%; overflow-x: auto; white-space: nowrap; }

.docs-desc { font-size: 14px; color: var(--text-sub); margin-bottom: 15px; line-height: 1.5; }
.code-block pre { background: var(--code-bg); padding: 15px; border-radius: 8px; font-family: var(--font-mono); font-size: 13px; color: var(--text-main); overflow-x: auto; border: 1px solid var(--border); }

.app-footer { text-align: center; margin-top: 40px; font-size: 13px; color: var(--text-sub); opacity: 0.6; }

/* =========================================
   5. UTILITIES (Skeleton, Error, Toast)
   ========================================= */
.skeleton { height: 20px; width: 80%; background: var(--border); border-radius: 4px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 0.3; } 100% { opacity: 0.6; } }

.fade-in { animation: fadeIn 0.5s ease-out; }
.fade-in-up { animation: fadeInUp 0.5s ease-out; }
.delay-1 { animation-delay: 0.1s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Error Card Specifics */
.error-card { text-align: center; border-color: var(--error); background: rgba(239, 68, 68, 0.03); }
.icon-box.error { width: 40px; height: 40px; background: var(--error); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 15px; font-weight: bold; }
.ip-display.error { color: var(--error); font-weight: 700; font-size: 20px; margin: 10px 0; }

/* Toast */
.toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 999; pointer-events: none; }
.toast { background: var(--text-main); color: var(--bg-card); padding: 10px 20px; border-radius: 50px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; opacity: 0; transform: translateY(20px); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.toast.show { opacity: 1; transform: translateY(0); }

/* Mobile */
@media (max-width: 600px) {
    .grid-stack { grid-template-columns: 1fr; }
    .hero-ip { font-size: 24px; }

    /* Hide icon on mobile if text is too long, or just keep it tight */
    .theme-btn { padding: 6px 10px; font-size: 10px; }
}