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

:root {
    --primary-color: #007aff;
    --primary-hover: #0051d5;
    --primary-light: #e5f1ff;
    --primary-dark: #004fbb;
    --secondary-color: #34c759;
    --secondary-hover: #2ab04a;
    --accent-color: #5856d6;
    --background: #f5f5f7;
    --surface: #fafafa;
    --surface-elevated: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --border-color: #d2d2d7;
    --border-light: #e5e5ea;
    --error-color: #ff3b30;
    --success-color: #34c759;
    --warning-color: #ff9500;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 8px 24px 0 rgba(0, 0, 0, 0.1);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 22px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #0a84ff;
        --primary-hover: #409cff;
        --primary-light: #1a2f4a;
        --primary-dark: #0070e0;
        --secondary-color: #30d158;
        --secondary-hover: #32d74b;
        --accent-color: #5e5ce6;
        --background: #000000;
        --surface: #1c1c1e;
        --surface-elevated: #2c2c2e;
        --card-bg: #1c1c1e;
        --text-primary: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #636366;
        --border-color: #38383a;
        --border-light: #2c2c2e;
        --error-color: #ff453a;
        --success-color: #30d158;
        --warning-color: #ff9f0a;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 2px 8px 0 rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 4px 16px 0 rgba(0, 0, 0, 0.5);
        --shadow-xl: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    }
}

body {
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Roboto",
        "Helvetica Neue",
        Arial,
        sans-serif;
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.47;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 2000px;
    margin: 0 auto;
    padding: 0 60px;
}

@media (min-width: 2200px) {
    .container {
        max-width: 2400px;
        padding: 0 80px;
    }
}

header {
    background: var(--surface-elevated);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--border-color);
    padding: 20px 0;
    margin-bottom: 40px;
    margin-left: -60px;
    margin-right: -60px;
    padding-left: 60px;
    padding-right: 60px;
    text-align: center;
}

.header-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.header-link:hover {
    opacity: 0.8;
}

.header-link:hover h1 {
    color: var(--primary-color);
}

.header-content {
    text-align: center;
    max-width: none;
    margin: 0 auto;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    text-align: center;
    transition: color 0.2s ease;
}

.subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.4;
    text-align: center;
}

.search-section {
    margin-bottom: 56px;
    padding: 0 60px;
}

.search-box {
    display: flex;
    gap: 12px;
    max-width: 1000px;
    margin: 0 auto;
    align-items: stretch;
}

#ipInput {
    flex: 1;
    padding: 14px 20px;
    border: 0.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.0625rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: var(--surface-elevated);
    color: var(--text-primary);
}

#ipInput:hover {
    border-color: var(--text-tertiary);
}

#ipInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.btn-primary {
    padding: 14px 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.0625rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

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

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

.results-container {
    animation: fadeInUp 0.5s ease-out;
    padding: 0 60px;
}

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

.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.info-card {
    background: var(--surface-elevated);
    border: 0.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: none;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-flag {
    width: 28px;
    height: 21px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: var(--shadow-sm);
}

.card-value {
    font-size: 1.03125rem;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.4;
    margin-top: 4px;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 16px;
    margin-bottom: 40px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* Detailed information section (left side on desktop) */
.details-grid > .details-section:first-child {
    order: 1;
}

/* Map section (right side on desktop) */
.details-grid > .map-section {
    order: 2;
}

.details-section {
    background: var(--surface-elevated);
    border: 0.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: none;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.details-section:hover {
    box-shadow: var(--shadow-sm);
}

.details-section h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    letter-spacing: -0.1px;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--border-light);
}

.map-section {
    display: flex;
    flex-direction: column;
}

.map-container {
    width: 100%;
    flex: 1;
    min-height: 320px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 0.5px solid var(--border-color);
}

.details-table {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 0.5px solid var(--border-light);
    transition: all 0.2s ease;
    gap: 16px;
}

.detail-row:hover {
    padding-left: 4px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.detail-value {
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
    max-width: 65%;
    font-size: 1.3125rem;
    font-weight: 700;
    line-height: 1.3;
}

.raw-data-section {
    background: var(--surface-elevated);
    border: 0.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--border-light);
}

.section-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.1px;
}

.btn-copy {
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: "Inter", inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: var(--shadow-sm);
}

.btn-copy:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-copy:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.raw-data {
    background: var(--surface);
    color: var(--text-primary);
    padding: 20px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-family: "JetBrains Mono", "Roboto Mono", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.7;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

/* Custom map popup styling */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.4;
}

.custom-popup .leaflet-popup-content-wrapper {
    background: var(--surface-elevated);
    color: var(--text-primary);
}

.error-message {
    background: var(--surface-elevated);
    color: var(--error-color);
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    margin: 24px 60px;
    text-align: center;
    font-weight: 500;
    font-size: 0.9375rem;
    border: 0.5px solid var(--error-color);
    box-shadow: none;
}

.loading-message {
    text-align: center;
    padding: 56px;
    background: var(--surface-elevated);
    border: 0.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin: 32px 60px;
    box-shadow: none;
}

.loading-message p {
    color: var(--text-secondary);
    font-weight: 500;
}

.loader {
    margin: 0 auto 20px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

footer {
    text-align: center;
    margin-top: 64px;
    padding: 20px 24px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
}

footer p {
    margin-bottom: 8px;
}

footer p:last-child {
    margin-bottom: 0;
}

.footer-copyright {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

footer a:hover {
    border-bottom-color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        padding: 0 20px;
    }

    header {
        padding: 32px 0;
    }

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .search-section {
        padding: 0 20px;
        margin-bottom: 40px;
    }

    .search-box {
        flex-direction: column;
        gap: 12px;
    }

    .btn-primary {
        width: 100%;
        padding: 14px;
    }

    .info-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Show details first, then map on mobile */
    .details-grid > .details-section:first-child {
        order: 1;
    }

    .details-grid > .map-section {
        order: 2;
    }

    .map-section {
        min-height: 280px;
    }

    .map-container {
        height: 240px;
    }

    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 16px 0;
    }

    .detail-label {
        font-size: 0.8125rem;
    }

    .detail-value {
        font-size: 0.875rem;
        text-align: left;
        max-width: 100%;
    }

    .card-value {
        font-size: 0.75rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .btn-copy {
        width: 100%;
    }

    .results-container,
    .raw-data-section,
    .error-message,
    .loading-message {
        padding: 0 20px;
        margin-left: 20px;
        margin-right: 20px;
    }

    .details-section {
        padding: 20px;
    }

    footer {
        margin-top: 48px;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .search-section,
    .btn-copy,
    footer {
        display: none;
    }

    .info-card,
    .details-section,
    .raw-data-section {
        box-shadow: none;
        border: 1px solid var(--border-color);
        background: white;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}
