/* ===================================
   JuryNER - Modern Legal PII Anonymizer
   Design System & Styles
   =================================== */

/* CSS Variables */
:root {
    /* Colors - Neutral Palette */
    --color-bg: #f8fafc;
    --color-bg-elevated: #ffffff;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    /* Text Colors */
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;

    /* Brand Colors */
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-primary-light: #dbeafe;

    --color-secondary: #6366f1;
    --color-secondary-hover: #4f46e5;

    /* Status Colors */
    --color-success: #10b981;
    --color-success-light: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-error: #ef4444;
    --color-error-light: #fee2e2;

    /* Entity Colors */
    --color-entity-person: #ec4899;
    --color-entity-location: #8b5cf6;
    --color-entity-org: #06b6d4;
    --color-entity-legal: #f97316;
    --color-entity-contact: #10b981;
    --color-entity-financial: #eab308;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --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);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-lg) var(--space-xl);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--color-primary);
}

.logo h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
}

.tagline {
    margin-top: var(--space-xs);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

/* Main Content */
.main {
    flex: 1;
    padding: var(--space-xl);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Cards */
.card {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.card-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.actions {
    display: flex;
    gap: var(--space-sm);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

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

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

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

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

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

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

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

/* Text Input */
.text-input {
    width: 100%;
    min-height: 200px;
    padding: var(--space-md);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: var(--font-size-sm);
    line-height: 1.7;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.text-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

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

.input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-sm);
}

.char-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Controls Section */
.controls-grid {
    display: grid;
    gap: var(--space-lg);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.control-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Entity Filters */
.entity-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.entity-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.entity-chip input {
    display: none;
}

.entity-chip.personal {
    background: #fce7f3;
    color: #be185d;
    border: 1px solid #f9a8d4;
}

.entity-chip.personal.active {
    background: #ec4899;
    color: white;
}

.entity-chip.legal {
    background: #ffedd5;
    color: #c2410c;
    border: 1px solid #fdba74;
}

.entity-chip.legal.active {
    background: #f97316;
    color: white;
}

.entity-chip.location {
    background: #ede9fe;
    color: #6d28d9;
    border: 1px solid #c4b5fd;
}

.entity-chip.location.active {
    background: #8b5cf6;
    color: white;
}

.entity-chip.contact {
    background: #d1fae5;
    color: #047857;
    border: 1px solid #6ee7b7;
}

.entity-chip.contact.active {
    background: #10b981;
    color: white;
}

.entity-chip.financial {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.entity-chip.financial.active {
    background: #f59e0b;
    color: white;
}

/* Method Selector */
.method-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-sm);
}

.radio-card {
    display: block;
    cursor: pointer;
}

.radio-card input {
    display: none;
}

.radio-content {
    display: flex;
    flex-direction: column;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.radio-card input:checked + .radio-content {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.radio-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.radio-desc {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-family: monospace;
}

/* Slider */
.slider {
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-value {
    font-weight: 600;
    color: var(--color-primary);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border);
}

.action-buttons .btn {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
}

/* Results Section */
.result-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-sm);
}

.meta-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Tabs */
.tabs {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-xs);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tab.active {
    background: var(--color-bg-elevated);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Entities List */
.entities-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 400px;
    overflow-y: auto;
}

.entity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.entity-item:hover {
    background: var(--color-border-light);
}

.entity-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.entity-type-badge {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.entity-text {
    font-family: monospace;
    font-size: var(--font-size-sm);
}

.entity-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.confidence-bar {
    width: 60px;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: var(--color-success);
    transition: width var(--transition-normal);
}

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

.confidence-fill.low {
    background: var(--color-error);
}

.confidence-value {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    min-width: 40px;
    text-align: right;
}

/* Preview */
.preview-header {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.preview-text {
    padding: var(--space-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: var(--font-size-sm);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* Highlighted Text */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding: var(--space-sm);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.highlighted-text {
    padding: var(--space-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    line-height: 2;
    max-height: 400px;
    overflow-y: auto;
}

.highlight {
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

.highlight-PERSON { background: #fce7f3; color: #be185d; }
.highlight-LOCATION { background: #ede9fe; color: #6d28d9; }
.highlight-ORGANIZATION { background: #cffafe; color: #0e7490; }
.highlight-EMAIL { background: #d1fae5; color: #047857; }
.highlight-PHONE { background: #d1fae5; color: #047857; }
.highlight-NUM_RCS { background: #ffedd5; color: #c2410c; }
.highlight-SIRET { background: #ffedd5; color: #c2410c; }
.highlight-SIREN { background: #ffedd5; color: #c2410c; }
.highlight-NUM_SECU { background: #fef3c7; color: #b45309; }
.highlight-REF_DOSSIER { background: #ffedd5; color: #c2410c; }
.highlight-NUM_PARQUET { background: #ffedd5; color: #c2410c; }
.highlight-IBAN { background: #fef3c7; color: #b45309; }
.highlight-NUM_AVOCAT { background: #ffedd5; color: #c2410c; }

/* Warning Banner */
.warning-banner {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
    background: var(--color-warning-light);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-md);
    color: #92400e;
}

.warning-banner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 1001;
}

.toast {
    padding: var(--space-md) var(--space-lg);
    background: var(--color-text);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

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

.toast.error {
    background: var(--color-error);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Sample Dropdown */
.sample-dropdown {
    position: relative;
}

.sample-dropdown .dropdown-arrow {
    width: 14px;
    height: 14px;
    margin-left: var(--space-xs);
    transition: transform var(--transition-fast);
}

.sample-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.sample-menu {
    position: absolute;
    top: calc(100% + var(--space-xs));
    right: 0;
    min-width: 220px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.sample-dropdown.open .sample-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sample-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast);
}

.sample-menu-item:hover {
    background: var(--color-bg);
}

.sample-menu-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.sample-menu-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.sample-menu-item svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
}

/* Footer */
.footer {
    padding: var(--space-lg);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    border-top: 1px solid var(--color-border);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: var(--space-md);
    }

    .main {
        padding: var(--space-md);
    }

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

    .action-buttons {
        flex-direction: column;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
}
