/* CSS Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #6c757d;
    --color-primary: #4361ee;
    --color-primary-dark: #3a56d4;
    --color-success: #06d6a0;
    --color-warning: #ffd166;
    --color-danger: #ef476f;
    --color-info: #118ab2;
    --color-border: #e9ecef;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--color-text);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 0.5rem;
}

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

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
}

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

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

/* Cards */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
}

th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg);
}

tr {
    border-bottom: 1px solid var(--color-border);
}

tbody tr:hover {
    background: var(--color-bg);
}

tbody tr:last-child {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-pending {
    background: #f1f3f4;
    color: var(--color-text-muted);
}

.badge-processing {
    background: #e3f2fd;
    color: var(--color-info);
}

.badge-approved {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-declined {
    background: #ffebee;
    color: #c62828;
}

.badge-warning {
    background: #fff8e1;
    color: #f57f17;
}

.badge-standard {
    background: #e8eaf6;
    color: #3949ab;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 0.375rem;
}

/* File Upload */
.file-upload {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-upload:hover {
    border-color: var(--color-primary);
    background: rgba(67, 97, 238, 0.02);
}

.file-upload-icon {
    font-size: 2.5rem;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.file-upload input[type="file"] {
    display: none;
}

/* Pipeline Progress */
.pipeline-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
}

.pipeline-progress::before {
    content: '';
    position: absolute;
    top: 1.25rem;
    left: 2rem;
    right: 2rem;
    height: 2px;
    background: var(--color-border);
    z-index: 0;
}

.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
}

.pipeline-step-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
}

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

.pipeline-step.active .pipeline-step-icon {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(67, 97, 238, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(67, 97, 238, 0); }
}

.pipeline-step-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-align: center;
}

.pipeline-step.completed .pipeline-step-label,
.pipeline-step.active .pipeline-step-label {
    color: var(--color-text);
}

/* Analysis Results */
.analysis-section {
    margin-bottom: 1.5rem;
}

.analysis-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.analysis-card {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.analysis-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

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

.analysis-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.analysis-value {
    font-weight: 500;
}

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.score-bar {
    flex: 1;
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.score-fill.low {
    background: var(--color-success);
}

.score-fill.medium {
    background: var(--color-warning);
}

.score-fill.high {
    background: var(--color-danger);
}

.score-value {
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.alert-error {
    background: #ffebee;
    color: #c62828;
}

.alert-warning {
    background: #fff8e1;
    color: #f57f17;
}

.alert-info {
    background: #e3f2fd;
    color: var(--color-info);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.alert-close:hover {
    opacity: 1;
}

/* Grid Layout */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--color-text-muted);
}

/* Footer */
.footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer p {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
}

/* Document List */
.document-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.document-icon {
    width: 2rem;
    height: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.document-name {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.document-type {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Flag List */
.flag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.flag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #fff8e1;
    color: #f57f17;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
}

.flag-item.high-risk {
    background: #ffebee;
    color: #c62828;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
