/* WhoIP - Responsive CSS with light/dark theme support */
/* No external dependencies, no tracking fonts */
/* Theme follows system preference via prefers-color-scheme */

/* Dark theme (default) */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --border: #30363d;
    --success: #3fb950;
    --error: #f85149;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Light theme (for users who prefer light mode) */
@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #f6f8fa;
        --bg-card: #ffffff;
        --text-primary: #1f2328;
        --text-secondary: #656d76;
        --accent: #0969da;
        --accent-hover: #0550ae;
        --border: #d0d7de;
        --success: #1a7f37;
        --error: #cf222e;
    }
}

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

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Top Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-nav .logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.top-nav .logo:hover {
    color: var(--accent-hover);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

/* Language flags */
.lang-separator {
    color: var(--border);
    font-size: 0.9rem;
}

.lang-flag {
    font-weight: 600;
    font-size: 0.85rem !important;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s;
}

.lang-flag:hover {
    background-color: var(--bg-card);
}

.lang-flag.active {
    background-color: var(--accent);
    color: var(--bg-primary) !important;
}

/* Main Content */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* API Hint Card */
.api-hint p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.api-hint .code-block {
    display: block;
    background-color: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.api-hint .hint-link {
    margin-top: 0.5rem;
}

.api-hint .hint-link a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
}

.api-hint .hint-link a:hover {
    text-decoration: underline;
}

/* Results */
.result {
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.result .loading {
    color: var(--text-secondary);
}

.result .ip-display {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.result .ip-version {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    margin-left: 0.5rem;
    color: var(--accent);
}

.result .detail {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.result .detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
}

.result .detail-label {
    color: var(--text-secondary);
}

.result .detail-value {
    color: var(--text-primary);
    text-align: right;
    word-break: break-all;
    max-width: 60%;
}

.result .resolved-ip {
    color: var(--text-secondary);
    font-size: 0.85em;
}

.result .error {
    color: var(--error);
}

.result .query-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.result .ip-section {
    margin-top: 1rem;
}

.result .ip-section h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result .ip-header {
    margin-bottom: 0;
}

.result .dns-section {
    margin-top: 0;
}

/* Add border when dns-section follows ip-section */
.result .ip-section + .dns-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.result .dns-section h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result .dns-records {
    list-style: none;
}

.result .dns-records li {
    padding: 0.2rem 0;
    color: var(--text-primary);
}

/* When IP section follows DNS section (domain lookups) */
.result .dns-section + .ip-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Form */
.input-group {
    display: flex;
    gap: 0.5rem;
}

input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font-mono);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

input[type="text"]::placeholder {
    color: var(--text-secondary);
}

button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--accent-hover);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* API Documentation Page */
.api-docs header {
    margin-bottom: 2rem;
}

.api-docs .card {
    margin-bottom: 2rem;
}

.api-docs .card h2 {
    margin-bottom: 1.25rem;
}

.api-docs .card p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.api-docs .card h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.api-docs .card h3:first-of-type {
    margin-top: 0;
}

/* Endpoint Styling */
.endpoint {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
}

.endpoint:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.endpoint:first-child {
    padding-top: 0;
}

.endpoint h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem !important;
    margin-top: 0 !important;
}

.endpoint .method {
    display: inline-block;
    background-color: var(--success);
    color: var(--bg-primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Code Examples */
.code-example {
    background-color: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 0.75rem 0;
}

.code-example code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent);
}

.response-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.response-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.response-hint code {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

pre.response {
    background-color: var(--bg-secondary);
    padding: 1rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.5;
}

/* Rate Limits */
.rate-limits {
    list-style: none;
    margin: 0.75rem 0;
}

.rate-limits li {
    padding: 0.3rem 0;
    color: var(--text-secondary);
}

.rate-limits strong {
    color: var(--text-primary);
}

/* Error Codes Table */
.error-codes {
    width: 100%;
    margin-top: 1rem;
    border-collapse: collapse;
}

.error-codes td {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.error-codes td:first-child {
    width: 80px;
}

.error-codes td:first-child code {
    font-family: var(--font-mono);
    color: var(--error);
}

.error-codes td:last-child {
    color: var(--text-secondary);
}

.error-codes tr:last-child td {
    border-bottom: none;
}

/* Legal Content Pages */
.legal-content h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.legal-content h3:first-child {
    margin-top: 0;
}

.legal-content p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.legal-content ul {
    color: var(--text-secondary);
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.legal-content li {
    margin-bottom: 0.25rem;
}

.legal-content a {
    color: var(--accent);
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 640px) {
    .top-nav {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .top-nav .logo {
        font-size: 1.25rem;
    }

    .nav-links {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-links a {
        font-size: 0.85rem;
    }

    main {
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

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

    button {
        width: 100%;
    }

    .result .detail-row {
        flex-direction: column;
    }

    .result .detail-value {
        max-width: 100%;
        text-align: left;
    }

    pre.response {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
}
