/* ============================================================
   IP Address Info Tool — Premium Dark Theme
   ============================================================ */

:root {
    --primary: #10B981;
    --primary-hover: #34D399;
    --primary-glow: rgba(16, 185, 129, 0.25);
    --secondary: #3B82F6;
    --accent: #22D3EE;
    --danger: #EF4444;
    --warning: #F59E0B;
    --success: #10B981;

    --bg-base: #0A0E14;
    --bg-surface: #111827;
    --bg-elevated: #1A2332;
    --bg-hover: #1F2D3D;
    --bg-active: #253346;

    --text-primary: #F0F4F8;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: var(--primary);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--primary-glow);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(16, 185, 129, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(59, 130, 246, 0.06), transparent);
    pointer-events: none;
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    padding: 24px 0 16px;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Search */
.search-section {
    margin-bottom: 24px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 8px 6px 16px;
    transition: border-color var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.search-bar:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    padding: 10px 8px;
    outline: none;
    min-width: 0;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), 0 0 16px var(--primary-glow);
}

.btn-ghost {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

/* Loading & Error */
.loading-state,
.error-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading-state[hidden],
.error-state[hidden] {
    display: none;
}

.error-state {
    color: var(--danger);
}

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

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

/* Map */
.map-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.map-container {
    height: 240px;
    position: relative;
}

.map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 8px;
    font-size: 0.85rem;
}

.map-iframe {
    width: 100%;
    height: 100%;
    border: none;
    filter: hue-rotate(180deg) invert(0.92) contrast(0.85);
}

.map-iframe[hidden] {
    display: none;
}

.map-coords {
    padding: 8px 16px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.info-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast);
}

.info-card:hover {
    border-color: var(--border-hover);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 4px 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
    transition: background var(--transition-fast);
}

.info-row:hover {
    background: var(--bg-hover);
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.info-value {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.mono {
    font-family: var(--font-mono);
}

.badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-yes {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.badge-no {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--secondary);
}

/* Subnet Section */
.subnet-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.subnet-controls {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    outline: none;
    transition: all var(--transition-fast);
}

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

.subnet-results[hidden] {
    display: none;
}

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

.subnet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    gap: 10px;
}

.subnet-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.subnet-value {
    font-size: 0.82rem;
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.subnet-value.small {
    font-size: 0.68rem;
}

/* History */
.history-section {
    margin-top: 8px;
}

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

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.history-flag {
    font-size: 0.9rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    color: var(--text-primary);
    animation: toastSlide 300ms ease;
    max-width: 360px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--secondary);
}

.toast-exit {
    animation: toastExit 200ms ease forwards;
}

@keyframes toastSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastExit {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-active);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .subnet-grid {
        grid-template-columns: 1fr;
    }

    .search-bar {
        flex-wrap: wrap;
    }

    .search-input {
        width: 100%;
    }

    .subnet-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0 12px 40px;
    }

    .app-header h1 {
        font-size: 1.15rem;
    }

    .subtitle {
        display: none;
    }

    .btn {
        padding: 7px 12px;
        font-size: 0.82rem;
    }
}