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

:root {
    /* Colors */
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.65);
    --bg-panel-hover: rgba(30, 41, 59, 0.85);
    --border-glass: rgba(255, 255, 255, 0.1);
    --border-glass-strong: rgba(255, 255, 255, 0.2);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    
    /* Effects */
    --glass-blur: blur(12px);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    font-family: 'Source Sans 3', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    /* background image/gradient overlay */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: #60a5fa;
}

/* Base Layout Container */
.app-container {
    display: flex;
    min-height: 100vh;
    overflow-x: clip; /* use clip not hidden — does not create stacking context */
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
    /* Do NOT add overflow here — it would clip the navbar dropdown */
}

/* Header */
.top-header {
    height: var(--header-height);
    background: linear-gradient(90deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(56, 189, 248, 0.15);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 1rem;
    overflow: visible;
}

/* Left: page title — fixed width, no shrink */
.header-title {
    flex-shrink: 0;
    min-width: 0;
}

.header-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Right: avatar + logout — fixed, no shrink */
.header-user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.user-greeting {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Professional role indicator — no pill, no border */
.nav-role-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0.75;
    white-space: nowrap;
    padding: 0;
    border: none;
    background: none;
}

.btn-logout {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.4);
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    line-height: 1;
}

.btn-logout:hover {
    background: #ef4444;
    border-color: #ef4444;
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.45);
    color: #ffffff;
    transform: translateY(-1px);
}

/* Content Area */
.content-wrapper {
    padding: 2rem;
    flex: 1;
}

/* Messages / Alerts */
.messages-container {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInDown 0.3s ease forwards;
}

.alert-success { border-left: 4px solid var(--success); }
.alert-error, .alert-danger { border-left: 4px solid var(--danger); }
.alert-warning { border-left: 4px solid var(--warning); }
.alert-info { border-left: 4px solid var(--info); }

@keyframes slideInDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Typography Helpers */
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* ── Navbar: search bar ─────────────────────────────────────────────────── */
.header-search-form {
    flex: 1 1 0;
    min-width: 0;
    max-width: 380px;
}

.header-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

/* SVG icon inside search bar — forced small */
.header-search-wrap .search-icon {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    width: 15px !important;
    height: 15px !important;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
    z-index: 1;
}

.header-search-input {
    width: 100%;
    height: 36px;
    padding: 0 0.75rem 0 2.2rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-sizing: border-box;
}

.header-search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.header-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    background: rgba(15, 23, 42, 0.75);
}

/* ── Navbar: profile avatar + dropdown ──────────────────────────────────── */
.profile-dropdown-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    max-width: 34px;
    max-height: 34px;
    border-radius: 50%;
    border: 2px solid var(--border-glass-strong);
    background: var(--primary-gradient);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    letter-spacing: 0.5px;
    line-height: 1;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar-btn:hover,
.profile-avatar-btn.open {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.75), 0 0 14px rgba(59, 130, 246, 0.5);
    border-color: #60a5fa;
    transform: scale(1.12);
    color: #ffffff;
}

.profile-avatar-btn:hover .avatar-initials,
.profile-avatar-btn.open .avatar-initials {
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    opacity: 1;
}

.avatar-initials {
    pointer-events: none;
    display: block;
    line-height: 1;
    font-size: 0.72rem;
    font-weight: 700;
}

/* Dropdown panel */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-glass-strong);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.45);
    padding: 0.75rem 0;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.profile-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.profile-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.profile-avatar-lg {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.profile-info .profile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.profile-info .profile-username {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border-glass);
    margin: 0.25rem 0;
}

.profile-welcome-line {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: background var(--transition-fast);
    text-decoration: none;
}

.profile-dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.profile-dropdown-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.profile-dropdown-item:hover svg {
    color: var(--primary-color);
}

/* ── Role badges ────────────────────────────────────────────────────────── */
.badge-doctor  { background: rgba(16,185,129,0.15); color:#34d399; border:1px solid rgba(16,185,129,0.3); }
.badge-lab     { background: rgba(14,165,233,0.15); color:#38bdf8; border:1px solid rgba(14,165,233,0.3); }
.badge-admin   { background: rgba(245,158,11,0.15); color:#fbbf24; border:1px solid rgba(245,158,11,0.3); }
.badge-viewer  { background: rgba(148,163,184,0.15);color:#cbd5e1; border:1px solid rgba(148,163,184,0.3); }
.badge-default { background: rgba(148,163,184,0.15);color:#cbd5e1; border:1px solid rgba(148,163,184,0.3); }

/* ── Search results page ────────────────────────────────────────────────── */
.search-results-page .search-section {
    margin-bottom: 1.5rem;
}

.search-results-header {
    margin-bottom: 1.5rem;
}

/* ── Profile page ───────────────────────────────────────────────────────── */
.profile-page-avatar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.profile-page-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
}

.profile-page-name {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Activity list */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-glass);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-action-badge {
    background: rgba(59,130,246,0.12);
    color: #60a5fa;
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 2px;
}

.activity-details {
    flex: 1;
}

.activity-desc {
    font-size: 0.88rem;
    color: var(--text-main);
}

.activity-time {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

