/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme colors */
    --bg-color: #f5f5f7;
    --text-color: #1d1d1f;
    --card-bg: #ffffff;
    --card-border: #e5e5e5;
    --primary-color: #e53e3e;
    --primary-hover: #c53030;
    --secondary-color: #4a5568;
    --muted-color: #718096;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --success-color: #38a169;
    --error-color: #e53e3e;
    --warning-color: #d69e2e;
    --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.dark {
    /* Dark theme colors */
    --bg-color: #0f0f23;
    --text-color: #e2e8f0;
    --card-bg: #1a202c;
    --card-border: #2d3748;
    --primary-color: #fc8181;
    --primary-hover: #f56565;
    --secondary-color: #e2e8f0;
    --muted-color: #a0aec0;
    --border-color: #4a5568;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --success-color: #68d391;
    --error-color: #fc8181;
    --warning-color: #f6e05e;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color);
}

.logo-text p {
    font-size: 0.875rem;
    color: var(--muted-color);
}

.theme-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover {
    background: var(--border-color);
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

/* Search Section */
.search-section {
    margin-bottom: 3rem;
}

.search-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.search-header {
    text-align: center;
    margin-bottom: 2rem;
}

.search-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.search-header p {
    color: var(--muted-color);
    font-size: 1rem;
}

.search-form {
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.input-container {
    flex: 1;
    min-width: 300px;
}

.input-container label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.input-container input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.input-container input.error {
    border-color: var(--error-color);
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

.error-message.show {
    display: block;
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.search-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.search-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.search-btn i.fa-spin {
    animation: spin 1s linear infinite;
}

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

/* Loading and Error States */
.loading-state,
.error-state {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.loading-state {
    background: rgba(56, 161, 105, 0.1);
    color: var(--success-color);
}

.error-state {
    background: rgba(229, 62, 62, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(229, 62, 62, 0.2);
}

.error-state h3 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.error-state p {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Results Section */
.results-section {
    display: grid;
    gap: 2rem;
    animation: fadeIn 0.5s ease-in;
}

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

.result-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.card-content {
    padding: 1.5rem;
}

/* IP Info Styles */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.info-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item .label {
    font-size: 0.875rem;
    color: var(--muted-color);
    font-weight: 500;
}

.info-item .value {
    font-weight: 600;
    color: var(--text-color);
}

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

.copy-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    color: var(--muted-color);
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.copy-btn:hover {
    color: var(--primary-color);
    background: rgba(229, 62, 62, 0.1);
}

/* Location Info Styles */
.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.location-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.location-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.country-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flag {
    font-size: 2rem;
}

.badge {
    background: var(--border-color);
    color: var(--text-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.coordinates-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.coordinates {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.coord-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.coord-label {
    font-size: 0.75rem;
    color: var(--muted-color);
    width: 2rem;
}

.coord-value {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Map Styles */
.map-container {
    height: 400px;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

.map {
    width: 100%;
    height: 100%;
}

/* Dark mode map adjustments */
.dark .leaflet-container {
    background: #2d3748;
}

.dark .leaflet-control-zoom a {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-color: var(--border-color);
}

.dark .leaflet-control-attribution {
    background-color: rgba(45, 55, 72, 0.8);
    color: var(--text-color);
}

/* Additional Info Styles */
.info-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
}

.btn-secondary,
.btn-outline,
.btn-ghost {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    border: none;
    flex: 1;
    justify-content: center;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #2d3748;
}

.btn-outline {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--border-color);
}

.btn-ghost {
    background: transparent;
    color: var(--muted-color);
}

.btn-ghost:hover {
    background: rgba(229, 62, 62, 0.1);
    color: var(--error-color);
}

/* Examples Section */
.examples-section {
    margin-top: 3rem;
}

.examples-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.examples-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.example-group h4 {
    font-size: 0.875rem;
    color: var(--muted-color);
    margin-bottom: 1rem;
    font-weight: 500;
}

.example-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.example-link {
    background: none;
    border: none;
    color: var(--primary-color);
    text-align: left;
    padding: 0.5rem 0;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.example-link:hover {
    background: rgba(229, 62, 62, 0.05);
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 300px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-color);
    font-weight: 500;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.show {
    display: block !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .header-content {
        padding: 0.75rem 0;
    }
    
    .logo-text h1 {
        font-size: 1rem;
    }
    
    .logo-text p {
        font-size: 0.75rem;
    }
    
    .search-header h2 {
        font-size: 1.5rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-container {
        min-width: auto;
    }
    
    .search-btn {
        width: 100%;
        justify-content: center;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .location-grid {
        grid-template-columns: 1fr;
    }
    
    .header-actions {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .action-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .examples-grid {
        grid-template-columns: 1fr;
    }
    
    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        min-width: auto;
    }
}