/* ==========================================
   CSS VARIABLE DECLARATIONS (HSL Design System)
   ========================================== */
:root {
    --bg-main: hsl(210, 20%, 97%);
    --bg-card: hsla(0, 0%, 100%, 0.85);
    --border-card: hsla(240, 10%, 10%, 0.08);
    --border-card-hover: hsla(260, 80%, 55%, 0.25);
    
    --text-primary: hsl(220, 25%, 15%);
    --text-secondary: hsl(220, 15%, 35%);
    --text-muted: hsl(220, 10%, 50%);

    --primary: hsl(260, 80%, 55%);
    --primary-glow: hsla(260, 80%, 55%, 0.1);
    --secondary: hsl(215, 90%, 50%);
    --secondary-glow: hsla(215, 90%, 50%, 0.1);
    --accent: hsl(150, 80%, 38%);
    --accent-glow: hsla(150, 80%, 38%, 0.1);
    --danger: hsl(350, 80%, 50%);

    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-smooth: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ==========================================
   BASE & RESET STYLES
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Background Animated Glows */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(130px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.15;
}

.bg-glow-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-glow);
    top: -100px;
    left: -100px;
}

.bg-glow-2 {
    width: 500px;
    height: 500px;
    background: var(--secondary-glow);
    bottom: -150px;
    right: -100px;
}

.bg-glow-3 {
    width: 300px;
    height: 300px;
    background: var(--accent-glow);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ==========================================
   HEADER SECTION
   ========================================== */
.app-header {
    text-align: center;
    margin-bottom: 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rotateGlobe 20s linear infinite;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================
   COMPONENTS: CARDS & GLASSMORPHISM
   ========================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
}

.card:hover {
    border-color: var(--border-card-hover);
    transform: translateY(-4px);
    box-shadow: 0 15px 40px -12px rgba(124, 58, 237, 0.08);
}

.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--secondary), var(--primary), var(--accent));
}

/* ==========================================
   DASHBOARD GRID LAYOUT
   ========================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

/* Hero IP Card */
.hero-card {
    grid-column: span 6;
    padding: 2.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 250px;
}

.badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    background-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px var(--accent);
    animation: pulse 1.8s infinite;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.ip-display-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.ip-address {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    word-break: break-all;
}

/* Interactive Buttons */
.action-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-only-btn {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--primary);
    border-color: var(--primary);
    transform: scale(1.05);
}

.action-btn:active {
    transform: scale(0.95);
}

.connection-quick-info {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.info-tag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.015);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.info-tag i {
    color: var(--secondary);
}

/* Map Card */
.map-card {
    grid-column: span 6;
    height: 280px;
    overflow: hidden;
    padding: 0;
}

.map-container {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Light Mode Leaflet Map Filter */
.leaflet-container {
    background: #f8fafc !important;
}
.leaflet-tile-container img {
    /* No inversion filter in light mode to keep standard clean maps */
}

.map-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    color: var(--text-secondary);
    gap: 1rem;
}

/* Details Cards */
.details-card {
    grid-column: span 6;
    padding: 1.75rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 0.75rem;
}

.header-icon {
    font-size: 1.25rem;
    color: var(--primary);
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

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

.value-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flag-icon {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    object-fit: cover;
}

.flag-icon.hidden {
    display: none;
}

.value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
}

/* ==========================================
   CONTROLS BAR & BUTTONS
   ========================================== */
.controls-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
    filter: brightness(1.05);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* ==========================================
   FOOTER SECTION
   ========================================== */
.app-footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 1.5rem;
}

/* ==========================================
   ANIMATIONS & PLACEHOLDERS
   ========================================== */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes rotateGlobe {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Loading placeholders */
.loading-placeholder {
    position: relative;
    overflow: hidden;
    color: transparent !important;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    display: inline-block;
    min-width: 150px;
    height: 1.8rem;
}

.loading-text {
    position: relative;
    overflow: hidden;
    color: transparent !important;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    display: inline-block;
    min-width: 100px;
    height: 1.2rem;
}

.loading-placeholder::after,
.loading-text::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.03) 20%,
        rgba(0, 0, 0, 0.06) 60%,
        rgba(0, 0, 0, 0) 100%
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* Spinner Loader */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.05);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
}

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

/* ==========================================
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================== */
@media (max-width: 992px) {
    .hero-card, .map-card, .details-card {
        grid-column: span 12;
    }
    
    .map-card {
        height: 320px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1.5rem 1rem;
        gap: 1.5rem;
    }
    
    .app-header h1 {
        font-size: 2.2rem;
    }
    
    .ip-address {
        font-size: 2rem;
    }
    
    .details-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .controls-bar {
        flex-direction: column;
    }
    
    .btn {
        justify-content: center;
    }
}
