:root {
    --primary: #2563EB; /* Bright royal blue */
    --primary-hover: #1D4ED8;
    --bg-light: #F8FAFC; /* Clean off-white background */
    --surface: #FFFFFF; /* Pure white cards */
    --surface-border: #E2E8F0;
    --text-primary: #0F172A; /* Slate 900 */
    --text-secondary: #475569; /* Slate 600 */
    --accent: #3B82F6; /* Lighter blue for accents */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', 'Noto Sans Bengali', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background-image: radial-gradient(#E2E8F0 1px, transparent 1px);
    background-size: 20px 20px;
}

.background-blobs {
    display: none;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-50px, 50px) scale(1.1); }
}

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

header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

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

.logo i {
    color: var(--accent);
    width: 3rem; height: 3rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

.upload-section {
    background: var(--surface);
    border: 2px dashed var(--surface-border);
    border-radius: 1rem;
    padding: 4rem 2rem;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    margin-bottom: 3rem;
}

.upload-section:hover, .upload-section.dragover {
    border-color: var(--accent);
    background: #EFF6FF;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

.upload-icon {
    width: 4rem; height: 4rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.upload-section h2 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-section p {
    color: var(--text-secondary);
}

/* Spinner */
.spinner {
    width: 3rem; height: 3rem;
    border: 4px solid var(--surface-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Results */
#search-icon-btn:hover {
    color: var(--accent) !important;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.stats {
    display: flex;
    gap: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.stat-card i {
    color: var(--primary);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-card p {
    font-size: 1.5rem;
    font-weight: 800;
}

.btn-download {
    background: var(--primary);
    color: var(--text-primary);
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-download:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--surface-border);
    margin-bottom: 2rem;
}

.tab {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: block;
}

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

/* Meta Grid */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.meta-item {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    padding: 1.25rem;
    border-radius: 0.75rem;
    backdrop-filter: blur(10px);
}

.meta-item span {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.meta-item strong {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Voters Grid */
.voters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.voter-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s;
}

.voter-card:hover {
    transform: translateY(-4px);
    border-color: var(--surface-border);
}

.voter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--surface-border);
    padding-bottom: 1rem;
}

.voter-header h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    color: var(--accent);
}

.voter-badge {
    background: rgba(255,255,255,0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.voter-detail {
    display: flex;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.voter-detail .label {
    color: var(--text-secondary);
    width: 100px;
    flex-shrink: 0;
}

/* JSON View */
#json-view pre {
    background: #F1F5F9;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--surface-border);
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.9rem;
    color: #0F172A;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding: 1.5rem 1rem;
    }
    
    header {
        margin-bottom: 2rem;
    }
    
    .logo {
        font-size: 2rem;
    }
    
    .stats {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .stat-card {
        width: 100%;
    }
    
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        gap: 0;
    }
    
    .tab {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .voters-grid {
        grid-template-columns: 1fr;
    }
    
    .meta-grid {
        grid-template-columns: 1fr;
    }
    
    .db-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .db-header > div {
        min-width: 100%;
    }
    
    #db-grid {
        grid-template-columns: 1fr !important;
    }
    
    #dict-grid {
        grid-template-columns: 1fr !important;
    }
    
    .db-pagination {
        flex-wrap: wrap;
    }
}

/* Stats Tree Styles */
details.tree-node {
    margin-bottom: 0.5rem;
    font-family: 'Noto Sans Bengali', sans-serif;
}
details.tree-node > summary {
    cursor: pointer;
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--surface-border);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    transition: background 0.2s;
    font-size: 1.1rem;
    color: var(--text-primary);
}
details.tree-node > summary:hover {
    background: #F1F5F9;
}
details.tree-node[open] > summary {
    border-bottom: 1px solid transparent;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: #FFFFFF;
}
details.tree-node > .tree-content {
    padding: 1rem;
    background: #F1F5F9;
    border: 1px solid var(--surface-border);
    border-top: none;
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.tree-leaf {
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--surface-border);
    transition: border-color 0.2s;
}
.tree-leaf:hover {
    border-color: rgba(255, 255, 255, 0.2);
}
.tree-badge {
    background: var(--accent);
    color: var(--text-primary);
    padding: 0.2rem 0.8rem;
    border-radius: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}
.btn-download { color: #FFFFFF !important; }
.tree-badge { color: #FFFFFF !important; }
.btn-download { color: #FFFFFF !important; }
.tree-badge { color: #FFFFFF !important; }
