/* Modern Travel App - Complete Redesign */

:root {
    /* Light Theme (Default) */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --surface: #ffffff;
    --surface-elevated: #ffffff;
    
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    
    --visited: #14b8a6;
    --unvisited: #e2e8f0;
    --hover: #3b82f6;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --surface: #1e293b;
    --surface-elevated: #334155;
    
    --text: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border: #334155;
    --border-light: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.4);
    
    --visited: #14b8a6;
    --unvisited: #334155;
    --hover: #3b82f6;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Modern App Bar */
.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    z-index: 1000;
    box-shadow: 0 1px 3px var(--shadow);
}

.app-bar-content {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 var(--space-lg);
    max-width: 1400px;
    margin: 0 auto;
}

.app-bar-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 1.5rem;
}

.app-bar-center {
    flex: 1;
    max-width: 400px;
    margin: 0 var(--space-xl);
}

.search-container {
    position: relative;
    width: 100%;
}

.search-container i {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-container input {
    width: 100%;
    padding: var(--space-sm) var(--space-sm) var(--space-sm) 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 0.875rem;
    transition: var(--transition);
}

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

.app-bar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-left: auto;
}

.app-bar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.app-bar-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
}

.user-avatar:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.user-avatar.admin-avatar {
    background: transparent;
    color: var(--text-secondary);
}

.user-avatar.admin-avatar:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

/* Layout Structure */
.content-wrapper {
    display: flex;
    margin-top: 64px;
    flex: 1;
}

/* Modern Sidebar */
.sidebar {
    width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--space-xl);
    overflow-y: auto;
    max-height: calc(100vh - 64px);
}

.sidebar-header {
    margin-bottom: var(--space-xl);
}

.sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.stats-grid {
    display: grid;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

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

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.recent-countries h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-md);
}

.country-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.country-list::-webkit-scrollbar {
    width: 6px;
}

.country-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.country-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.country-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.continent-section {
    margin-bottom: var(--space-md);
}

.continent-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-xs);
}

.country-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.country-item i {
    color: var(--primary);
    font-size: 0.875rem;
}

.country-item span {
    color: var(--text);
    font-size: 0.875rem;
}

.country-item:hover {
    background: var(--bg-secondary);
    transform: translateX(2px);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: var(--space-md);
}

/* Dev Controls */
.dev-controls {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border);
}

.dev-controls .btn {
    width: 100%;
    justify-content: center;
}

/* Map Section */
.map-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
}

.map-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.map-controls {
    display: flex;
    gap: var(--space-sm);
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

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

.map-container {
    position: relative;
    flex: 1;
    background: var(--bg-secondary);
    display: block;
    min-height: 500px;
}

#map {
    width: 100%;
    height: 500px;
    cursor: grab;
    background: var(--bg-secondary);
}

#map:active {
    cursor: grabbing;
}

#map path {
    transition: all 0.2s ease;
    /* Let JavaScript handle colors */
}

.map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    z-index: 10;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    color: var(--text-secondary);
}

.loading-spinner i {
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

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

/* Map Styling */
.country {
    fill: var(--unvisited);
    stroke: var(--border);
    stroke-width: 0.5;
    transition: var(--transition);
    cursor: pointer;
    pointer-events: all;
}

.country:hover {
    fill: var(--hover) !important;
    stroke: var(--primary);
    stroke-width: 1;
}

.country.visited {
    fill: var(--visited) !important;
}

/* Ensure visited countries stay teal even after hover */
.country[fill="#14b8a6"]:hover {
    fill: #0d9488 !important;
}

/* Ensure map paths are visible */
#map path {
    /* Let JavaScript handle colors */
    stroke-width: 0.5;
}

#map path:hover {
    /* Let JavaScript handle hover colors */
    stroke-width: 1;
}

/* Modern Footer */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
}

.footer-left p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.social-links {
    display: flex;
    gap: var(--space-md);
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.social-link:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.footer-stats {
    display: flex;
    gap: var(--space-lg);
}

.footer-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

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

.footer-stat .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.footer-bottom {
    padding: var(--space-md);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Modern Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-lg);
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xl);
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--error);
    color: white;
}

.modal-body {
    padding: var(--space-xl);
}

.modal-footer {
    padding: var(--space-xl);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
}

.theme-card {
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.theme-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow);
}

.theme-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.theme-preview {
    position: relative;
    height: 80px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.preview-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.preview-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
}

.preview-accent {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.theme-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-xs);
}

.theme-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

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

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .app-bar-center {
        max-width: 300px;
        margin: 0 var(--space-md);
    }
    
    .theme-dropdown {
        width: 800px;
    }
    
    .theme-options {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        order: 2;
    }
    
    .map-section {
        order: 1;
    }
    
    .map-container {
        min-height: 60vh;
        height: 60vh;
    }
    
    #map {
        height: 100%;
    }
    
    .app-bar-content {
        padding: 0 var(--space-md);
    }
    
    .app-bar-center {
        display: none;
    }
    
    .footer-content {
        flex-direction: column;
        gap: var(--space-lg);
        text-align: center;
    }
    
    .theme-grid {
        grid-template-columns: 1fr;
    }
    
    .theme-dropdown {
        width: calc(100vw - 40px);
        right: -20px;
        left: auto;
    }
    
    .theme-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .app-bar {
        height: 56px;
    }
    
    .content-wrapper {
        margin-top: 56px;
    }
    
    .map-container {
        min-height: 50vh;
        height: 50vh;
    }
    
    #map {
        height: 100%;
    }
    
    .modal-content {
        margin: var(--space-md);
        max-height: calc(100vh - 2rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-lg);
    }
}

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

.modal-content {
    animation: fadeIn 0.3s ease-out;
}

/* Login Form Styles */
.login-form {
    max-width: 400px;
    margin: 0 auto;
}

.login-form h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-xl);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-group input {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group small {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.settings-form {
    max-width: 500px;
    margin: 0 auto;
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
}

.success-message {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.admin-panel {
    max-width: 400px;
    margin: 0 auto;
}

.admin-actions h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-md);
}

.admin-actions p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

/* Theme Dropdown Styles */
.theme-selector-wrapper {
    position: relative;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 900px;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.theme-selector-wrapper:hover .theme-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.theme-dropdown-header {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.theme-options {
    padding: var(--space-md);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.theme-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    border: 2px solid transparent;
}

.theme-option:hover {
    transform: scale(1.02);
    border-color: var(--primary);
}

.theme-option.active {
    background: var(--primary);
    border-color: var(--primary-dark);
}

.theme-option.active .theme-name,
.theme-option.active .theme-description {
    color: white;
}

.theme-colors {
    display: flex;
    gap: 3px;
}

.theme-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.theme-text {
    flex: 1;
    min-width: 0;
}

.theme-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}

.theme-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.theme-option.active .theme-colors .theme-color-dot {
    background-color: rgba(255, 255, 255, 0.9) !important;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}