/* ========== 1. DESIGN TOKENS (CSS Custom Properties) ========== */
:root {
    color-scheme: light;

    --aeo-green: #00ff7f;
    --aeo-green-dim: #00cc66;
    --aeo-green-hover: #009955;  /* Darker green for hover on light backgrounds */
    --aeo-green-dark: #004d26;
    --aeo-dark-bg: #121212;
    --aeo-dark-surface: #1e1e1e;
    --aeo-dark-border: rgba(0, 255, 127, 0.2);
    --aeo-text: #ffffff;
    --aeo-text-muted: #cccccc;
    --aeo-text-dim: #888888;

    /* Semantic Status Colors (Bootstrap-compatible) */
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning-text: #856404;
    --color-warning-bg: #ffc107;
    --color-muted: #6c757d;
    --color-info: #17a2b8;
    --color-primary: #007bff;

    /* Neutral Palette */
    --color-bg-light: #f8f9fa;
    --color-text-dark: #495057;
    --color-text-heading: #2c3e50;
    --color-border-light: #dee2e6;
    --color-border-subtle: #e9ecef;
    --color-border-card: #e1e8ed;
    --color-border-divider: #f0f4f8;

    /* Link Color */
    --color-link: #337ab7;
    --color-link-hover: #23527c;

    /* Navbar Colors */
    --color-nav-text: #777;
    --color-nav-active-text: #333;
    --color-nav-active-bg: #e7e7e7;
    --color-nav-active-bg-mobile: #f5f5f5;

    /* Secondary Text */
    --color-text-secondary: #666;

    /* Hostname Verification (relay pages) */
    --color-hostname-verified: #68b030;
    --color-hostname-unverified: #FE9F30;

    /* Highlight/Target (anchor navigation) */
    --color-highlight-bg: #fff3cd;
    --color-highlight-border: #ffe69c;
}

/* ========== 2. 1AEO CROSS-SITE NAVIGATION ========== */
.aeo-cross-nav {
    background-color: var(--aeo-dark-surface);
    padding: 10px 0;
    border-bottom: 1px solid var(--aeo-dark-border);
    margin-bottom: 0;
}

.aeo-cross-nav .aeo-nav-container {
    max-width: 95%;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.aeo-cross-nav .aeo-nav-brand {
    color: var(--aeo-green);
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aeo-cross-nav .aeo-nav-brand:hover {
    color: var(--aeo-green);
    text-decoration: none;
}

.aeo-cross-nav .aeo-nav-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
}

.aeo-cross-nav .aeo-nav-links a {
    color: var(--aeo-text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.aeo-cross-nav .aeo-nav-links a:hover {
    color: var(--aeo-green);
    text-decoration: none;
}

.aeo-cross-nav .aeo-nav-links a.active {
    color: var(--aeo-green);
    font-weight: 500;
}

@media (max-width: 480px) {
    .aeo-cross-nav .aeo-nav-container {
        justify-content: center;
        text-align: center;
    }
    .aeo-cross-nav .aeo-nav-links {
        justify-content: center;
        gap: 12px;
    }
}

/* ========== 3. BREADCRUMBS ========== */
.breadcrumb a {
    text-decoration: none;
}

/* ========== 4. 1AEO FOOTER ========== */
.aeo-footer {
    background-color: var(--aeo-dark-surface);
    color: var(--aeo-text-muted);
    padding: 25px 20px;
    margin-top: 40px;
    text-align: center;
    border-top: 1px solid var(--aeo-dark-border);
}

.aeo-footer a {
    color: var(--aeo-green);
    text-decoration: none;
}

.aeo-footer a:hover {
    color: var(--aeo-green);
    text-decoration: underline;
}

.aeo-footer-links {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.aeo-footer-brand {
    font-size: 14px;
    margin: 0;
}

.aeo-footer-legal {
    font-size: 12px;
    color: var(--aeo-text-dim);
    margin-top: 10px;
}
/* ========== 5. RELAY STATUS INDICATORS ========== */
.circle {
    display: inline-block;
    vertical-align: middle;
    background: var(--color-muted);
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.circle-online {
    background: var(--color-success);
}

.circle-offline {
    background: var(--color-danger);
}

/* verified-hostname, unverified-hostname, status classes,
   section-box, subsection-card, subsection-header, and
   status-note moved to relay-info.html (only consumer) */

/* ========== 6. CONTACT & TEXT TRUNCATION ========== */
.contact-text {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 20vw;  /* Use viewport width for responsive sizing */
}

/* Contact cell in contacts table - dynamic width with CSS ellipsis */
.contact-cell {
    max-width: 25vw;
    display: flex;
    align-items: center;
}

.contact-cell > span {
    flex-shrink: 0;
    margin-right: 4px;
}

.contact-cell a {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== 7. TABLE STYLES ========== */
.table {
    width: 100%;
    margin-bottom: 1rem;
}

/* Precise alignment for multi-value columns using monospace */
.bw-header, .cw-header, .rc-header, /* rc = relay count */
.bw-data, .cw-data, .rc-data {
    font-family: Consolas, "Courier New", monospace;
    white-space: nowrap;
    text-align: center;
    letter-spacing: 0.05em; /* Slight spacing for readability */
}

/* ========== 8. LAYOUT (Container, column overflow) ========== */
@media (min-width: 1400px) {
    .container {
        width: 95%;
        max-width: none;
        padding-right: 15px;
        padding-left: 15px;
        margin-right: auto;
        margin-left: auto;
    }
}

/* Fix two-column layout overflow in contact/operator pages */
.row > .col-md-7,
.row > .col-md-5 {
    overflow-wrap: anywhere;
    min-width: 0; /* Allow flex/grid children to shrink below content size */
}

/* Ensure nested content doesn't overflow columns */
.col-md-7 ul,
.col-md-7 li,
.col-md-5 ul,
.col-md-5 li {
    overflow-wrap: anywhere;
}

/* ========== 9. AROI SHARED UTILITIES ========== */
.aroi-center-text { text-align: center; }
.aroi-subsection { margin-bottom: 30px; }

/* AROI Leaderboard CSS moved to aroi-leaderboards.html (only consumer) */
/* Network Health CSS moved to network-health-dashboard.html (only consumer) */

/* ========== 10. CSS-ONLY TOOLTIPS ========== */
/* Base tooltip styling for elements with title attributes */
[title] {
    position: relative;
    cursor: help;
}

/* Create tooltip content using title attribute */
[title]::before {
    content: attr(title);
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.3;
    max-width: 300px;
    overflow-wrap: break-word;
    white-space: normal;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    
    /* Position above the element by default */
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
}

/* Tooltip arrow */
[title]::after {
    content: '';
    position: absolute;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    
    /* Position arrow */
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
}

/* Show tooltip on hover (desktop) and focus/active (mobile) */
[title]:hover::before,
[title]:focus::before,
[title]:active::before,
[title]:hover::after,
[title]:focus::after,
[title]:active::after {
    opacity: 1;
    visibility: visible;
}

/* Make elements focusable on mobile for tooltip interaction */
@media (max-width: 767px) {
    [title] {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        outline: none;
    }
    
    /* Add subtle visual feedback for tapped tooltips on mobile */
    [title]:active {
        background-color: rgba(0, 0, 0, 0.05);
        border-radius: 3px;
    }
    
    /* Ensure tooltip fits on mobile screens */
    [title]::before {
        max-width: 280px;
        left: 0;
        right: 0;
        transform: none;
        margin-left: auto;
        margin-right: auto;
    }
    
    [title]::after {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Special positioning for table cells and small elements */
td[title]::before,
th[title]::before {
    bottom: 100%;       /* position tooltip above cell */
    top: auto;
    margin-bottom: 8px; /* spacing between cell and tooltip */
    margin-top: 0;
}

td[title]::after,
th[title]::after {
    bottom: 100%;
    top: auto;
    border-top-color: rgba(0, 0, 0, 0.9); /* arrow points down */
    border-bottom-color: transparent;
    margin-bottom: 2px;
    margin-top: 0;
}

/* ========== 11. CSS-ONLY NAVBAR (Hamburger menu) ========== */
.navbar-toggle {
    display: none;
    background-color: transparent;
    background-image: none;
    border: 1px solid var(--color-border-light);
    border-radius: 4px;
    padding: 9px 10px;
    margin-top: 8px;
    margin-right: 15px;
    margin-bottom: 8px;
    cursor: pointer;
    float: right;
}

.navbar-toggle:hover,
.navbar-toggle:focus {
    background-color: var(--color-border-light);
}

.navbar-toggle .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--aeo-text-dim);
    border-radius: 1px;
    margin: 4px 0;
}

.navbar-brand {
    float: left;
    height: 50px;
    padding: 15px;
    font-size: 18px;
    line-height: 20px;
    font-weight: bold;
}

/* Desktop: show navigation horizontally */
@media (min-width: 768px) {
    .navbar-collapse {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .nav.navbar-nav {
        float: left;
        margin: 0;
    }
    
    .nav.navbar-nav > li {
        float: left;
    }
    
    .nav.navbar-nav > li > a {
        padding-top: 15px;
        padding-bottom: 15px;
        color: var(--color-nav-text);
        text-decoration: none;
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .nav.navbar-nav > li.active > a,
    .nav.navbar-nav > li > a:hover,
    .nav.navbar-nav > li > a:focus {
        color: var(--color-nav-active-text);
        background-color: var(--color-nav-active-bg);
    }
    
    .navbar-brand {
        display: none;
    }
}

/* Mobile: hide navigation by default, show hamburger */
@media (max-width: 767px) {
    .navbar-toggle {
        display: block;
    }
    
    .navbar-collapse {
        display: none;
        clear: both;
        width: 100%;
        margin-top: 50px;
        border-top: 1px solid var(--color-border-subtle);
        padding-top: 10px;
    }
    
    /* When checkbox is checked, show the menu */
    .navbar-toggle-checkbox:checked ~ .navbar-header + .navbar-collapse {
        display: block;
    }
    
    .nav.navbar-nav > li {
        float: none;
    }
    
    .nav.navbar-nav > li > a {
        display: block;
        padding: 12px 20px;
        color: var(--color-nav-text);
        text-decoration: none;
        border-bottom: 1px solid var(--color-border-subtle);
    }
    
    .nav.navbar-nav > li:last-child > a {
        border-bottom: none;
    }
    
    .nav.navbar-nav > li.active > a,
    .nav.navbar-nav > li > a:hover,
    .nav.navbar-nav > li > a:focus {
        color: var(--color-nav-active-text);
        background-color: var(--color-nav-active-bg-mobile);
    }
}

/* ========== 12. SEARCH FORM ========== */
.navbar-form.navbar-right {
    margin-left: 15px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.navbar-form .input-group {
    display: inline-table;
    vertical-align: middle;
}

.navbar-form .form-control {
    border-radius: 3px 0 0 3px;
}

.navbar-form .btn {
    border-radius: 0 3px 3px 0;
}

.allium-mobile-search {
    background: var(--color-bg-light);
    padding: 8px 15px;
    margin-top: -20px; /* Pull up to sit flush with navbar */
    margin-bottom: 15px;
    border-radius: 0 0 4px 4px; /* Only round bottom corners */
    border: 1px solid var(--color-border-subtle);
    border-top: none;
}

.allium-mobile-search .form-control {
    font-size: 15px; /* Smaller than nav (18px) but larger than body (14px) */
    padding: 6px 10px;
    height: auto;
}

.allium-mobile-search .btn {
    font-size: 14px;
    padding: 6px 12px;
}

/* 
 * Search bar responsive behavior:
 * - Below 1600px: Always show full-width search bar below navbar
 * - At 1600px+: Show compact search in navbar (enough room for all nav items + search)
 *
 * !important is required here to override Bootstrap's .hidden-xs/.visible-xs
 * utility classes which also use !important. The HTML uses both Bootstrap
 * responsive classes AND these custom breakpoint rules for the 1600px threshold.
 */

/* Default: show full-width search, hide navbar search */
.allium-mobile-search {
    display: block !important;
}

.navbar-form.navbar-right {
    display: none !important;
}

/* Extra large desktop (≥1600px): enough room for inline search */
@media (min-width: 1600px) {
    .allium-mobile-search {
        display: none !important;
    }
    .navbar-form.navbar-right {
        display: block !important;
    }
}
/* API Diagnostics CSS moved to api-diagnostics.html (only consumer) */

/* ========== 13. SHARED SEMANTIC CLASSES (al- namespaced) ========== */
/*
 * Shared classes promoted from relay-info.html for global reuse.
 * All prefixed with al- to avoid collisions with Bootstrap
 * (.text-muted, .text-success, .alert-warning, etc.).
 */

/* Status text colors — replace inline style="color: #hexval;" */
.al-status-success      { color: var(--color-success); }
.al-status-danger       { color: var(--color-danger); }
.al-status-warning      { color: var(--color-warning-text); }
.al-status-muted        { color: var(--color-muted); }
.al-status-info         { color: var(--color-info); }

/* Status text colors + bold — replace inline style="color: #hex; font-weight: bold;" */
.al-status-success-bold { color: var(--color-success); font-weight: bold; }
.al-status-danger-bold  { color: var(--color-danger); font-weight: bold; }
.al-status-warning-bold { color: var(--color-warning-text); font-weight: bold; }

/* Status note — placeholder text in bold contexts (resets font-weight) */
.al-status-note         { font-size: 11px; font-weight: normal; color: var(--color-muted); }

/* Text size helpers */
.al-text-small-muted    { font-size: 11px; color: var(--color-text-secondary); }
.al-text-small-note     { font-size: 12px; color: var(--color-text-secondary); }

/* Rating classes — for Python-emitted operator intelligence HTML */
.al-rating-great        { color: #2e7d2e; font-weight: bold; }
.al-rating-okay         { color: #cc9900; font-weight: bold; }
.al-rating-poor         { color: #c82333; font-weight: bold; }

/* Box classes — color-only (layout stays inline per instance) */
.al-box-warning         { background-color: #fff3cd; border-left-color: var(--color-warning-bg); }
.al-box-danger          { background-color: #f8d7da; border-left-color: var(--color-danger); }
.al-box-success         { background-color: #d4edda; border-left-color: var(--color-success); }
.al-box-info            { background-color: #d1ecf1; border-left-color: var(--color-info); }
.al-box-muted           { background-color: #e9ecef; border-left-color: var(--color-muted); }
.al-box-primary         { background-color: var(--color-bg-light); border-left-color: var(--color-primary); }

/* Utility classes */
.al-link-plain          { text-decoration: none; }
.al-section-title       { margin-top: 0; margin-bottom: 12px; }
.al-font-bold           { font-weight: bold; }
