/**
 * Bchecklist - Application Shell Layout
 */

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

/* Master Shell Container */
.app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background-color: var(--color-bg);
}

/* ==========================================================================
   LEFT PANEL (Sidebar)
   ========================================================================== */
.left-panel {
    width: var(--panel-left-width);
    min-width: var(--panel-left-width);
    background-color: var(--panel-left-bg);
    color: var(--panel-left-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    border-right: 1px solid var(--panel-left-border);
    transition: width var(--transition-normal), transform var(--transition-normal);
    z-index: 1000;
    user-select: none;
    position: relative;
}

/* Top-Left Brand / Logo Header - Two Rows Layout */
.left-panel-header {
    min-height: 124px;
    padding: var(--space-4) var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background-color: rgba(0, 0, 0, 0.18);
}

.brand-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #ffffff;
    width: 100%;
}

/* Row 1: Logo across full width of the sidepanel */
.brand-logo-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.brand-logo-img {
    height: 56px;
    max-width: 216px;
    width: auto;
    object-fit: contain;
    border-radius: var(--radius-md);
    background: #ffffff; /* Crisp white backing for maximum contrast */
    padding: 6px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    display: block;
}

/* Row 2: Organization Name & Account Details */
.brand-details-row {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
    line-height: 1.25;
    word-break: break-word;
    max-width: 100%;
}

.brand-account-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.account-badge {
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(0, 139, 139, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.02em;
}

.account-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

.brand-layer-badge {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    background-color: var(--color-primary);
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
}

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--panel-left-text);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Sidebar Navigation Area */
.left-panel-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) 0;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    padding: var(--space-3) var(--space-4) var(--space-1) var(--space-4);
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 2px var(--space-2);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-3);
    color: var(--panel-left-text);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background-color: var(--panel-left-bg-hover);
    color: #ffffff;
}

.nav-link.active {
    background-color: var(--panel-left-active-bg);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2;
}

.nav-label {
    flex: 1;
    display: inline-block !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    font-weight: 500;
}

.nav-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
}

/* User Profile Block at Bottom of Left Panel */
.left-panel-user {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info-block {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    overflow: hidden;
}

.user-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-icon-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.logout-icon-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   RIGHT PANEL
   ========================================================================== */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: var(--color-bg);
}

/* Right Panel Top Header */
.right-panel-header {
    height: 64px;
    min-height: 64px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    padding: var(--space-2);
}

.page-title-group {
    display: flex;
    flex-direction: column;
}

.page-title {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.page-breadcrumb {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.page-breadcrumb a {
    color: var(--color-primary-dark);
    text-decoration: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* Global Search in Header */
.header-search {
    position: relative;
    width: 240px;
}

.header-search input {
    width: 100%;
    padding: 7px 12px 7px 34px;
    font-size: var(--font-size-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-text);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header-search input:focus {
    border-color: var(--color-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px var(--color-primary-focus);
}

.header-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}

/* Header Alerts / Notifications Icon */
.header-icon-action {
    position: relative;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-icon-action:hover {
    background-color: var(--color-surface);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-danger);
    border: 2px solid #ffffff;
}

/* User Dropdown in Header */
.header-user-menu {
    position: relative;
}

.header-user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: transparent;
    border: 1px solid var(--color-border);
    padding: 4px 10px 4px 6px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-user-btn:hover {
    border-color: var(--color-primary);
    background-color: var(--color-surface);
}

/* Right Panel Scrollable Main Content */
.right-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    background-color: var(--color-surface);
    display: flex;
    flex-direction: column;
}

.content-inner {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* Right Panel Sticky / Static Footer */
.right-panel-footer {
    padding: var(--space-3) var(--space-6);
    background-color: #ffffff;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-muted);
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.footer-logo-img {
    height: 18px;
    width: auto;
    opacity: 0.8;
}

/* ==========================================================================
   RESPONSIVENESS
   ========================================================================== */
@media (max-width: 992px) {
    .header-search {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .left-panel {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    }

    .left-panel.drawer-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .right-panel-header {
        padding: 0 var(--space-4);
    }

    .right-panel-content {
        padding: var(--space-4);
    }
}
