/* Modern Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #f59e0b;
    --background-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
    --primary-color: #818cf8;
    --primary-dark: #6366f1;
    --secondary-color: #a78bfa;
    --accent-color: #fbbf24;
    --background-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success-color: #34d399;
    --error-color: #f87171;
    --warning-color: #fbbf24;
}

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

body {
    font-family: 'Segoe UI', 'Nirmala UI', 'Mangal', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    padding: 0;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.hindi-text {
    font-family: 'Nirmala UI', 'Mangal', 'Arial Unicode MS', sans-serif;
}

.container {
    max-width: 100%;
    margin: 0;
    background: transparent;
    min-height: 100vh;
}

/* Modern Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 2rem 3rem;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
}

.theme-toggle, .language-toggle {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.theme-toggle:hover, .language-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.theme-toggle {
    top: 1.5rem;
    right: 1.5rem;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.language-toggle {
    top: 1.5rem;
    left: 1.5rem;
    border-radius: 25px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    margin-bottom: 0.75rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.hindi-title {
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    margin-bottom: 0.75rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
    opacity: 0.95;
}

.subtitle {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    opacity: 0.9;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

/* Advertisement Banner */
.ad-banner {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 1.5rem;
    margin: 0;
    position: relative;
    overflow: hidden;
}

.ad-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.ad-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}

.ad-title {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ad-subjects {
    font-size: clamp(0.85rem, 2vw, 1rem);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.ad-subjects span {
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.ad-contact {
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    opacity: 0.9;
}

.ad-address {
    font-size: clamp(0.75rem, 1.6vw, 0.9rem);
    margin-top: 0.5rem;
    opacity: 0.85;
    text-align: center;
    max-width: 600px;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    min-height: calc(100vh - 300px);
}

/* Modern Cards */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preview-panel {
    display: flex;
    flex-direction: column;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Modern Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.02), rgba(139, 92, 246, 0.02));
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
    transform: translateY(-2px);
}

.upload-area:hover::before {
    opacity: 1;
}

.upload-area.dragover {
    border-color: var(--secondary-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    transform: scale(1.02);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    filter: grayscale(0.3);
}

/* Modern Buttons */
.btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 0.75rem;
    width: 100%;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-box input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 0 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.search-box button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* PDF Preview Container */
.pdf-preview-container {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    flex: 1;
    overflow-y: auto;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.02), rgba(139, 92, 246, 0.02));
    display: flex;
    justify-content: center;
    align-items: flex-start;
    max-height: 80vh;
    padding: 10px;
}

.pdf-preview {
    padding: 0;
    display: block;
    text-align: center;
    width: 100%;
}

.pdf-canvas {
    max-width: 100%;
    height: auto;
    box-shadow: var(--shadow-xl);
    border-radius: 8px;
    margin: 20px auto;
}

.text-layer {
    position: absolute;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

/* Highlight Animations */
.highlight {
    background-color: #fef08a !important;
    color: #000 !important;
    padding: 2px 4px;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(254, 240, 138, 0.6);
    position: absolute;
    z-index: 12;
    transition: all 0.3s ease;
}

.current-highlight {
    background-color: var(--accent-color) !important;
    color: #000 !important;
    padding: 2px 4px;
    border-radius: 3px;
    position: absolute;
    z-index: 13;
    animation: pulse-modern 2s infinite;
}

@keyframes pulse-modern {
    0%, 100% {
        box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
    }
    50% {
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.9);
    }
}

/* Modern Progress Bar */
.progress-container {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.4s ease;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-height: 20px;
    font-weight: 500;
}

/* Status Messages */
.status {
    margin-top: 1rem;
    padding: 0.875rem;
    border-radius: 10px;
    text-align: center;
    font-weight: 500;
    font-size: 0.9rem;
}

.processing {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(99, 102, 241, 0.1));
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(34, 197, 94, 0.1));
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(248, 113, 113, 0.1));
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Processing Steps */
.processing-steps {
    margin-top: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.step-icon.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    animation: rotate 2s linear infinite;
}

.step-icon.completed {
    background: var(--success-color);
    color: white;
}

.step-icon.error {
    background: var(--error-color);
    color: white;
}

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

.step-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-color);
}

.step-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Modern Tabs */
.tabs {
    list-style: none;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.tabs li {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: 8px 8px 0 0;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.tabs li::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tabs li:hover {
    color: var(--text-color);
    background: rgba(99, 102, 241, 0.05);
}

.tabs li.active {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.08);
}

.tabs li.active::after {
    transform: scaleX(1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Zoom Controls */
.zoom-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.zoom-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color);
    font-weight: 600;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.625rem 1.125rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    font-weight: 600;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.nav-btn:disabled {
    background: var(--background-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

/* Info Elements */
.file-info, .results-info, .table-detection-info {
    margin-top: 1rem;
    padding: 0.875rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.file-info {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(34, 197, 94, 0.08));
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: none;
}

.results-info {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: none;
}

.table-detection-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.08));
    border: 1px solid rgba(59, 130, 246, 0.2);
    display: none;
}

.page-info {
    text-align: center;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Warning Note */
.warning-note {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(251, 191, 36, 0.1));
    border-left: 4px solid var(--warning-color);
    padding: 0.875rem;
    margin: 1rem 0;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Tables */
.processed-preview {
    overflow: auto;
    max-height: 500px;
    border-radius: 8px;
}

.metadata {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.voter-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.voter-table th, .voter-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.voter-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.voter-table tr:nth-child(even) {
    background: rgba(99, 102, 241, 0.03);
}

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 350px 1fr;
    }
}

@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    .pdf-preview-container {
        min-height: 500px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1.5rem 1rem 2rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .hindi-title {
        font-size: 1.5rem;
    }
    
    .theme-toggle, .language-toggle {
        top: 1rem;
    }
    
    .theme-toggle {
        right: 1rem;
        width: 40px;
        height: 40px;
    }
    
    .language-toggle {
        left: 1rem;
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }
    
    .main-content {
        padding: 0.75rem;
        gap: 1rem;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .ad-subjects {
        gap: 0.5rem;
    }
    
    .ad-subjects span {
        padding: 0.2rem 0.6rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .upload-area {
        padding: 2rem 1rem;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .navigation {
        gap: 0.5rem;
    }
    
    .nav-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.85rem;
    }
    
    .zoom-controls {
        gap: 0.375rem;
    }
    
    .zoom-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Loading Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    animation: spin 1s linear infinite;
}