/* Modern, Clean Design System */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--gray-600);
    font-size: 16px;
}

.nav-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--primary-light);
}

/* Card */
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
}

.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.help-text {
    color: var(--gray-600);
    font-size: 14px;
}

/* Upload Zone */
.upload-zone {
    border: 3px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 48px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--gray-50);
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 13px;
    color: var(--gray-500);
    font-family: 'Courier New', monospace;
}

/* File Info Card */
.file-info-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 2px solid var(--gray-200);
    margin: 20px 0;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 16px;
}

.file-icon-large {
    font-size: 40px;
}

.file-name {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.file-size {
    font-size: 14px;
    color: var(--gray-600);
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Week Info */
.week-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
    padding: 20px;
    background: var(--info-light);
    border-radius: var(--radius);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
}

.info-value.status {
    color: var(--success);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-300);
}

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

.btn-large {
    width: 100%;
    padding: 18px 32px;
    font-size: 18px;
    margin-top: 20px;
}

.btn-icon {
    font-size: 20px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-card {
    background: white;
    padding: 48px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-xl);
}

.spinner {
    width: 64px;
    height: 64px;
    border: 6px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.loading-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
}

/* Error Card */
.error-card {
    background: var(--danger-light);
    border: 2px solid var(--danger);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.error-icon {
    font-size: 32px;
}

.error-content h3 {
    color: var(--danger);
    margin-bottom: 8px;
}

.error-content p {
    color: var(--gray-700);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 40px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
}

.stat-new {
    border-left: 4px solid var(--success);
}

.stat-new .stat-value {
    color: var(--success);
}

.stat-modified {
    border-left: 4px solid var(--warning);
}

.stat-modified .stat-value {
    color: var(--warning);
}

.stat-removed {
    border-left: 4px solid var(--danger);
}

.stat-removed .stat-value {
    color: var(--danger);
}

.stat-unchanged {
    border-left: 4px solid var(--gray-400);
}

.stat-unchanged .stat-value {
    color: var(--gray-600);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.download-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* EID Section */
.eid-count {
    background: var(--primary-light);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

#eid-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.eid-group {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.2s;
}

.eid-group:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.eid-header {
    background: var(--gray-50);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.eid-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

.eid-stats {
    display: flex;
    gap: 16px;
}

.eid-stat {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
}

.eid-stat.new {
    background: var(--success-light);
    color: var(--success);
}

.eid-stat.modified {
    background: var(--warning-light);
    color: var(--warning);
}

.eid-stat.removed {
    background: var(--danger-light);
    color: var(--danger);
}

.eid-content {
    padding: 20px;
    display: none;
}

.eid-content.expanded {
    display: block;
}

.change-section {
    margin-bottom: 24px;
}

.change-section-header {
    background: var(--gray-100);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.change-section-header:hover {
    background: var(--gray-200);
}

.change-details {
    display: none;
    padding: 16px;
}

.change-details.expanded {
    display: block;
}

.change-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.change-table th {
    background: var(--gray-100);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--gray-300);
}

.change-table td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.change-table tr:hover {
    background: var(--gray-50);
}

.delta-positive {
    color: var(--success);
    font-weight: 600;
}

.delta-negative {
    color: var(--danger);
    font-weight: 600;
}

.field-changed {
    background: var(--warning-light);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: white;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .action-bar {
        flex-direction: column;
    }
    
    .download-buttons {
        width: 100%;
        flex-direction: column;
    }
    
    .download-buttons button {
        width: 100%;
    }
}


/* ===== Field-Level Change Viewer Styles ===== */

.modified-record-card {
    margin-bottom: 20px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.2s ease;
}

.modified-record-card:hover {
    box-shadow: var(--shadow-md);
}

.modified-record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--gray-50);
    cursor: pointer;
    transition: background 0.2s ease;
}

.modified-record-header:hover {
    background: var(--gray-100);
}

.modified-record-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.record-icon {
    font-size: 20px;
}

.record-demand-id {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 15px;
}

.no-demand-id {
    color: var(--warning);
    font-weight: 600;
}

.modified-record-summary {
    display: flex;
    align-items: center;
    gap: 12px;
}

.changes-count {
    font-size: 14px;
    color: var(--gray-600);
    font-weight: 500;
}

.expand-icon {
    font-size: 12px;
    color: var(--gray-500);
    transition: transform 0.2s ease;
}

.modified-record-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.modified-record-content.expanded {
    max-height: 2000px;
    padding: 20px;
    border-top: 1px solid var(--gray-200);
}

/* Composite Key Warning */
.composite-key-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--warning-light);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--gray-700);
}

.warning-icon {
    font-size: 18px;
}

.composite-key-details {
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.composite-key-details strong {
    display: block;
    margin-bottom: 12px;
    color: var(--gray-700);
    font-size: 14px;
}

.composite-key-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    font-size: 13px;
}

.composite-key-grid div {
    padding: 8px 12px;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.composite-key-grid strong {
    display: inline;
    color: var(--gray-600);
    font-weight: 600;
    margin-right: 6px;
}

/* Field Changes Section */
.field-changes-section {
    margin-bottom: 20px;
}

.field-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.field-changes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field-change-item {
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.field-change-name {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    margin-bottom: 6px;
}

.field-change-values {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
}

.old-value {
    color: var(--gray-500);
    text-decoration: line-through;
    padding: 4px 8px;
    background: var(--gray-100);
    border-radius: 4px;
}

.change-arrow {
    color: var(--gray-400);
    font-weight: bold;
}

.new-value {
    color: var(--gray-800);
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
}

.new-value.highlighted {
    background: var(--success-light);
    color: var(--success);
    font-weight: 600;
}

.delta-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.delta-badge.delta-positive {
    background: var(--success-light);
    color: var(--success);
}

.delta-badge.delta-negative {
    background: var(--danger-light);
    color: var(--danger);
}

/* Unchanged Fields Section */
.unchanged-fields-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.unchanged-fields-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
}

.unchanged-fields-header:hover {
    background: var(--gray-200);
}

.expand-icon-small {
    font-size: 10px;
    color: var(--gray-500);
    transition: transform 0.2s ease;
}

.unchanged-fields-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-top: 12px;
}

.unchanged-fields-content.collapsed {
    max-height: 0;
    margin-top: 0;
}

.unchanged-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
}

.unchanged-field-item {
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    gap: 6px;
}

.unchanged-field-item .field-name {
    color: var(--gray-600);
    font-weight: 500;
}

.unchanged-field-item .field-value {
    color: var(--gray-800);
}

/* Badge Styles for Signed/Unsigned */
.badge-signed,
.badge-unsigned {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-signed {
    background: var(--success-light);
    color: var(--success);
}

.badge-unsigned {
    background: var(--warning-light);
    color: var(--warning);
}


/* ===== Enhanced Comparison Results Display ===== */

.comparison-meta {
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.comparison-meta > div {
    margin-bottom: 6px;
}

/* ===== MaitreD Results Enhancements ===== */

.maitred-summary .summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-label {
    font-size: 13px;
    color: var(--gray-600);
    font-weight: 500;
}

.summary-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.summary-value.warning {
    color: var(--warning);
}

.maitred-downloads {
    margin-top: 24px;
}

.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.download-card {
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.2s ease;
}

.download-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.download-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.download-eid {
    font-weight: 600;
    color: var(--gray-800);
}

.download-count {
    font-size: 13px;
    color: var(--gray-600);
    background: white;
    padding: 4px 8px;
    border-radius: 12px;
}

.btn-download {
    width: 100%;
    margin-bottom: 8px;
}

.download-expires {
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
}

/* ===== Status Updates Styling ===== */

.status-updates {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 20px;
}

.status-update {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: var(--gray-50);
}

.status-update.info {
    border-left: 3px solid var(--info);
}

.status-update.success {
    border-left: 3px solid var(--success);
    background: var(--success-light);
}

.status-update.warning {
    border-left: 3px solid var(--warning);
    background: var(--warning-light);
}

.status-update-icon {
    font-size: 18px;
}

.status-update-text {
    font-size: 14px;
    color: var(--gray-700);
}


/* Status Updates Container */
.status-updates-container {
    margin-top: 24px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.status-update {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: white;
    animation: slideIn 0.3s ease;
}

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

.status-update.info {
    border-left: 3px solid var(--info);
}

.status-update.success {
    border-left: 3px solid var(--success);
}

.status-update.warning {
    border-left: 3px solid var(--warning);
}

.status-update-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.status-update-text {
    flex: 1;
    font-size: 14px;
    color: var(--gray-700);
}
