/* Sidebar Navigation Styles */
.sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: #fafaf8;
    border-right: 1px solid #e8e5e0;
    display: flex;
    flex-direction: column;
    z-index: 1030;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
}

/* Brand Section */
.sidebar-brand {
    padding: 16px 16px 14px;
    border-bottom: 1px solid #e8e5e0;
    flex-shrink: 0;
}

.sidebar-brand .brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-dark);
}

.sidebar-brand .brand-link i {
    font-size: 22px;
    color: var(--primary-color);
    flex-shrink: 0;
}

/* Org-uploaded logo in the sidebar brand. Height-constrained, width scales. */
.sidebar-brand .brand-logo {
    max-height: 32px;
    width: auto;
    flex-shrink: 0;
}

/* Platform (Sahab Key) key mark in the sidebar brand, paired with the wordmark. */
.sidebar-brand .brand-mark {
    height: 28px;
    width: auto;
    flex-shrink: 0;
}

.sidebar-brand .brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand .brand-name {
    font-size: 15px;
    font-weight: var(--font-weight-bold);
    color: var(--primary-color);
    line-height: 1.2;
}

.sidebar-brand .brand-tagline {
    font-size: 11px;
    color: #6b7280;
    font-weight: var(--font-weight-normal);
}

/* Building Scope Indicator */
.building-scope-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    font-size: 12px;
    font-weight: 500;
    color: #1e40af;
    flex-shrink: 0;
}

.building-scope-indicator i {
    font-size: 11px;
    color: #3b82f6;
    flex-shrink: 0;
}

.building-scope-indicator span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation Menu */
.sidebar-menu {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 1px 8px;
    color: #4b5563;
    text-decoration: none;
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    border-radius: 6px;
    border-left: none;
    transition: all var(--transition-fast);
}

.sidebar-nav-item i {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    color: #6b7280;
    transition: color var(--transition-fast);
}

.sidebar-nav-item:hover {
    background: rgba(208, 167, 100, 0.06);
    color: var(--primary-color);
}

.sidebar-nav-item:hover i {
    color: var(--primary-color);
}

.sidebar-nav-item.active {
    background: rgba(208, 167, 100, 0.1);
    color: var(--primary-color);
    font-weight: var(--font-weight-semibold);
}

.sidebar-nav-item.active i {
    color: var(--primary-color);
}

.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

/* User Section (bottom) */
.sidebar-user {
    border-top: 1px solid #e8e5e0;
    padding: 12px 16px;
    flex-shrink: 0;
    margin-top: auto;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.sidebar-user .user-avatar i {
    font-size: 24px;
    color: #6b7280;
}

.sidebar-user .user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.sidebar-user .user-role {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.3;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    color: #6b7280;
    text-decoration: none;
    font-size: 13px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.sidebar-logout:hover {
    background: #fee2e2;
    color: #ef4444;
}

.sidebar-powered-by {
    font-size: 9px;
    color: #6b7280;
    text-align: center;
    padding-top: 8px;
    margin-top: 6px;
    border-top: 1px solid #e8e5e0;
    letter-spacing: 0.3px;
    transition: color 0.2s;
}

.sidebar-powered-by a {
    color: #6b7280;
    text-decoration: none;
    font-weight: var(--font-weight-medium);
}

.sidebar-powered-by a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* Mobile Toggle Button */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1040;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 18px;
    color: var(--text-dark);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-fast);
    min-width: 44px;
    min-height: 44px;
}

.sidebar-toggle:hover {
    background: #f9fafb;
    border-color: var(--primary-color);
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1025;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* Footer Styles. The footer sits on a dark #1f2937 background, so its text
   uses LIGHT colors (the brand tint for accents, #d1d5db for body) to meet
   WCAG AA contrast — the opposite of the light-background app surfaces. */
.app-footer {
    background: #1f2937;
    color: #d1d5db;
    padding: var(--spacing-xl) 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.footer-main {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.footer-brand h3 {
    color: var(--brand-tint);
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-sm);
}

/* Brand logo in the dark footer (Sahab Key light variant, or an org logo). */
.footer-brand .footer-logo {
    display: block;
    height: 34px;
    width: auto;
    max-width: 100%;
    margin-bottom: var(--spacing-sm);
}

.footer-brand p {
    color: #d1d5db;
    font-size: var(--font-size-sm);
    line-height: 1.6;
}

.footer-section h4 {
    color: #f3f4f6;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--spacing-md);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.footer-links a {
    color: #d1d5db;
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--brand-tint);
}

.footer-contact p {
    color: #d1d5db;
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-xs);
}

.footer-contact i {
    width: 20px;
    color: var(--brand-tint);
    margin-right: var(--spacing-xs);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid #374151;
    font-size: var(--font-size-sm);
}

.footer-bottom a {
    color: var(--brand-tint);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
}

.footer-bottom a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 992px) {
    .sidebar-nav {
        transform: translateX(-100%);
    }

    .sidebar-nav.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

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

    .footer-main {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .footer-bottom {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }
}

/* Page adjustments */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
}

.app-footer {
    margin-left: 240px;
}

@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
    }

    .app-footer {
        margin-left: 0;
    }
}

/* Ensure content doesn't go under navbar */
.manager-container,
.tenant-container,
.td,
.boarding-container {
    padding-top: var(--spacing-sm);
}

/* Mobile: larger touch targets for sidebar nav items */
@media (max-width: 992px) {
    .sidebar-nav-item {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }

    .sidebar-nav-item i {
        font-size: 16px;
    }

    .sidebar-logout {
        padding: 10px 8px;
        min-height: 44px;
    }

    /* Ensure content clears the hamburger button */
    .td,
    .manager-container,
    .tenant-container {
        padding-top: 56px;
    }
}

@media (max-width: 768px) {
    .footer-main {
        gap: var(--spacing-md);
    }

    .footer-content {
        padding: 0 var(--spacing-md);
    }

    .app-footer {
        padding: var(--spacing-lg) 0;
    }
}
