/* MicroView - Modern Blood Cell Analysis Platform */
/* Design System: 2026 Clean Medical UI */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
    /* Primary palette - Deep medical blue to teal */
    --mv-primary: #0f766e;
    --mv-primary-light: #14b8a6;
    --mv-primary-dark: #0d5f58;
    --mv-primary-bg: #f0fdfa;
    --mv-primary-subtle: #ccfbf1;

    /* Accent */
    --mv-accent: #6366f1;
    --mv-accent-light: #818cf8;

    /* Neutrals */
    --mv-gray-50: #f8fafc;
    --mv-gray-100: #f1f5f9;
    --mv-gray-200: #e2e8f0;
    --mv-gray-300: #cbd5e1;
    --mv-gray-400: #94a3b8;
    --mv-gray-500: #64748b;
    --mv-gray-600: #475569;
    --mv-gray-700: #334155;
    --mv-gray-800: #1e293b;
    --mv-gray-900: #0f172a;

    /* Semantic colors */
    --mv-success: #059669;
    --mv-danger: #dc2626;
    --mv-warning: #d97706;
    --mv-info: #0284c7;

    /* Cell type colors */
    --cell-artifact: #84cc16;
    --cell-platelet: #8b5cf6;
    --cell-red: #ef4444;
    --cell-red-abnormal: #06b6d4;
    --cell-white: #3b82f6;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Base & Typography
   ============================================ */
body {
    font-family: var(--font-sans);
    color: var(--mv-gray-800);
    background-color: var(--mv-gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main {
    flex: 1;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--mv-gray-900);
    letter-spacing: -0.01em;
}

a {
    color: var(--mv-primary);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--mv-primary-dark);
}

.container {
    max-width: 1200px;
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--mv-gray-200);
    padding: 0.6rem 0;
    z-index: 1030;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--mv-gray-900) !important;
    letter-spacing: -0.02em;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--mv-primary), var(--mv-primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
}

.navbar .nav-link {
    color: var(--mv-gray-600) !important;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 0.85rem !important;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.navbar .nav-link:hover {
    color: var(--mv-primary) !important;
    background: var(--mv-primary-bg);
}

.navbar .dropdown-menu {
    border-radius: var(--radius-md);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.navbar .dropdown-item {
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

.navbar .dropdown-item:hover {
    background: var(--mv-gray-100);
}

.navbar-toggler-icon {
    filter: invert(40%);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--mv-primary), var(--mv-primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ============================================
   Cards
   ============================================ */
.card {
    border: 1px solid var(--mv-gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-base);
    background: white;
    overflow: hidden;
}

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

.card-title {
    font-weight: 600;
    color: var(--mv-gray-900);
    font-size: 1rem;
}

.card-body {
    padding: 1.25rem;
}

.card-header {
    background: var(--mv-gray-50);
    border-bottom: 1px solid var(--mv-gray-200);
    font-weight: 600;
    padding: 0.875rem 1.25rem;
}

.hover-card {
    cursor: pointer;
    transition: all var(--transition-base);
}

.hover-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--mv-primary-subtle);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: all var(--transition-fast);
    letter-spacing: 0.01em;
}

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

.btn-primary:hover {
    background: var(--mv-primary-dark);
    border-color: var(--mv-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-outline-primary {
    color: var(--mv-primary);
    border-color: var(--mv-primary);
}

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

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

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

/* ============================================
   Forms
   ============================================ */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--mv-gray-300);
    padding: 0.6rem 0.85rem;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--mv-primary-light);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.form-label {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--mv-gray-700);
    margin-bottom: 0.375rem;
}

.input-group-text {
    background: var(--mv-gray-100);
    border-color: var(--mv-gray-300);
    color: var(--mv-gray-500);
    font-size: 0.875rem;
}

/* ============================================
   Badges & Pills
   ============================================ */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}

.badge.bg-primary {
    background: var(--mv-primary) !important;
}

.badge.bg-info {
    background: var(--mv-info) !important;
}

.badge.bg-success {
    background: var(--mv-success) !important;
}

/* ============================================
   Image Cards & Gallery
   ============================================ */
.image-card {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    background: white;
    position: relative;
    border: 1px solid var(--mv-gray-200);
    height: 100%;
}

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

.image-link {
    display: block;
    position: relative;
    overflow: hidden;
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent 50%);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.image-link:hover .image-overlay {
    opacity: 1;
}

.overlay-content {
    text-align: center;
    color: white;
}

.card-img-top {
    height: 180px;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.image-link:hover .card-img-top {
    transform: scale(1.05);
}

.image-card img {
    object-fit: cover;
    height: 180px;
    width: 100%;
}

/* ============================================
   Segmentation
   ============================================ */
.segmentation-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.color-box {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    margin-right: 0.375rem;
}

.segmentation-status-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
}

.correction-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(5, 150, 105, 0.92);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

/* ============================================
   File Upload
   ============================================ */
.file-drop-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2rem;
    border: 2px dashed var(--mv-gray-300);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    background: var(--mv-gray-50);
    text-align: center;
    margin-bottom: 1rem;
    cursor: pointer;
}

.file-drop-area:hover {
    border-color: var(--mv-primary-light);
    background: var(--mv-primary-bg);
}

.file-drop-area.highlight {
    border-color: var(--mv-primary);
    background: var(--mv-primary-bg);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.file-drop-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-msg {
    font-size: 0.9375rem;
    color: var(--mv-gray-500);
    font-weight: 500;
    display: block;
    width: 100%;
}

/* ============================================
   Pagination
   ============================================ */
.pagination .page-link {
    border-radius: var(--radius-sm);
    margin: 0 2px;
    border: 1px solid var(--mv-gray-200);
    color: var(--mv-gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    transition: all var(--transition-fast);
}

.pagination .page-link:hover {
    background: var(--mv-primary-bg);
    border-color: var(--mv-primary-light);
    color: var(--mv-primary);
}

.pagination .page-item.active .page-link {
    background: var(--mv-primary);
    border-color: var(--mv-primary);
}

.pagination .page-item.disabled .page-link {
    color: var(--mv-gray-400);
}

/* ============================================
   Footer
   ============================================ */
footer {
    background: white;
    color: var(--mv-gray-500);
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid var(--mv-gray-200);
    margin-top: auto;
    font-size: 0.8125rem;
}

/* ============================================
   Accordion
   ============================================ */
.accordion-button:not(.collapsed) {
    background: var(--mv-primary-bg);
    color: var(--mv-primary);
    box-shadow: none;
}

.accordion-item {
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--mv-gray-200);
}

/* ============================================
   Segmentation Editor
   ============================================ */
.cell-item {
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.cell-item:hover {
    background: rgba(15, 118, 110, 0.06);
}

.cell-item.selected {
    background: rgba(15, 118, 110, 0.1);
    border-left: 3px solid var(--mv-primary);
}

.edit-toolbar {
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 1rem;
    background: var(--mv-gray-50);
    border: 1px solid var(--mv-gray-200);
}

.edit-toolbar button {
    margin-right: 0.25rem;
    transition: all var(--transition-fast);
}

.edit-toolbar button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.bg-light-success {
    background-color: rgba(5, 150, 105, 0.08);
}

/* ============================================
   Auth Pages (Login / Register)
   ============================================ */
.auth-container {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--mv-gray-200);
}

.auth-card .card-body {
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .brand-icon-lg {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--mv-primary), var(--mv-primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.auth-header p {
    color: var(--mv-gray-500);
    font-size: 0.875rem;
}

/* ============================================
   Stats Cards
   ============================================ */
.stat-card {
    text-align: center;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    border: 1px solid var(--mv-gray-200);
    background: white;
}

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

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--mv-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--mv-gray-500);
    text-transform: capitalize;
    margin-top: 0.25rem;
}

.stat-card.clickable {
    cursor: pointer;
}

.stat-card.clickable:hover {
    border-color: var(--mv-primary-light);
    background: var(--mv-primary-bg);
}

/* ============================================
   Progress Bar
   ============================================ */
.progress {
    border-radius: var(--radius-full);
    height: 0.625rem;
    background: var(--mv-gray-200);
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--mv-primary), var(--mv-primary-light));
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

/* ============================================
   Breadcrumb
   ============================================ */
.breadcrumb {
    font-size: 0.8125rem;
    padding: 0;
    margin-bottom: 1.5rem;
    background: none;
}

.breadcrumb-item a {
    color: var(--mv-gray-500);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--mv-primary);
}

.breadcrumb-item.active {
    color: var(--mv-gray-800);
    font-weight: 500;
}

/* ============================================
   Image Viewer
   ============================================ */
.image-container {
    max-height: 70vh;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-md);
    background: var(--mv-gray-100);
}

#panzoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#panzoom-element {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: move;
}

#image-view {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.zoom-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-full);
    padding: 0.375rem 0.75rem;
    box-shadow: var(--shadow-md);
    display: flex;
    gap: 0.25rem;
}

.zoom-controls .btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
}

.metadata-label {
    font-weight: 600;
    color: var(--mv-gray-600);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
}

.image-counter {
    text-align: center;
    color: var(--mv-gray-500);
}

/* ============================================
   Cell Gallery
   ============================================ */
.cell-card {
    border: 1px solid var(--mv-gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 100%;
    transition: all var(--transition-base);
}

.cell-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.cell-card a {
    display: block;
    height: 100%;
}

.cell-img-container {
    position: absolute;
    inset: 0;
    background: var(--mv-gray-100);
}

.crop-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: white;
    padding: 8px;
    box-sizing: border-box;
}

.confidence-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    background: var(--mv-primary) !important;
}

.cell-type-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
    padding: 1.5rem 0.5rem 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 5;
}

.thumbnail-small .cell-card .position-relative {
    height: 120px;
    width: 120px;
    margin: 0 auto;
}

.thumbnail-medium .cell-card .position-relative {
    height: 180px;
    width: 180px;
    margin: 0 auto;
}

.thumbnail-large .cell-card .position-relative {
    height: 250px;
    width: 250px;
    margin: 0 auto;
}

.cell-zoom-effect {
    transition: transform var(--transition-base);
}

.cell-card:hover .cell-zoom-effect {
    transform: scale(1.08);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
    border-radius: var(--radius-md);
    border: none;
    font-size: 0.875rem;
}

/* ============================================
   Modal
   ============================================ */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--mv-gray-200);
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--mv-gray-200);
    padding: 1rem 1.5rem;
}

/* ============================================
   Tables
   ============================================ */
.table {
    font-size: 0.875rem;
}

.table th {
    font-weight: 600;
    color: var(--mv-gray-700);
    border-bottom-width: 1px;
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--mv-gray-500);
}

.empty-state i {
    font-size: 3rem;
    color: var(--mv-gray-300);
    margin-bottom: 1rem;
}

.empty-state h5 {
    color: var(--mv-gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================
   Toasts
   ============================================ */
.toast {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }

    .image-card img {
        height: 140px;
    }

    .auth-card .card-body {
        padding: 1.5rem;
    }

    .metadata-section {
        margin-top: 1.5rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* ============================================
   Utility
   ============================================ */
.hover-shadow:hover {
    box-shadow: var(--shadow-lg) !important;
}

.text-primary {
    color: var(--mv-primary) !important;
}

.bg-primary {
    background-color: var(--mv-primary) !important;
}

.border-primary {
    border-color: var(--mv-primary) !important;
}

/* Drop zone (legacy compat) */
.drop-zone {
    border: 2px dashed var(--mv-primary-light);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    color: var(--mv-primary);
    margin-bottom: 1.25rem;
    transition: all var(--transition-base);
}

.drop-zone.dragover {
    background: var(--mv-primary-bg);
}
