/* System Variables & Dark Theme Reset */
:root {
    --bg-main: #0b0f19;
    --bg-surface: rgba(23, 32, 54, 0.7);
    --bg-surface-hover: rgba(30, 41, 69, 0.8);
    --bg-input: #111827;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: #38bdf8;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --accent-sponsor: #10b981;
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
    --shadow-card: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.directory-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.directory-wrapper {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(129, 140, 248, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    padding: 32px 20px;
    max-width: 1300px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    -webkit-font-smoothing: antialiased;
}

/* Header */
.directory-wrapper header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.directory-wrapper header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glassmorphism Panels */
.directory-wrapper .panel {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.directory-wrapper .panel:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.directory-wrapper .panel h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Controls & Buttons */
.directory-wrapper input[type="text"], 
.directory-wrapper select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.directory-wrapper input[type="text"]::placeholder {
    color: var(--text-muted);
}

.directory-wrapper input[type="text"]:focus, 
.directory-wrapper select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.directory-wrapper select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

.directory-wrapper .btn {
    background: var(--accent-gradient);
    color: #0b0f19 !important;
    font-weight: 700;
    padding: 12px 22px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-glow);
}

.directory-wrapper .btn:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 0 25px rgba(56, 189, 248, 0.35);
}

.directory-wrapper .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.directory-wrapper #refresh-data-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    box-shadow: none;
}

.directory-wrapper #refresh-data-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Map Container */
.directory-wrapper #map {
    width: 100%;
    height: 480px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* InfoWindow Dark Theme Overrides */
.gm-style .gm-style-iw-c {
    background-color: #111827 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px !important;
    color: #f8fafc !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4) !important;
}
.gm-style .gm-style-iw-tc::after {
    background-color: #111827 !important;
}

/* Data Table & Sorting */
.directory-wrapper #search-input {
    width: 100%;
    margin-bottom: 20px;
}

.directory-wrapper .table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.directory-wrapper table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    background: var(--bg-input);
}

.directory-wrapper th {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.directory-wrapper th:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.directory-wrapper td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.directory-wrapper tr:last-child td {
    border-bottom: none;
}

.directory-wrapper tbody tr {
    transition: var(--transition);
}

.directory-wrapper tbody tr:hover {
    background-color: rgba(56, 189, 248, 0.04);
}

/* Badges */
.directory-wrapper .badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    color: #f8fafc;
    font-weight: 600;
    gap: 16px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(56, 189, 248, 0.15);
    border-top: 3px solid #38bdf8;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}