/* ============================================================
   NDPI Slide Manager – Design System
   Premium dark theme for medical imaging
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
    --bg-primary: #06080d;
    --bg-secondary: #0d1117;
    --bg-surface: #161b22;
    --bg-surface-hover: #1c2333;
    --bg-card: rgba(22, 27, 34, 0.85);
    --bg-glass: rgba(22, 27, 34, 0.6);

    --accent-cyan: #22d3ee;
    --accent-teal: #2dd4bf;
    --accent-violet: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #22d3ee, #a78bfa);
    --accent-gradient-hover: linear-gradient(135deg, #67e8f9, #c4b5fd);

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    --border-color: rgba(139, 148, 158, 0.12);
    --border-glow: rgba(34, 211, 238, 0.25);

    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(34,211,238,0.15);

    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-cyan); text-decoration: none; }
a:hover { color: var(--accent-teal); }

img { max-width: 100%; display: block; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

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

/* ---------- Header ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-brand .logo {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--bg-primary);
}

.header-brand h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-brand h1 span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--bg-primary);
}
.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--accent-cyan);
}

.btn-danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.25);
}
.btn-danger:hover {
    background: rgba(248, 81, 73, 0.25);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}
.btn-icon:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    background: rgba(34,211,238,0.08);
}

.btn-lang {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: rgba(34,211,238,0.08);
    border: 1px solid var(--border-color);
    color: var(--accent-cyan);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}
.btn-lang:hover {
    background: rgba(34,211,238,0.15);
    border-color: var(--accent-cyan);
    box-shadow: var(--shadow-glow);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* ---------- Stats Row ---------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-base);
}
.stat-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.slides { background: rgba(34,211,238,0.12); color: var(--accent-cyan); }
.stat-icon.size { background: rgba(167,139,250,0.12); color: var(--accent-violet); }
.stat-icon.annotations { background: rgba(45,212,191,0.12); color: var(--accent-teal); }

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 260px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}
.search-box input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(34,211,238,0.1);
}
.search-box input::placeholder { color: var(--text-muted); }

.search-box .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

/* ---------- Upload Zone ---------- */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: all var(--transition-base);
    cursor: pointer;
    display: none;
}
.upload-zone.visible { display: block; }
.upload-zone.drag-over {
    border-color: var(--accent-cyan);
    background: rgba(34,211,238,0.04);
    box-shadow: var(--shadow-glow);
}
.upload-zone .upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}
.upload-zone p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.upload-zone .upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Upload Progress ---------- */
.upload-progress {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}
.upload-progress.active { display: block; }

.progress-bar-container {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.75rem;
}
.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    width: 0%;
    transition: width var(--transition-fast);
}

/* ---------- Slide Grid ---------- */
.slides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.slide-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
}
.slide-card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
    transform: translateY(-3px);
}

.slide-card .card-thumbnail {
    width: 100%;
    height: 200px;
    background: var(--bg-primary);
    overflow: hidden;
    position: relative;
}
.slide-card .card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}
.slide-card:hover .card-thumbnail img {
    transform: scale(1.05);
}

.card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    color: var(--accent-cyan);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem 1.25rem;
}

.card-body h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}
.card-meta span {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.card-actions .btn {
    font-size: 0.8rem;
    padding: 6px 14px;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
    animation: fadeIn var(--transition-base) ease;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 480px;
    width: 90%;
    animation: slideUp var(--transition-base) ease;
}

.modal h2 {
    margin-bottom: 1rem;
    font-size: 1.15rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.25rem;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    animation: slideInRight var(--transition-base) ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent-cyan); }

/* ============================================================
   Viewer Page
   ============================================================ */
.viewer-layout {
    display: flex;
    height: calc(100vh - 64px);
    overflow: hidden;
}

.viewer-main {
    flex: 1;
    position: relative;
    background: #000;
}

#osd-viewer {
    width: 100%;
    height: 100%;
}

/* Viewer toolbar */
.viewer-toolbar {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
}

.viewer-toolbar .btn-icon {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
}
.viewer-toolbar .btn-icon:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}
.viewer-toolbar .btn-icon.active {
    background: rgba(34,211,238,0.15);
    color: var(--accent-cyan);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Viewer sidebar */
.viewer-sidebar {
    width: 340px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--transition-base);
}
.viewer-sidebar.collapsed {
    width: 0;
    border: none;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    transition: all var(--transition-fast);
    border-bottom: 2px solid transparent;
}
.sidebar-tab:hover { color: var(--text-secondary); }
.sidebar-tab.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
}

.sidebar-panel { display: none; }
.sidebar-panel.active { display: block; }

/* Property list */
.prop-list {
    list-style: none;
}
.prop-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.82rem;
}
.prop-list li:last-child { border-bottom: none; }
.prop-label { color: var(--text-secondary); }
.prop-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
    max-width: 55%;
    word-break: break-all;
}

/* Notes textarea */
.notes-area {
    width: 100%;
    min-height: 120px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.75rem;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}
.notes-area:focus {
    border-color: var(--accent-cyan);
}

/* Navigator minimap */
.navigator-container {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}

/* Annotation list */
.annotation-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
}
.annotation-item .ann-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-header { padding: 0 1rem; }
    .main-content { padding: 1rem; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .slides-grid { grid-template-columns: 1fr; }
    .viewer-sidebar { width: 100%; position: absolute; right: 0; z-index: 20; height: 100%; }
    .viewer-sidebar.collapsed { width: 0; }
    .toolbar { flex-direction: column; align-items: stretch; }
}
