/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;

    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.3);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.3);
    --accent-orange: #f59e0b;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-card: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-blue-glow);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
    --error-red: #ef4444;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== App Container ===== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

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

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex: 0 1 550px;
}

.subtitle {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* ===== Upload Section ===== */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.upload-card {
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.upload-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-card);
    pointer-events: none;
}

.upload-card:hover,
.upload-card.drag-over {
    border-color: var(--accent-blue);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.upload-icon svg {
    width: 40px;
    height: 40px;
    color: var(--accent-blue);
}

.upload-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-card>p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.file-info {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-md);
    color: var(--accent-blue);
    font-weight: 500;
    display: none;
}

.file-info.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    background: var(--gradient-primary);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
}

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

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

.btn-primary svg {
    width: 20px;
    height: 20px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

.btn-secondary:disabled,
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-muted);
}

.btn-secondary:disabled:hover,
.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
    color: var(--text-muted);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-ghost svg {
    width: 18px;
    height: 18px;
}

.btn-generate {
    width: 100%;
    justify-content: center;
    padding: 1rem;
    margin-top: 1rem;
}

/* ===== Mapping Card ===== */
.mapping-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mapping-card h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.mapping-card h3 svg {
    width: 24px;
    height: 24px;
    color: var(--accent-purple);
}

.mapping-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.mapping-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mapping-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.label-icon {
    font-size: 1.1rem;
}

.mapping-item select {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 18px;
    padding-right: 2.5rem;
}

.mapping-item select:hover {
    border-color: var(--border-hover);
}

.mapping-item select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

/* ===== Results Section ===== */
.results-section {
    margin-top: 1rem;
    animation: fadeIn 0.5s ease;
}

.results-title h2 svg {
    width: 28px;
    height: 28px;
    color: var(--accent-blue);
}

.badge {
    padding: 0.25rem 0.75rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
}

/* ===== Table Container ===== */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.table-filters {
    display: flex;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 200px;
    flex: 1;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group label svg {
    width: 16px;
    height: 16px;
}

.filter-group select {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 18px;
    padding-right: 2.5rem;
}

.filter-group select:hover,
.filter-group input:hover {
    border-color: var(--accent-primary);
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ===== Custom Searchable Select ===== */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 2.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.search-container .chevron {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
    pointer-events: none;
    transition: transform var(--transition-fast);
}

.custom-select-wrapper.active .chevron {
    transform: rotate(180deg);
}

.options-list {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.custom-select-wrapper.active .options-list {
    display: block;
}

.option-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

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

.option-item:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.option-item.selected {
    background: var(--accent-primary);
    color: white;
}

.no-results {
    padding: 1rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
    font-size: 0.9rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-group.search-group {
    flex: 0 1 400px;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    padding-bottom: 2px;
}

.filter-group input {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.filter-group input::placeholder {
    color: var(--text-muted);
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-secondary);
}

.data-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.data-table th:hover {
    color: var(--text-primary);
}

.data-table th svg {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-left: 0.25rem;
    opacity: 0.5;
    transition: all var(--transition-fast);
}

.data-table th:hover svg {
    opacity: 1;
}

.data-table th.sorted svg {
    opacity: 1;
    color: var(--accent-blue);
}

.data-table th.sorted.desc svg {
    transform: rotate(180deg);
}

.data-table td {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.data-table td:first-child {
    font-weight: 500;
}

.data-table td:last-child {
    font-weight: 600;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
    margin-top: auto;
    padding-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .upload-card {
        padding: 2.5rem 1.5rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-actions {
        width: 100%;
    }

    .results-actions button {
        flex: 1;
        justify-content: center;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Admin Dashboard ===== */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.admin-card.primary {
    border-color: rgba(99, 102, 241, 0.2);
}

.admin-card:not(.disabled):hover {
    border-color: var(--accent-blue);
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(59, 130, 246, 0.1);
}

.admin-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.card-icon {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    flex-shrink: 0;
}

.admin-card:hover .card-icon {
    background: rgba(59, 130, 246, 0.1);
}

.card-icon svg {
    width: 32px;
    height: 32px;
}

.card-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.card-info p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.card-arrow {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.admin-card:hover .card-arrow {
    transform: translateX(5px);
    color: var(--accent-blue);
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-card {
        padding: 1.5rem;
    }
}

/* ===== Login Modal ===== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeInScale 0.4s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-card h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 1.5rem 0 0.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    margin-top: 1rem;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.error-msg {
    margin-top: 1.25rem;
    color: var(--error-red);
    font-size: 0.85rem;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.hidden {
    display: none !important;
}

/* Logout Button */
.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: var(--error-red);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-left: auto;
}

.btn-logout:hover {
    background: var(--error-red);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-logout svg {
    width: 16px;
    height: 16px;
}