/* ------------------------------------------------------------------ */
/* Design Tokens & CSS Reset                                          */
/* ------------------------------------------------------------------ */
:root {
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Sleek HSL Tailored Theme (Slate & Neon Indigo/Teal) */
    --bg-dark: 222 47% 7%;
    --card-bg: 222 47% 11% / 0.6;
    --card-border: 222 47% 20% / 0.4;
    
    --primary: 263 90% 64%;      /* Royal Purple/Indigo */
    --primary-glow: 263 90% 64% / 0.35;
    --accent: 172 90% 50%;       /* Neon Teal */
    --accent-glow: 172 90% 50% / 0.35;
    
    --text-primary: 210 40% 98%;
    --text-secondary: 215 20% 70%;
    --text-muted: 215 15% 45%;
    
    --success: 142 70% 45%;
    --warning: 38 92% 50%;
    --danger: 0 84% 60%;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-sans);
    background-color: hsl(var(--bg-dark));
    color: hsl(var(--text-primary));
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Background Glowing Orbs */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-bg::before,
.glow-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
}

.glow-bg::before {
    top: -10%;
    left: 10%;
    width: 40vw;
    height: 40vw;
    background: hsl(var(--primary));
}

.glow-bg::after {
    bottom: -10%;
    right: 10%;
    width: 35vw;
    height: 35vw;
    background: hsl(var(--accent));
}

/* Glassmorphism base */
.glass {
    background: hsl(var(--card-bg));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid hsl(var(--card-border));
}

/* ------------------------------------------------------------------ */
/* Layout Structure                                                   */
/* ------------------------------------------------------------------ */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid hsl(var(--card-border));
    background: hsl(222 47% 5% / 0.85);
    padding: 24px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid hsl(var(--card-border));
}

.brand-icon {
    font-size: 28px;
}

.brand-text h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff, hsl(var(--text-secondary)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: hsl(var(--accent));
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: hsl(var(--text-secondary));
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

.nav-item:hover {
    background: hsl(222 47% 20% / 0.3);
    color: hsl(var(--text-primary));
}

.nav-item.active {
    background: linear-gradient(135deg, hsl(var(--primary) / 0.25), hsl(var(--primary) / 0.05));
    border: 1px solid hsl(var(--primary) / 0.4);
    color: hsl(var(--text-primary));
    box-shadow: 0 4px 20px -5px hsl(var(--primary-glow));
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid hsl(var(--card-border));
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: hsl(var(--text-secondary));
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.pulse-red {
    background-color: hsl(var(--danger));
    box-shadow: 0 0 0 0 hsl(var(--danger) / 0.7);
    animation: pulse-red 2s infinite;
}

.pulse-green {
    background-color: hsl(var(--success));
    box-shadow: 0 0 0 0 hsl(var(--success) / 0.7);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 hsl(var(--danger) / 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px hsl(var(--danger) / 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 hsl(var(--danger) / 0);
    }
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 hsl(var(--success) / 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px hsl(var(--success) / 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 hsl(var(--success) / 0);
    }
}

/* Main Content Workspace */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    padding: 32px;
    gap: 32px;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-radius: var(--radius-lg);
}

.header-title h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.header-title p {
    font-size: 14px;
    color: hsl(var(--text-secondary));
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
}

.badge-info {
    background: hsl(var(--primary) / 0.2);
    border: 1px solid hsl(var(--primary) / 0.4);
    color: hsl(var(--text-primary));
}

.badge-success {
    background: hsl(var(--success) / 0.2);
    border: 1px solid hsl(var(--success) / 0.4);
    color: hsl(var(--text-primary));
}

/* ------------------------------------------------------------------ */
/* Tab Management                                                     */
/* ------------------------------------------------------------------ */
.tab-panel {
    display: none;
    flex-direction: column;
    gap: 32px;
    width: 100%;
}

.tab-panel.active {
    display: flex;
}

/* Grid System */
.grid {
    display: grid;
    gap: 32px;
    width: 100%;
}

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

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
}

/* Card Styling */
.card {
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: hsl(var(--primary) / 0.3);
    box-shadow: 0 10px 30px -10px hsl(var(--primary-glow) / 0.5);
}

.card-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid hsl(var(--card-border));
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 svg {
    color: hsl(var(--accent));
    width: 20px;
    height: 20px;
}

.card-body {
    padding: 24px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Form Controls & Inputs */
textarea {
    width: 100%;
    height: 260px;
    background: hsl(222 47% 4% / 0.6);
    border: 1px solid hsl(var(--card-border));
    border-radius: var(--radius-md);
    padding: 16px;
    color: hsl(var(--text-primary));
    font-family: inherit;
    font-size: 15px;
    resize: none;
    outline: none;
    transition: var(--transition-smooth);
}

textarea:focus {
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 4px hsl(var(--primary-glow));
    background: hsl(222 47% 2% / 0.8);
}

.input-counter {
    text-align: right;
    font-size: 12px;
    color: hsl(var(--text-muted));
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.btn-primary {
    background: hsl(var(--primary));
    color: #fff;
}

.btn-primary:hover {
    background: hsl(263 90% 70%);
}

.btn-secondary {
    background: hsl(222 47% 20% / 0.4);
    border: 1px solid hsl(var(--card-border));
    color: hsl(var(--text-primary));
}

.btn-secondary:hover {
    background: hsl(222 47% 25% / 0.6);
}

.btn-glow {
    box-shadow: 0 4px 20px -2px hsl(var(--primary-glow));
}

.btn-glow:hover {
    box-shadow: 0 4px 30px 2px hsl(var(--primary-glow));
    transform: translateY(-1px);
}

/* Result Visualization UI */
.result-container {
    min-height: 260px;
    justify-content: center;
    align-items: center;
}

.placeholder-state {
    text-align: center;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: hsl(var(--primary) / 0.15);
    border: 1px solid hsl(var(--primary) / 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--primary));
}

.placeholder-icon svg {
    width: 28px;
    height: 28px;
}

.placeholder-state h4 {
    font-size: 18px;
    font-weight: 600;
}

.placeholder-state p {
    font-size: 14px;
    color: hsl(var(--text-secondary));
    max-width: 280px;
}

/* Prediction Details */
.result-details {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    width: 100%;
}

.result-gauge-box {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gauge-container {
    position: relative;
    width: 160px;
    height: 160px;
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-value span {
    font-size: 26px;
    font-weight: 800;
    color: hsl(var(--accent));
}

.gauge-value label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: hsl(var(--text-secondary));
}

.result-category-box {
    text-align: center;
    background: hsl(222 47% 20% / 0.2);
    border: 1px solid hsl(var(--card-border));
    border-radius: var(--radius-md);
    padding: 20px;
    width: 100%;
}

.meta-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: hsl(var(--accent));
    margin-bottom: 6px;
}

.category-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 10px;
}

.category-desc {
    font-size: 14px;
    color: hsl(var(--text-secondary));
}

/* ------------------------------------------------------------------ */
/* PDF Upload UI                                                     */
/* ------------------------------------------------------------------ */
.dropzone {
    width: 100%;
    border: 2px dashed hsl(var(--card-border));
    border-radius: var(--radius-lg);
    background: hsl(222 47% 4% / 0.3);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transition: var(--transition-smooth);
}

.dropzone:hover, .dropzone.active {
    border-color: hsl(var(--accent));
    background: hsl(172 90% 50% / 0.05);
}

.dropzone-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: hsl(var(--accent) / 0.12);
    border: 1px solid hsl(var(--accent) / 0.3);
    color: hsl(var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.dropzone h3 {
    font-size: 20px;
    font-weight: 600;
}

.dropzone p {
    font-size: 14px;
    color: hsl(var(--text-secondary));
}

.file-name-display {
    display: inline-flex;
    align-items: center;
    background: hsl(var(--accent) / 0.2);
    border: 1px solid hsl(var(--accent) / 0.4);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
}

.action-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

/* Table Design for Report */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.report-table th {
    background: hsl(222 47% 4% / 0.8);
    color: hsl(var(--text-secondary));
    font-size: 13px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 16px;
    border-bottom: 1px solid hsl(var(--card-border));
}

.report-table td {
    padding: 18px 16px;
    font-size: 14px;
    border-bottom: 1px solid hsl(var(--card-border));
}

.report-table tbody tr {
    transition: var(--transition-smooth);
}

.report-table tbody tr:hover {
    background: hsl(222 47% 20% / 0.2);
}

.text-index {
    color: hsl(var(--text-muted));
    font-weight: 600;
}

.clause-text-cell {
    font-family: inherit;
    color: hsl(var(--text-primary));
    max-width: 450px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.label-cell {
    font-weight: 600;
}

.confidence-val {
    font-weight: 700;
    color: hsl(var(--accent));
}

/* ------------------------------------------------------------------ */
/* Settings and Stats                                                 */
/* ------------------------------------------------------------------ */
.settings-desc {
    font-size: 14px;
    color: hsl(var(--text-secondary));
    line-height: 1.6;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: hsl(var(--text-secondary));
}

.form-group input {
    background: hsl(222 47% 4% / 0.8);
    border: 1px solid hsl(var(--card-border));
    color: hsl(var(--text-muted));
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

.form-group small {
    font-size: 12px;
    color: hsl(var(--text-muted));
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    height: 100%;
}

.stat-card {
    background: hsl(222 47% 20% / 0.15);
    border: 1px solid hsl(var(--card-border));
    padding: 24px;
    border-radius: var(--radius-md);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: hsl(var(--accent));
}

.stat-label {
    font-size: 13px;
    color: hsl(var(--text-secondary));
    font-weight: 500;
}

.status-tag {
    display: inline-flex;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 30px;
}

.status-tag.success {
    background: hsl(var(--success) / 0.15);
    color: hsl(142 70% 50%);
    border: 1px solid hsl(var(--success) / 0.3);
}

/* ------------------------------------------------------------------ */
/* Spinner / Loading Overlay                                          */
/* ------------------------------------------------------------------ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: hsl(var(--bg-dark) / 0.8);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-box {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

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

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

.spinner-box p {
    font-size: 16px;
    font-weight: 500;
    color: hsl(var(--text-primary));
}

/* ------------------------------------------------------------------ */
/* Animations & Helper Classes                                        */
/* ------------------------------------------------------------------ */
.hidden {
    display: none !important;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Micro-animations */
.animate-fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

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