/* ============================================
   DENTAL OPD — Layout (Sidebar + Topbar + Content)
   ============================================ */

/* ── App Shell ── */
.app {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Sidebar Toggle (Floating Futuristic) ── */
.sidebar-toggle-btn {
    position: fixed;
    left: 248px;
    /* 260px - 12px */
    top: 28px;
    width: 28px;
    height: 28px;
    background: var(--surface);
    border: 1px solid var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    color: var(--primary);
    box-shadow: 0 0 15px rgba(15, 118, 110, 0.2);
    transition: left 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--primary-bg);
    box-shadow: 0 0 20px rgba(15, 118, 110, 0.4);
    transform: scale(1.1);
}

/* ── Collapsed State ── */
body.sidebar-collapsed .sidebar {
    width: 80px;
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 80px;
}

body.sidebar-collapsed .sidebar-toggle-btn {
    left: 66px;
    /* 80px - 14px */
    transform: rotate(180deg);
}

/* Hide elements in collapsed state */
body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-item-text,
body.sidebar-collapsed .sidebar-item-badge,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-logout-btn {
    display: none !important;
}

body.sidebar-collapsed .sidebar-header {
    padding: var(--sp-4) var(--sp-2);
}

body.sidebar-collapsed .sidebar-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 0;
    box-shadow: 0 0 10px rgba(15, 118, 110, 0.2);
}

body.sidebar-collapsed .sidebar-item {
    justify-content: center;
    padding: var(--sp-3) 0;
    margin: 4px 10px;
    border-radius: 12px;
}

body.sidebar-collapsed .sidebar-item-icon {
    margin: 0;
    font-size: 1.25rem;
}

body.sidebar-collapsed .sidebar-item.active {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}

body.sidebar-collapsed .sidebar-item.active::before {
    display: none;
    /* Remove the scaling border */
}

body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: var(--sp-2) 0;
}

body.sidebar-collapsed .sidebar-footer {
    flex-direction: column;
    padding: var(--sp-2);
}

/* Tooltips for collapsed state */
body.sidebar-collapsed .sidebar-item {
    position: relative;
}

body.sidebar-collapsed .sidebar-item:hover::after {
    content: attr(data-tooltip);
    /* Requires data-tooltip attribute via JS */
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--text);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 200;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    pointer-events: none;
}

.sidebar-header {
    padding: var(--sp-6) var(--sp-4) var(--sp-5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    border-bottom: none;
    min-height: auto;
    position: relative;
    background: linear-gradient(180deg, rgba(15, 118, 110, 0.04) 0%, transparent 100%);
}

/* Gradient accent line under header */
.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: var(--sp-4);
    right: var(--sp-4);
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-light), var(--primary), var(--primary-light), transparent);
    border-radius: 2px;
    opacity: 0.5;
}

.sidebar-logo {
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: var(--sp-2);
    background: white;
    border-radius: 50%;
    padding: 6px;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(15, 118, 110, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.sidebar-logo:hover {
    transform: scale(1.05);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.12),
        0 0 0 2px rgba(15, 118, 110, 0.15);
}

.sidebar-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
    width: 100%;
}

.sidebar-brand-name {
    font-family: var(--font-display);
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    color: var(--primary-dark);
    line-height: 1.2;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.sidebar-brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: var(--fw-medium);
    letter-spacing: 0.02em;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: var(--sp-3) var(--sp-3);
}

.sidebar-section-label {
    font-size: 0.6875rem;
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
    user-select: none;
}

.sidebar-item:hover {
    background: var(--bg);
    color: var(--text);
}

.sidebar-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: var(--fw-semibold);
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.sidebar-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--fs-md);
}

.sidebar-item-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.625rem;
    font-weight: var(--fw-bold);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
    padding: var(--sp-3);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.sidebar-logout-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-logout-btn:hover,
.sidebar-logout-btn:focus {
    background: var(--danger-bg);
    color: var(--danger);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition-fast);
    flex: 1;
    min-width: 0;
    /* Enable truncation */
}

.sidebar-user:hover {
    background: var(--bg);
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* ── Main Content Area ── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-6);
    gap: var(--sp-4);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--text);
}

.topbar-breadcrumb {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-left: var(--sp-2);
}

.topbar-spacer {
    flex: 1;
}

.topbar-search {
    position: relative;
    width: 280px;
}

.topbar-search input {
    width: 100%;
    padding: var(--sp-2) var(--sp-4);
    padding-left: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: var(--fs-sm);
    background: var(--bg);
    color: var(--text);
    transition: all var(--transition-fast);
    font-family: var(--font-primary);
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--primary-light);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    pointer-events: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.topbar-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    position: relative;
    font-size: var(--fs-md);
}

.topbar-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.topbar-btn .notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--surface);
}

/* Role Switcher */
.role-switcher {
    position: relative;
}

.role-switcher-btn {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-primary);
}

.role-switcher-btn:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.role-switcher-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 200;
    display: none;
    overflow: hidden;
}

.role-switcher-dropdown.open {
    display: block;
    animation: fadeSlideDown 0.15s ease;
}

.role-option {
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.role-option:hover {
    background: var(--bg);
}

.role-option.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: var(--fw-semibold);
}

/* ── Content ── */
.content {
    flex: 1;
    padding: var(--sp-6);
    max-width: var(--content-max-width);
}

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.page-header h1 {
    font-size: var(--fs-2xl);
}

.page-header-actions {
    display: flex;
    gap: var(--sp-3);
}

/* ── Login Layout ── */
.login-layout {
    display: flex;
    min-height: 100vh;
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-12);
    color: white;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    top: -100px;
    right: -100px;
}

.login-left::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    bottom: -50px;
    left: -50px;
}

.login-branding {
    text-align: center;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Logo Wrapper — Glassmorphism Circle ── */
.login-logo-wrapper {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.25),
        0 0 80px rgba(255, 255, 255, 0.1);
    position: relative;
    animation: logoFloat 4s ease-in-out infinite;
}

.login-logo-wrapper::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    animation: logoPulse 3s ease-in-out infinite;
}

.login-logo-wrapper::after {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: logoPulse 3s ease-in-out infinite 0.5s;
}

.login-logo-img {
    width: 240px;
    height: 240px;
    object-fit: contain;
    border-radius: 50%;
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes logoPulse {

    0%,
    100% {
        opacity: 0.4;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.03);
    }
}

.login-branding h1 {
    color: white;
    font-size: 1.75rem;
    font-weight: var(--fw-bold);
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.login-tagline {
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 1rem !important;
    font-weight: var(--fw-semibold);
    letter-spacing: 0.04em;
    margin-bottom: var(--sp-3) !important;
    text-transform: uppercase;
    font-size: 0.75rem !important;
}

.login-branding p {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--fs-base);
    max-width: 400px;
    line-height: 1.6;
}

/* ── Feature Pills ── */
.login-features {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.login-feature-item {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.3s ease;
}

.login-feature-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.login-feature-icon {
    color: #5EEAD4;
    font-weight: bold;
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8);
    background: var(--bg);
}

.login-form-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-form-wrapper h2 {
    margin-bottom: var(--sp-2);
}

.login-form-wrapper .login-subtitle {
    color: var(--text-muted);
    margin-bottom: var(--sp-8);
}

/* ── Animations ── */
@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideInRight 0.3s ease;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .sidebar .sidebar-brand,
    .sidebar .sidebar-item span,
    .sidebar .sidebar-section-label,
    .sidebar .sidebar-user-info,
    .sidebar .sidebar-item-badge {
        display: none;
    }

    .sidebar-item {
        justify-content: center;
        padding: var(--sp-3);
    }

    .sidebar-header {
        justify-content: center;
        padding: var(--sp-3);
    }

    .sidebar-logo {
        width: 40px;
        height: 40px;
        margin-bottom: 0;
    }

    .sidebar-user {
        justify-content: center;
        padding: 0;
    }

    .sidebar-footer {
        flex-direction: column;
        gap: var(--sp-2);
        padding: var(--sp-2);
    }

    .sidebar-logout-btn {
        width: 34px;
        height: 34px;
    }

    .main-wrapper {
        margin-left: var(--sidebar-collapsed);
    }

    .topbar-search {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .content {
        padding: var(--sp-4);
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }

    .login-left {
        display: none;
    }
}