/**
 * Ontology Co-pilot Design System
 * A sophisticated, academic-inspired design with warm neutrals and refined typography
 */

/* ============================================
   TYPOGRAPHY - Distinctive & Professional
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=IBM+Plex+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Typography */
    --font-display: 'DM Sans', system-ui, sans-serif;
    --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    /* Colors - Warm Academic Palette */
    --color-primary: #2D5A6B;
    --color-primary-light: #3A7285;
    --color-primary-dark: #1E3A47;
    --color-accent: #D4743E;
    --color-accent-light: #E89668;

    /* Neutrals */
    --color-bg: #FAFAF9;
    --color-surface: #FFFFFF;
    --color-border: #E7E5E4;
    --color-text: #292524;
    --color-text-muted: #78716C;
    --color-text-light: #A8A29E;

    /* Semantic Colors */
    --color-success: #16A34A;
    --color-warning: #EA580C;
    --color-error: #DC2626;
    --color-info: #0891B2;

    /* Spacing Scale */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   GLOBAL RESETS & BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text);
}

/* ============================================
   BOOTSTRAP-COMPATIBLE UTILITIES
   ============================================ */

/* Container */
.container-fluid {
    width: 100%;
    padding: var(--space-xl) var(--space-lg);
    max-width: 1400px;
    margin: 0 auto;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(-1 * var(--space-md));
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
    padding: 0 var(--space-md);
}

/* Spacing Utilities */
.mt-4 { margin-top: var(--space-xl); }
.mb-4 { margin-bottom: var(--space-xl); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-2 { margin-bottom: var(--space-md); }
.ms-2 { margin-left: var(--space-md); }
.py-4 { padding-top: var(--space-xl); padding-bottom: var(--space-xl); }
.p-4 { padding: var(--space-xl); }

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }

.d-none { display: none; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }

/* ============================================
   CARD COMPONENTS
   ============================================ */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all var(--transition-base);
    margin-bottom: var(--space-lg);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    padding: var(--space-lg) var(--space-xl);
    background: linear-gradient(to bottom, var(--color-surface), #F8F8F7);
    border-bottom: 1px solid var(--color-border);
}

.card-header h5 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-header h5 i {
    color: var(--color-primary);
    font-size: 1.25rem;
}

.card-body {
    padding: var(--space-xl);
}

/* ============================================
   PAGE HEADERS
   ============================================ */

.container-fluid > .row:first-child h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: var(--color-primary-dark);
}

.container-fluid > .row:first-child h2 i {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    box-shadow: var(--shadow-md);
}

.container-fluid > .row:first-child p {
    font-size: 1.0625rem;
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
}

/* ============================================
   UPLOAD AREA
   ============================================ */

#upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3xl);
    text-align: center;
    background: linear-gradient(to bottom, var(--color-surface), #FCFCFB);
    transition: all var(--transition-base);
    cursor: pointer;
}

#upload-area:hover {
    border-color: var(--color-primary);
    background: linear-gradient(to bottom, #FEFEFE, var(--color-surface));
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#upload-area.border-primary {
    border-color: var(--color-primary);
    background: linear-gradient(135deg,
        rgba(45, 90, 107, 0.03),
        rgba(58, 114, 133, 0.05)
    );
}

#upload-area i.fa-cloud-upload-alt {
    font-size: 3rem;
    color: var(--color-primary);
    margin-bottom: var(--space-lg);
    display: block;
    opacity: 0.7;
}

#upload-area p {
    font-size: 1.0625rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    font-weight: 500;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.5rem;
    font-family: var(--font-display);
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-outline-primary {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}

.btn-outline-primary:hover {
    background: var(--color-primary);
    color: white;
}

.btn-outline-info {
    background: transparent;
    color: var(--color-info);
    border: 1.5px solid var(--color-info);
}

.btn-outline-info:hover {
    background: var(--color-info);
    color: white;
}

.btn-outline-danger {
    background: transparent;
    color: var(--color-error);
    border: 1.5px solid var(--color-error);
}

.btn-outline-danger:hover {
    background: var(--color-error);
    color: white;
}

.btn-group {
    display: inline-flex;
    gap: var(--space-xs);
}

/* ============================================
   TABLE
   ============================================ */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9375rem;
}

.table thead {
    background: linear-gradient(to bottom, #FAFAF9, #F5F5F4);
}

.table thead th {
    padding: var(--space-md) var(--space-lg);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
    text-align: left;
}

.table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition-fast);
}

.table-hover tbody tr:hover {
    background: linear-gradient(to right,
        rgba(45, 90, 107, 0.02),
        rgba(45, 90, 107, 0.04)
    );
}

.table tbody td {
    padding: var(--space-lg);
    vertical-align: middle;
    color: var(--color-text);
}

.table tbody td i {
    margin-right: var(--space-sm);
    color: var(--color-primary);
    font-size: 1.125rem;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.bg-success {
    background: linear-gradient(135deg, #16A34A, #15803D);
    color: white;
}

.bg-info {
    background: linear-gradient(135deg, #0891B2, #0E7490);
    color: white;
}

.bg-secondary {
    background: linear-gradient(135deg, #78716C, #57534E);
    color: white;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

#upload-progress {
    margin-top: var(--space-lg);
}

.progress {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: 999px;
    transition: width var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.card-body .text-center.py-4 {
    padding: var(--space-3xl) var(--space-xl);
}

.card-body .text-center i.fa-inbox {
    font-size: 4rem;
    color: var(--color-text-light);
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.card-body .text-center p {
    font-size: 1.0625rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

/* ============================================
   ALERT MESSAGES
   ============================================ */

.alert {
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    font-size: 0.9375rem;
    border-left: 4px solid;
    animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: linear-gradient(to right, #DCFCE7, #F0FDF4);
    color: #15803D;
    border-left-color: #16A34A;
}

.alert-danger {
    background: linear-gradient(to right, #FEE2E2, #FEF2F2);
    color: #B91C1C;
    border-left-color: #DC2626;
}

.alert-warning {
    background: linear-gradient(to right, #FED7AA, #FFEDD5);
    color: #C2410C;
    border-left-color: #EA580C;
}

.alert-info {
    background: linear-gradient(to right, #CFFAFE, #ECFEFF);
    color: #0E7490;
    border-left-color: #0891B2;
}

.alert i {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-dismissible {
    padding-right: var(--space-2xl);
    position: relative;
}

.btn-close {
    position: absolute;
    right: var(--space-md);
    top: var(--space-md);
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    padding: var(--space-xs);
}

.btn-close:hover {
    opacity: 1;
}

.btn-close::before {
    content: '×';
    font-size: 1.5rem;
    line-height: 1;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .container-fluid {
        padding: var(--space-lg) var(--space-md);
    }

    .card-header,
    .card-body {
        padding: var(--space-lg);
    }

    .table thead th,
    .table tbody td {
        padding: var(--space-md);
    }

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }

    #upload-area {
        padding: var(--space-xl);
    }

    .container-fluid > .row:first-child h2 {
        font-size: 1.5rem;
    }

    .container-fluid > .row:first-child h2 i {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
}

/* ============================================
   MICRO-INTERACTIONS & POLISH
   ============================================ */

/* Smooth transitions on interactive elements */
a, button, input, textarea, select {
    transition: all var(--transition-base);
}

/* Focus states for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Loading state shimmer effect */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Fade in animation for content */
.fade-in {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Border animations for drag-and-drop */
.border-2 {
    border-width: 2px;
}

.border-dashed {
    border-style: dashed;
}

.rounded {
    border-radius: var(--radius-md);
}

/* ============================================
   ENHANCED INTERACTIONS
   ============================================ */

/* Refresh button rotation on click */
.btn .fa-sync-alt {
    transition: transform var(--transition-base);
}

.btn:active .fa-sync-alt {
    transform: rotate(180deg);
}

/* Table row animations */
.table tbody tr {
    animation: fadeInRow 0.3s ease backwards;
}

.table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.table tbody tr:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Enhanced button hover states */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width var(--transition-slow), height var(--transition-slow);
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

/* Icon pulse on hover */
.card-header h5 i,
.btn i {
    display: inline-block;
}

.card:hover .card-header h5 i {
    animation: pulse-icon 0.6s ease;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Badge animations */
.badge {
    transition: all var(--transition-base);
}

.badge:hover {
    transform: scale(1.05);
}

/* Enhanced empty state */
.text-center.py-4 {
    animation: fadeIn 0.6s ease;
}

/* Tooltip-like title effects */
[title] {
    position: relative;
    cursor: help;
}

/* Loading spinner for async operations */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   VERIFICATION HISTORY STYLES
   ============================================ */

/* Verification History Section */
.verification-history-section {
    background: #fef9f3;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.verification-history-section:hover {
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.1);
}

/* Intention Reminder */
.intention-reminder {
    background: white;
    border-left: 4px solid var(--color-primary);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.intention-reminder p {
    margin: 0;
    color: #374151;
    font-style: italic;
    line-height: 1.6;
}

/* Previous Attempts Accordion */
.previous-attempts .card {
    border: 1px solid #e5e7eb;
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
}

.previous-attempts .card-header {
    background: #f9fafb;
    padding: 12px 16px;
    border-bottom: none;
}

.previous-attempts .card-header button {
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    width: 100%;
    text-align: left;
    padding: 0;
    display: block;
}

.previous-attempts .card-header button:hover {
    color: var(--color-primary);
}

.previous-attempts .card-header button:focus {
    outline: none;
    box-shadow: none;
}

/* Chevron rotation animation */
.card-header button i.fa-chevron-right {
    transition: transform 0.2s ease;
    display: inline-block;
}

.card-header button[aria-expanded="true"] i.fa-chevron-right {
    transform: rotate(90deg);
}

/* Attempt Card Body */
.previous-attempts .card-body {
    padding: 16px;
    background: white;
}

/* User Notes Box */
.previous-attempts .user-notes-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.previous-attempts .user-notes-box p {
    margin: 0;
    color: #1e3a8a;
    font-size: 0.9rem;
}

/* AI Feedback Box */
.previous-attempts .ai-feedback-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 12px;
    border-radius: 4px;
    margin-top: 12px;
}

.previous-attempts .ai-feedback-box.success {
    background: #d1fae5;
    border-left-color: #10b981;
}

/* Timeline for Standalone Verification History */
.verification-history-standalone {
    background: #fef9f3;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.attempts-timeline {
    margin-top: 20px;
}

.timeline-item {
    border-left: 3px solid #f59e0b;
    padding-left: 20px;
    margin-bottom: 24px;
    position: relative;
}

.timeline-item.success {
    border-left-color: #10b981;
}

/* Timeline dot */
.timeline-item::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f59e0b;
}

.timeline-item.success::before {
    background: #10b981;
}

/* Progress Indicator */
.verification-history-section .progress-indicator {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #fed7aa;
}

.verification-history-section .progress-indicator p {
    color: #92400e;
    font-size: 0.85rem;
    margin: 0;
}

/* Learning Insights Box */
.learning-insights {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
}

.learning-insights p {
    margin: 0;
    color: #1e3a8a;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .verification-history-section {
        padding: 16px;
    }
    
    .timeline-item {
        padding-left: 16px;
    }
    
    .verification-history-standalone {
        padding: 16px;
    }
}

/* Animation for new attempts */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.verification-history-section.new-attempt {
    animation: slideIn 0.3s ease-out;
}

/* Confidence Badge Styling */
.verification-history-section .badge {
    font-weight: 500;
    padding: 4px 10px;
    font-size: 0.85rem;
}

/* Notes Textarea Styling (for re-verification) */
.verification-notes-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
}

.verification-notes-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 107, 0.1);
}

.verification-notes-input::placeholder {
    color: var(--color-text-light);
    font-style: italic;
}
