/* ========================================
   Database Explorer - Styles
   ======================================== */

:root {
    /* Typography */
    --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --sidebar-width: 320px;
    --header-height: 72px;
    --search-height: 72px;
    
    /* Effects */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme - Deep Ocean (Default) */
[data-theme="dark"] {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2234;
    --bg-hover: #232d42;
    --bg-active: #2a3752;
    
    --accent-primary: #22d3ee;
    --accent-secondary: #06b6d4;
    --accent-tertiary: #0891b2;
    --accent-glow: rgba(34, 211, 238, 0.15);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #1e293b;
    --border-active: #334155;
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --table-badge: #a78bfa;
    --fc-badge: #34d399;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    
    --gradient-bg: 
        radial-gradient(ellipse at 0% 0%, rgba(34, 211, 238, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

/* Light Theme - Frost */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-active: #cbd5e1;
    
    --accent-primary: #0891b2;
    --accent-secondary: #0e7490;
    --accent-tertiary: #155e75;
    --accent-glow: rgba(8, 145, 178, 0.12);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-active: #cbd5e1;
    
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    
    --table-badge: #7c3aed;
    --fc-badge: #059669;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    
    --gradient-bg: 
        radial-gradient(ellipse at 0% 0%, rgba(8, 145, 178, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(124, 58, 237, 0.04) 0%, transparent 50%);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-display);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--gradient-bg), var(--bg-primary);
}

/* Copy Format Selector */
.copy-format-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
}

.copy-format-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.copy-format-label svg {
    opacity: 0.7;
}

.copy-format-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    cursor: pointer;
    transition: var(--transition);
    min-width: 140px;
}

.copy-format-select:hover {
    border-color: var(--accent-primary);
}

.copy-format-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.copy-format-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
}

.theme-toggle-btn {
    position: relative;
    width: 52px;
    height: 28px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-primary);
}

.theme-toggle-btn::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .theme-toggle-btn::before {
    transform: translateX(24px);
}

.theme-toggle-icon {
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.theme-toggle-icon.sun {
    display: none;
}

.theme-toggle-icon.moon {
    display: flex;
}

[data-theme="light"] .theme-toggle-icon.sun {
    display: flex;
}

[data-theme="light"] .theme-toggle-icon.moon {
    display: none;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo svg {
    color: var(--accent-primary);
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.logo .subtitle {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 8px;
}

.logo .last-updated {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats {
    display: flex;
    gap: 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-value {
    color: var(--accent-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Search Container */
.search-container {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 100%;
}

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

#searchInput {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    transition: var(--transition);
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#searchInput::placeholder {
    color: var(--text-muted);
}

.search-filters {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.filter-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--bg-primary);
}

[data-theme="light"] .filter-btn.active {
    color: #ffffff;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.section-title svg {
    opacity: 0.7;
}

.section-title .count {
    margin-left: auto;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.dataset-list {
    list-style: none;
}

.dataset-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid transparent;
}

.dataset-item:hover {
    background: var(--bg-hover);
}

.dataset-item.active {
    background: var(--bg-active);
    border-left-color: var(--accent-primary);
}

.dataset-item .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
}

.dataset-item.table .icon {
    background: rgba(167, 139, 250, 0.2);
    color: var(--table-badge);
}

[data-theme="light"] .dataset-item.table .icon {
    background: rgba(124, 58, 237, 0.12);
}

.dataset-item.feature-class .icon {
    background: rgba(52, 211, 153, 0.2);
    color: var(--fc-badge);
}

[data-theme="light"] .dataset-item.feature-class .icon {
    background: rgba(5, 150, 105, 0.12);
}

.dataset-item .name {
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dataset-item .row-count {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Detail Panel */
.detail-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-primary);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 300px;
}

.hidden {
    display: none !important;
}

/* Dataset Details */
.detail-header {
    margin-bottom: 24px;
}

.dataset-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.dataset-type-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dataset-type-badge.table {
    background: rgba(167, 139, 250, 0.2);
    color: var(--table-badge);
}

[data-theme="light"] .dataset-type-badge.table {
    background: rgba(124, 58, 237, 0.12);
}

.dataset-type-badge.feature-class {
    background: rgba(52, 211, 153, 0.2);
    color: var(--fc-badge);
}

[data-theme="light"] .dataset-type-badge.feature-class {
    background: rgba(5, 150, 105, 0.12);
}

.dataset-title h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.dataset-meta {
    display: flex;
    gap: 20px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.meta-item svg {
    opacity: 0.7;
}

/* Field Search */
.field-search-container {
    margin-bottom: 20px;
}

#fieldSearch {
    width: 100%;
    max-width: 400px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    transition: var(--transition);
}

#fieldSearch:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

/* Fields Container */
.fields-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: var(--transition);
}

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

.field-card.has-values {
    border-left: 3px solid var(--accent-primary);
}

.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
}

.field-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.field-name {
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.field-alias {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.field-meta {
    display: flex;
    gap: 12px;
}

.field-type {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.field-length {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.values-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--accent-glow);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 4px;
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

[data-theme="light"] .values-toggle {
    border-color: rgba(8, 145, 178, 0.3);
}

.values-toggle:hover {
    background: rgba(34, 211, 238, 0.25);
}

[data-theme="light"] .values-toggle:hover {
    background: rgba(8, 145, 178, 0.18);
}

.values-toggle svg {
    transition: transform 0.2s ease;
}

.values-toggle.expanded svg {
    transform: rotate(180deg);
}

.field-values {
    padding: 0 18px 14px;
    display: none;
}

.field-values.visible {
    display: block;
}

.values-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.value-chip {
    padding: 5px 12px;
    background: var(--bg-tertiary);
    border-radius: 15px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    transition: var(--transition);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.value-chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.value-chip:active {
    transform: scale(0.95);
}

/* Selected state for multi-copy */
.value-chip.selected {
    background: var(--accent-primary);
    color: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

[data-theme="light"] .value-chip.selected {
    color: #ffffff;
}

/* Copied flash animation */
.value-chip.copied {
    animation: copyFlash 0.6s ease;
}

@keyframes copyFlash {
    0% {
        background: var(--accent-primary);
        color: var(--bg-primary);
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        transform: scale(1);
    }
}

/* Copy toast notification */
.copy-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    pointer-events: none;
}

.copy-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.copy-toast svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

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

.field-card {
    animation: fadeIn 0.3s ease forwards;
}

.field-card:nth-child(1) { animation-delay: 0.02s; }
.field-card:nth-child(2) { animation-delay: 0.04s; }
.field-card:nth-child(3) { animation-delay: 0.06s; }
.field-card:nth-child(4) { animation-delay: 0.08s; }
.field-card:nth-child(5) { animation-delay: 0.10s; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        width: 260px;
    }
    
    .search-filters {
        display: none;
    }
}

@media (max-width: 700px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}
