/* Root Variables */
:root {
    --sidebar-max-width-left: 320px;
    --sidebar-min-width-left: 260px;
    --sidebar-max-width-right: 280px;
    --sidebar-min-width-right: 200px;
    --avatar-size: 48px;
    --primary-color: #870735;
    --selected-bg: rgba(135, 7, 53, 0.1);
    --hover-bg: rgba(0, 0, 0, 0.05);
    --border-color: #dee2e6;
    --text-muted: #6c757d;
}

/* Global Styles */
:root {
    --vh: 1vh; /* Will be set dynamically by JavaScript */
}

html, body {
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

.container-fluid {
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100);
    padding: 0;
}

.row {
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100);
    margin: 0;
}

/* Sidebar Base Styles */
.left-sidebar {
    max-width: var(--sidebar-max-width-left);
    min-width: var(--sidebar-min-width-left);
    background-color: #f8f9fa;
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden; /* Changed from overflow-y: auto to prevent whole sidebar scrolling */
    padding: 0;
    display: flex;
    flex-direction: column;
}

.right-sidebar {
    max-width: var(--sidebar-max-width-right);
    min-width: var(--sidebar-min-width-right);
    background-color: #ffffff;
    border-left: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

.center-column {
    flex: 1;
    min-width: 0;
    background-color: #ffffff;
    position: relative;
    height: 100vh; /* Fallback */
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    padding: 0;
}

/* iOS-specific scrolling fix for iframes */
.center-column iframe,
.right-sidebar iframe {
    -webkit-overflow-scrolling: touch;
}

/* Logo Section */
.logo-section {
    border-bottom: 1px solid var(--border-color);
    background-color: #ffffff;
    flex-shrink: 0; /* Prevent shrinking */
}

.logo-img {
    max-width: 120px;
    max-height: 60px;
    width: auto;
    height: auto;
}

/* Info Section with Fade Effect */
.info-section {
    border-bottom: 1px solid var(--border-color);
    position: relative;
    flex-shrink: 0; /* Prevent shrinking */
}

.info-content {
    max-height: 90px;
    overflow: hidden;
    position: relative;
    transition: max-height 0.3s ease;
}

.info-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, #f8f9fa);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.info-content.expanded {
    max-height: none;
}

.info-content.expanded::after {
    opacity: 0;
}

.read-all-btn {
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.2s ease;
}

.read-all-btn:hover,
.read-all-btn:focus {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Inactive state for the read-all button */
.read-all-btn.inactive {
    color: var(--text-muted) !important;
    opacity: 0.7 !important;
    cursor: default !important;
    pointer-events: none !important;
    text-decoration: none !important;
}

/* People List Styles */
.people-section {
    border-bottom: 1px solid var(--border-color);
    overflow-y: auto; /* Enable vertical scrolling */
    flex: 1; /* Take up all available space */
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for proper scrolling in flex containers */
}

.people-list {
    outline: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Critical for proper scrolling in flex containers */
}

.people-list:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

.person-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    background-color: transparent;
    width: 100%;
    text-align: left;
}

.person-item:hover {
    background-color: var(--hover-bg);
}

.person-item:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--hover-bg);
}

.person-item.selected {
    background-color: var(--selected-bg);
    border-color: var(--primary-color);
}

.person-item.selected:hover {
    background-color: var(--selected-bg);
}

/* Avatar Styles */
.person-avatar {
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.person-avatar.initials {
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.person-info {
    flex: 1;
    min-width: 0;
}

.person-name {
    font-weight: 600;
    margin: 0 0 2px 0;
    font-size: 0.95rem;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-summary {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.person-chevron {
    color: var(--text-muted);
    margin-left: 8px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.person-item.selected .person-chevron {
    transform: translateX(4px);
    color: var(--primary-color);
}

/* Contact Section */
.contact-section {
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent shrinking */
}

.contact-links a,
.contact-links button {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.contact-links a:hover,
.contact-links button:hover {
    color: var(--primary-color);
    text-decoration: none;
}

/* Footer Section */
.footer-section {
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    min-height: 30px;
    flex-shrink: 0; /* Prevent shrinking */
}

.info-btn {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    opacity: 0.4;
    border-width: 1px;
    border-color: #dee2e6;
    margin-top: -2px;
}

.info-btn:hover,
.info-btn:focus {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1);
    opacity: 1;
}

/* Overlay Menu */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.overlay.show {
    display: flex;
    opacity: 1;
}

.overlay-content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

/* Details modal specific styles */
.details-content {
    width: calc(100% - 40px); /* Full width minus 20px margin on each side */
    height: calc(100% - 40px); /* Full height minus 20px margin on each side */
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
}

.details-iframe-container {
    flex: 1;
    overflow: hidden;
    min-height: 0;
    height: 100%;
    margin-top: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover,
.close-btn:focus {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000;
}

.overlay.show .overlay-content {
    transform: scale(1);
}

.overlay-content button[role="menuitem"] {
    border: none;
    background: none;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.overlay-content button[role="menuitem"]:hover,
.overlay-content button[role="menuitem"]:focus {
    background-color: var(--hover-bg);
    color: var(--primary-color);
    outline: none;
}

/* Iframe Styles */
iframe {
    border: none;
    width: 100%;
    height: 100%;
}

/* Responsive Design */
@media (max-width: 767.98px) {
    html, body {
        height: auto;
        overflow: auto;
    }
    
    .container-fluid {
        height: auto;
    }
    
    .row {
        height: auto;
        flex-direction: column;
    }
    
    .left-sidebar,
    .right-sidebar {
        position: static;
        max-width: none;
        min-width: auto;
        height: auto;
        overflow: visible;
    }
    
    .center-column {
        height: 60vh;
        min-height: 400px;
    }
    
    .right-sidebar {
        height: 40vh;
        min-height: 300px;
    }
    
    .left-sidebar {
        order: 1;
    }
    
    .center-column {
        order: 2;
    }
    
    .right-sidebar {
        order: 3;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --hover-bg: rgba(0, 0, 0, 0.1);
        --selected-bg: rgba(13, 110, 253, 0.2);
    }
    
    .person-item {
        border: 1px solid var(--border-color);
    }
}

/* Loading States */
.loading {
    opacity: 0.6;
    /* Remove pointer-events: none to allow touch scrolling during load */
    /* pointer-events: none; */
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Two-Page Navigation */
@media (max-width: 767.98px) {
    /* Base layout for mobile */
    .left-sidebar,
    .center-column,
    .right-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh; /* Fallback */
        height: calc(var(--vh, 1vh) * 100);
        max-width: 100%;
        transition: transform 0.3s ease;
    }

    /* Initial state: left sidebar visible, center and right hidden */
    .left-sidebar {
        transform: translateX(0);
        z-index: 10;
    }

    .center-column {
        transform: translateX(100%);
        z-index: 20;
    }

    .right-sidebar {
        transform: translateX(100%);
        z-index: 30;
    }

    /* Active states for navigation */
    .mobile-center-active .left-sidebar {
        transform: translateX(-100%);
    }

    .mobile-center-active .center-column {
        transform: translateX(0);
    }

    /* Mobile top bar */
    .mobile-top-bar {
        position: sticky;
        top: 0;
        left: 0;
        width: 100%;
        padding: 10px 15px;
        background-color: #ffffff;
        border-bottom: 1px solid var(--border-color);
        z-index: 25;
        display: flex;
        align-items: center;
        height: 50px;
    }

    .back-button {
        display: flex;
        align-items: center;
        color: white;
        background: none;
        border: none;
        padding: 5px 10px;
        font-weight: 500;
    }

    .back-button i {
        margin-right: 5px;
    }
    
    .back-button:hover,
    .back-button:focus {
        color: rgba(255, 255, 255, 0.9);
        text-decoration: none;
        background-color: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
    }

    /* Mobile top and bottom bars */
    .mobile-top-bar,
    .mobile-bottom-bar {
        position: sticky;
        width: 100%;
        padding: 10px 15px;
        z-index: 25;
        display: flex;
        align-items: center;
        height: 50px;
    }
    
    /* Bottom bar keeps white background */
    .mobile-bottom-bar {
        background-color: #ffffff;
    }
    
    .mobile-top-bar {
        top: 0;
        left: 0;
        background-color: var(--primary-color);
        color: white;
        border-bottom: none;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-bottom-bar {
        bottom: 0;
        left: 0;
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
    
    /* Adjust iframe height to account for top and bottom bars */
    .center-column iframe {
        height: calc(100% - 100px);
        height: calc((var(--vh, 1vh) * 100) - 100px);
    }
    
    /* Ensure details modal uses dynamic viewport height on mobile */
    .details-content {
        height: calc((var(--vh, 1vh) * 100) - 40px);
    }
    
    /* Price display */
    .price-display {
        font-weight: bold;
        color: var(--primary-color);
        font-size: 1.1rem;
    }
    
    /* Details button */
    .details-button {
        color: var(--primary-color);
        border: 1px solid var(--primary-color);
        background-color: transparent;
        padding: 5px 10px;
        transition: all 0.2s ease;
    }
    
    .details-button:hover,
    .details-button:focus {
        background-color: var(--primary-color);
        color: white;
    }
}
