/*
    Main Application Layout Styles

    This file contains all the styling for the main application shell including:
    - Sidebar styles
    - Main content area styles
    - Navigation styles
    - Layout containers

    Uses global CSS variables from color.css
*/


/* ==== GLOBAL LAYOUT VARIABLES ==== */

:root {
    /* Spacing scale */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    /* Border radius tokens */
    --border-radius-sm: 6px;
    --border-radius: 8px;
    --border-radius-md: 10px;
    --border-radius-lg: 12px;
    --border-radius-xl: 20px;
    /* Transitions */
    --transition: all 0.3s ease;
    /* Placeholder sizing tokens (colors are in color.css) */
    --placeholder-font-size: 16px;
    --placeholder-line-height: 20px;
    --placeholder-top-offset: 1px;
    /* MultiSelect specific sizing */
    --multiselect-min-height: 48px;
    --multiselect-padding: 12px 16px 12px 44px;
    --multiselect-item-margin: 2px 4px;
}


/* Main Layout Container */

.main-layout-container {
    display: flex;
    height: calc(100vh - 60px - 56px - 4px);
}


/* Sidebar Styles */

.sidebar-container {
    width: 380px;
    background-color: var(--bg-primary);
    border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
    border-right: 1.5px solid var(--bg-tertiary);
    padding: var(--spacing-md);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px - 56px - 4px);
    overflow: hidden;
}

.sidebar-body {
    flex: 1 1 auto;
    overflow-y: auto;
}

.sidebar-navigation {
    margin-top: var(--spacing-xl);
    padding-left: 6px;
}


/* Sidebar Navigation Items */

.sidebar-section {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-xs);
    text-decoration: none;
    transition: var(--transition);
}

.sidebar-section:hover {
    background-color: var(--bg-tertiary);
}

.sidebar-section-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
}


/* if this class is on a span, its been placed next to an icon */

.sidebar-section-text {
    color: var(--color-text-secondary);
    font-size: 16px;
    font-weight: 400;
}


/* if this class is directly on the link, it has no icon */

a.sidebar-section-text {
    color: var(--color-text-secondary);
    font-size: 14px;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}


/* Sidebar Dropdown */

.sidebar-dropdown-container {
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-xs);
}


/* apply indent for nested items */

.sidebar-dropdown-container .collapse a {
    margin-left: 2em;
}


/* Main Content Area */

.page-container {
    border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
    background-color: var(--bg-primary);
    padding: var(--spacing-md);
    overflow-y: auto;
    height: 100%;
    flex: 1;
    transition: var(--transition);
}


/* When sidebar is collapsed */

.page-container--sidebar-collapsed {
    border-radius: var(--border-radius-lg);
}


/* Loading Components */

.loading-container {
    margin-bottom: var(--spacing-sm);
}

.data-badge {
    margin-bottom: 0.5%;
    display: inline-block;
}

.data-badge--hidden {
    display: none;
}


/* Top Bar */

.topbar {
    height: 60px;
    width: 100%;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 10px;
    padding-right: 10px;
    border-bottom: 1.5px solid var(--bg-tertiary);
}

.topbar-left {
    display: flex;
    align-items: center;
}

.topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.topbar-right {
    min-width: 150px;
}


/* Sidebar Toggle Button */

.sidebar-toggle {
    color: var(--color-text-secondary);
    font-size: 18px;
    padding: var(--spacing-xs) 12px;
    margin-right: 10px;
    border: none;
    background-color: transparent;
}


/* Logo Styles */

.logo {
    width: 70px;
    height: 22px;
    margin: 20px 20px;
    display: inline-block;
    vertical-align: middle;
}

.logo--chaoss {
    margin: 10px -20px;
}


/* Navigation Links */

.nav-link {
    color: var(--color-text-secondary);
    font-size: 16px;
    padding: 6px 16px;
    margin-right: 16px;
    text-decoration: none;
    border-radius: var(--border-radius);
    line-height: 1.2;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--color-white);
    background-color: var(--bg-tertiary);
}

.nav-link--visualization {
    background-color: transparent;
    border: none;
    text-align: left;
    padding: 4px 16px;
}


/* Bottom Navbar */

.navbar-bottom {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: var(--bg-primary);
    border-top: 1px solid var(--bg-tertiary);
}


/* Application Container */

.app-container {
    background-color: var(--bg-secondary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.app-main-container {
    background-color: var(--bg-secondary);
}


/* Search Bar Styles */


/* fix for input background color */


/* we need to override dash bootstrap components here. this selector should be more specific than
.dbc input:not([type="radio"]):not([type="checkbox"]) */

.searchbar-dropdown input#projects.mantine-MultiSelect-inputField::placeholder {
    background-color: transparent !important;
}

.searchbar-dropdown input#projects.mantine-MultiSelect-inputField {
    background-color: transparent !important;
}

.search-bar {
    padding-top: 16px;
}

.search-bar-input {
    font-size: 16px;
    height: 48px;
    padding: 0 16px 0 44px;
    border-radius: var(--border-radius-xl);
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border-color: var(--border-color-ui);
    position: relative;
    z-index: 1;
}

.search-bar-dropdown {
    border-radius: var(--border-radius-lg);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color-dark);
}

.search-bar-item {
    border-radius: var(--border-radius);
    margin: 2px 4px;
    color: var(--color-white);
}


/* Truncate long names in search bar pills (selected items) */

.searchbar-dropdown .mantine-Pill-label {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-icon {
    background-color: transparent;
    border: none;
    font-size: 16px;
    width: 16px;
    height: 16px;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-100%);
    font-weight: bold;
    z-index: 2;
}


/* Search Controls */

.search-controls {
    width: 100%;
    justify-content: center;
    margin-top: 16px;
}

.search-help-button {
    background-color: transparent;
    border: none;
    padding: 4px var(--spacing-xs);
    font-size: 14px;
}

.search-list-button {
    background-color: transparent;
    border: none;
    padding: 4px var(--spacing-xs);
    font-size: 14px;
}

.bot-filter-switch {
    font-size: 12px;
    margin-top: var(--spacing-xs);
    margin-left: 10px;
}


/* visualization adjustments */

.visualization-row {
    margin-bottom: 5rem;
    /* Centers the cards */
    justify-content: space-evenly;
    /* Vertically align child text elements */
    align-items: center;
}


/* Storage Quota Warning */

.storage-quota-warning {
    display: none;
    margin-top: var(--spacing-sm);
    margin-bottom: 0;
}


/* ==== UTILITY COMPONENT CLASSES ==== */


/* Generic transparent icon button */

button.icon-button.btn,
.btn.icon-button {
    background-color: transparent;
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 14px;
    box-shadow: none;
}

button.icon-button.btn:hover,
button.icon-button.btn:focus,
button.icon-button.btn:active,
.btn.icon-button:hover,
.btn.icon-button:focus,
.btn.icon-button:active {
    background-color: transparent;
    border: none;
    box-shadow: none;
    color: inherit;
}


/* Login disabled banner positioning */

.login-banner-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 1000;
}

.login-banner-alert {
    background-color: var(--baby-blue-100);
    border-color: var(--baby-blue-700);
    border: 1px solid var(--baby-blue-700);
    border-left: 5px solid var(--baby-blue-700);
    box-shadow: 0 2px 8px var(--shadow-color-md);
    max-width: 400px;
    padding: 15px;
    z-index: 1000;
}

.login-banner-heading {
    color: var(--color-black);
    font-weight: 600;
    margin: 0 0 8px 0;
    text-shadow: none;
}

.login-banner-text {
    color: #333333;
    margin: 0 0 10px 0;
}

.login-banner-link {
    font-weight: 500;
    color: #1565C0;
}


/* Search component specific classes */

.search-input-wrapper {
    position: relative;
}

.search-input-section {
    width: 100%;
    margin-bottom: var(--spacing-md);
    padding: 0 6px;
}

.search-controls-stack {
    width: 100%;
    justify-content: center;
    margin-top: var(--spacing-md);
}

.search-bar-wrapper {
    padding-top: var(--spacing-md);
}

.repo-list-alert {
    overflow-y: scroll;
    max-height: 440px;
}


/* Utility Classes */

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.flex-center {
    justify-content: center;
    align-items: center;
}

.text-center {
    text-align: center;
}

.w-100 {
    width: 100%;
}

.h-100 {
    height: 100%;
}


/* Responsive Design */

@media (max-width: 768px) {
    .sidebar-container {
        width: 280px;
    }
    .topbar {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
    }
    .nav-link {
        font-size: 14px;
        padding: 4px 12px;
        margin-right: var(--spacing-xs);
    }
}

@media (max-width: 480px) {
    .sidebar-container {
        width: 100%;
        position: fixed;
        z-index: 1000;
    }
    .main-layout-container {
        flex-direction: column;
    }
}


/* ==================================================================
   GLOBAL COMPONENT STYLES

   The following styles apply to components used throughout the
   application. These were previously in color.css but have been
   moved here for better organization.

   Sections:
   - Typography (headings, blockquotes)
   - Dash-specific components
   - Data display components
   - Bootstrap overrides
   - Form components (switches, popovers, radio buttons)
   - Card components
   - Custom buttons
   - Date picker components
   - Text input controls
   - Table components
   ================================================================== */


/* ==== TYPOGRAPHY WITH HIGHER SPECIFICITY ==== */

body h2,
body h4,
body h5,
body h6 {
    color: var(--color-secondary);
}

body h1,
body h3 {
    color: var(--color-primary);
}


/* Blockquote styling with higher specificity */

article blockquote h5,
div blockquote h5,
blockquote h5 {
    color: var(--color-muted);
}

article blockquote,
div blockquote,
blockquote {
    color: var(--color-accent);
    font-style: normal;
    font-size: 18px;
    margin-left: 32px;
    font-family: Consolas, "Times New Roman", Verdana;
    border-left: 4px solid #787878;
    padding-left: 8px;
}

blockquote p {
    margin-top: var(--placeholder-top-offset);
    margin-bottom: 1px;
    width: auto;
    min-width: 50px;
    max-width: 950px;
}


/* ==== DASH SPECIFIC COMPONENTS ==== */


/* Utility classes */

.explanation-p {
    width: auto;
    min-width: 50px;
    max-width: 550px;
}


/* Navigation brand with higher specificity */

.navbar .navbar-brand,
nav .navbar-brand {
    color: var(--color-primary);
}


/* ==== DATA DISPLAY COMPONENTS ==== */


/* Metric data with higher specificity */

.metric-container .metric_data,
div.metric_data {
    color: var(--color-black);
    text-shadow: none;
    padding-bottom: 15px;
}

.box_emissions {
    background-color: #505050;
    color: #505050;
    margin: 2px;
    box-shadow: 4px 4px 4px rgb(33, 33, 33);
    justify-content: center;
    text-align: center;
}


/* Headers with higher specificity */

.glace-container .glace_headers,
div.glace_headers {
    color: var(--color-black);
    text-shadow: none;
    font-weight: normal;
}


/* ==== BOOTSTRAP COMPONENT OVERRIDES ==== */


/* Alert warning with higher specificity */

.alert.alert-warning {
    background-color: var(--color-secondary);
}


/* ==== FORM COMPONENTS ==== */


/* Switch styling with higher specificity */

.filter-container .botlist-filter-switch:checked,
input.botlist-filter-switch:checked {
    background-color: var(--baby-blue-700);
    color: var(--placeholder-text-color)!important;
}


/* Popover styling */

.popover {
    max-width: 500px;
}


/* Graph info popover theme */

.popover>.popover-body {
    background-color: #404040;
    color: #E5E5E5;
}

.popover>.popover-header {
    background-color: #E5E5E5;
    color: #404040;
}


/* Remove underline for button-as-link in sidebar */

.sidebar-link-button,
.sidebar-link-button:hover,
.sidebar-link-button:focus,
.sidebar-link-button:active {
    text-decoration: none !important;
    box-shadow: none !important;
}


/* Ensure footer spacer actually takes effect in case of collapsed margins */

#sidebar-footer>div[style*="height"] {
    display: block;
}


/* ==== CARD COMPONENTS ==== */


/* Card title with higher specificity */

.card h3.card-title,
div.card h3.card-title {
    color: var(--color-white);
    text-align: left;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 0;
}


/* ==== CUSTOM RADIO BUTTONS ==== */

.custom-radio-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.custom-radio-buttons .form-check {
    margin-right: var(--spacing-md);
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

.custom-radio-buttons .form-check-input {
    width: 1em;
    height: 1em;
    border: 1px solid var(--content-subtle);
    background-color: transparent;
    margin-right: 0.4rem;
    margin-top: 0;
    flex-shrink: 0;
}

.custom-radio-buttons .form-check-input:checked {
    background-color: var(--color-border);
    border-color: var(--content-subtle);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2.5' fill='%23C7C7C7'/%3e%3c/svg%3e");
}

.custom-radio-buttons .form-check-input:focus {
    border-color: var(--content-subtle);
    box-shadow: 0 0 0 0.2rem rgba(199, 199, 199, 0.25);
}

.custom-radio-buttons .form-check-label {
    color: var(--content-subtle);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    margin-left: 0.1rem;
    margin-bottom: 0;
    line-height: 1;
}


/* ==== CUSTOM BUTTON STYLES ==== */


/* About graph button with higher specificity */

.graph-container .about-graph-button,
button.about-graph-button {
    border-radius: var(--border-radius);
    font-weight: 400;
    min-width: 120px;
    padding: 0.33rem var(--spacing-lg);
    color: var(--color-white);
    border: 0.5px solid var(--multiselect-hover-bg);
    background-color: transparent;
    transition: all 0.2s ease;
}

.graph-container .about-graph-button:hover,
button.about-graph-button:hover {
    border-color: #606060;
    color: var(--color-text-light);
    background-color: rgba(64, 64, 64, 0.1);
}


/* ==== CARD STYLES ==== */


/* Dark card with higher specificity */

.card-container .dark-card,
div.dark-card {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    background-color: var(--color-border);
}


/* =============================================================================
   DATE PICKER COMPONENTS
============================================================================= */


/* Fix for the vertical bar issue */

.dbc input:not([type=radio]):not([type=checkbox]).DateInput_input {
    color: var(--bs-body-color) !important;
    background-color: #404040 !important;
}


/**
 * Date Picker Dark Theme
 * Styling for React-Dates and similar date picker components
 */

.dark-date-picker .DateInput_input {
    background-color: var(--multiselect-hover-bg)!important;
    border-color: var(--multiselect-hover-bg) !important;
    color: white !important;
}

.dark-date-picker .DateInput_input:focus {
    background-color: var(--multiselect-hover-bg) !important;
    border-color: #555555 !important;
    color: white !important;
}

.dark-date-picker .DateRangePickerInput {
    background-color: var(--multiselect-hover-bg) !important;
    border-color: var(--multiselect-hover-bg) !important;
}


/**
 * Date Range Picker Specific Styling
 * The Date picker within plotly involves a lot of internal classes that need to be styled.
 */

.dark-date-picker .DateRangePickerInput .DateInput_input,
.DateInput_input__focused {
    height: var(--placeholder-font-size);
    outline: 0;
    background: var(--multiselect-hover-bg) !important;
    border: 0 !important;
    border-top: 0 !important;
    border-right: 0;
    border-bottom: 2px solid #008489;
    border-left: 0;
}

.dark-date-picker .DateInput_input {
    font-weight: 400;
    font-size: 19px;
    color: var(--color-white);
}

.dark-date-picker .DateInput {
    background: var(--multiselect-hover-bg) !important;
}


/* Dark Date Picker Border Styling */

.dark-date-picker .DateRangePickerInput__withBorder {
    border-radius: 7px;
    border: 1px solid var(--multiselect-hover-bg);
}


/**
 * Date Picker Arrow Customization
 * Hides default SVG arrow and replaces with text-based arrow
 */

.dark-date-picker .DateRangePickerInput_arrow_svg {
    display: none !important;
}

.dark-date-picker .DateRangePickerInput_arrow::before {
    content: "→" !important;
    font-size: 1.2em !important;
    color: #fff9f9 !important;
    display: inline-block !important;
    vertical-align: middle !important;
    background-color: var(--multiselect-hover-bg) !important;
}


/* Placeholder text (the Start Date and End Date labels) */

.dark-date-picker input::placeholder {
    background-color: var(--multiselect-hover-bg) !important;
}


/* =============================================================================
   TEXT INPUT CONTROLS
============================================================================= */


/* Dark Input Box Styling */

.dark-input,
.form-control.form-control-sm.dark-input,
.form-control.form-control-sm.dark-input[type="number"] {
    width: 80px !important;
    background-color: #404040 !important;
    border-color: #404040 !important;
    color: white !important;
    background-image: none !important;
}


/* Dark Input Focus Styling */

.dark-input:focus,
input.dark-input:focus,
.form-control.dark-input:focus,
.form-control.form-control-sm.dark-input:focus,
.form-control.form-control-sm.dark-input[type="number"]:focus {
    background-color: #404040 !important;
    border-color: #555555 !important;
    color: white !important;
    box-shadow: 0 0 0 0.2rem rgba(64, 64, 64, 0.25) !important;
    background-image: none !important;
}


/* Labels for dark inputs (scoped to a wrapper) */

.dark-input-group label,
.dark-input-group .form-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-white);
    margin-bottom: 0;
    margin-right: 0.5rem;
    margin-bottom: 0;
}


/* =============================================================================
   DCC.DROPDOWN dark-dropdown styling
============================================================================= */


.dark-dropdown {
    border-radius: var(--border-radius-lg);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color-dark);
}

/* removes the white boarder  */
.dark-dropdown .Select-control {
    border-color: var(--multiselect-hover-bg) !important;
}

/* prevent the weird bar color mismatch */
.dark-dropdown .Select-value,
.dark-dropdown .Select-placeholder {
    background-color: #404040 ;
    color: var(--bs-body-color);
}

/* dropdown menu options */
.dark-dropdown .VirtualizedSelectOption {
    background-color: #404040;
    color: var(--bs-body-color);
  }

/* dropdown menu hover effect */
.dark-dropdown .VirtualizedSelectFocusedOption {
    background-color: var(--color-border);;
    color: white;
  }

/* ==== CARD DIVIDER (card-split) ==== */


/* Horizontal divider used to separate graph from controls inside cards */

.card-split {
    border: 0;
    border-top: 1px solid #909090;
    margin: 1.5rem -1.5rem;
    width: calc(100% + 3rem);
}


/* =============================================================================
   TABLE COMPONENTS STYLING
============================================================================= */


/* Scoped to app to avoid global overrides */

.dbc .table {
    /* Bootstrap 5 table CSS variables for consistent theming */
    --bs-table-bg: var(--color-dark-bg);
    --bs-table-color: var(--color-white);
    --bs-table-border-color: var(--multiselect-hover-bg);
    --bs-table-striped-bg: #222;
    --bs-table-hover-bg: #2e2e2e;
    --bs-table-active-bg: #2e2e2e;
    background-color: var(--bs-table-bg);
    color: var(--bs-table-color);
}

.dbc .table th,
.dbc .table td {
    border-color: var(--bs-table-border-color);
    background-color: var(--bs-table-bg);
}

.dbc .table thead th {
    background-color: var(--color-topbar-bg);
    color: var(--color-white);
}

.dbc .table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--bs-table-striped-bg);
}

.dbc .table-hover tbody tr:hover {
    background-color: var(--bs-table-hover-bg);
}

.dbc .table-bordered {
    border-color: var(--bs-table-border-color);
}
