/*
 * AGSIST Shared Styles
 * Include in all pages: <link rel="stylesheet" href="/components/shared.css">
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
    /* Colors */
    --bg: #0a0a0c;
    --surface: #111114;
    --card: #16161a;
    --card-hover: #1c1c22;
    --border: #2a2a32;
    --text: #e8e8ec;
    --dim: #9a9aa6;
    --accent: #e6b042;
    --green: #4ade80;
    --red: #ef4444;
    
    /* Category Colors */
    --community: #ff6b35;
    --government: #10b981;
    --university: #3b82f6;
    --industry: #8b5cf6;
    --markets: #f59e0b;
    --weather: #06b6d4;
}

/* ============================================
   BASE RESET
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   NAVIGATION
   ============================================ */

.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.nav-logo:hover {
    opacity: 0.85;
}

.nav-logo-img {
    height: 38px;
    width: auto;
    display: block;
}

/* Desktop Menu */
.nav-menu {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    background: none;
    border: none;
    color: var(--dim);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.nav-dropdown-btn:hover {
    color: var(--text);
    background: var(--card-hover);
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-width: 180px;
    padding: 8px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 1001;
}

.nav-dropdown:hover .nav-dropdown-content {
    display: block;
}

.nav-dropdown-content a {
    display: block;
    padding: 10px 16px;
    color: var(--dim);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-dropdown-content a:hover {
    background: var(--card-hover);
    color: var(--accent);
}

/* Mobile Menu Button */
.nav-mobile-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.4rem;
    width: 44px;
    height: 44px;
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.nav-mobile-btn:hover {
    background: var(--card-hover);
    border-color: var(--accent);
}

/* Mobile Menu Panel */
.nav-mobile {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    z-index: 999;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

.nav-mobile.active {
    display: block;
}

.nav-mobile-section {
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0 4px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}

.nav-mobile-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.nav-mobile a {
    display: inline-block;
    color: var(--dim);
    text-decoration: none;
    padding: 6px 10px;
    font-size: 0.85rem;
    transition: color 0.2s;
    background: var(--card);
    border-radius: 4px;
    margin: 2px;
}

.nav-mobile a:hover {
    color: var(--text);
    background: var(--card-hover);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 32px 20px 24px;
    margin-top: 60px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.footer-logo:hover { opacity: 0.85; }

.footer-logo-img {
    height: 28px;
    width: auto;
    display: block;
}

.footer-sep { color: var(--border); }
.footer-tagline { color: var(--dim); font-size: 0.85rem; }

.footer-cols {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.footer-col h4 {
    color: var(--dim);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 8px;
}

.footer-col a {
    display: block;
    color: var(--dim);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 3px 0;
    transition: color 0.15s;
}

.footer-col a:hover { color: var(--accent); }

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.footer-legal {
    color: var(--dim);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer-legal a {
    color: var(--dim);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-legal a:hover { color: var(--accent); }

.footer-network-inline {
    display: flex;
    gap: 16px;
}

.footer-network-inline a {
    color: var(--dim);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s;
}

.footer-network-inline a:hover { color: var(--accent); }

/* ============================================
   COMMON LAYOUT (base fallbacks)
   ============================================ */

main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.breadcrumb { font-size: 0.85rem; color: var(--dim); margin-bottom: 16px; }
.breadcrumb a { color: var(--accent); text-decoration: none; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 20px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h1, .panel-head h2 { font-size: 1.1rem; color: var(--accent); margin: 0; }
.panel-body { padding: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Form controls */
.panel label { display: block; font-size: 0.8rem; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.panel input[type="number"], .panel input[type="text"], .panel select {
    width: 100%; padding: 10px 12px; font-family: inherit; font-size: 0.9rem;
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.panel input:focus, .panel select:focus { outline: none; border-color: var(--accent); }

/* Results */
.result-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: none; }
.result-label { font-size: 0.9rem; color: var(--dim); }
.result-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.result-value.highlight { color: var(--accent); font-size: 1.3rem; }
.result-value.positive { color: #4ade80; }
.result-value.negative { color: #ef4444; }

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    main { padding: 12px; }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

/* Prevent horizontal overflow globally */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: hidden; width: 100%; }
img, video, svg { max-width: 100%; height: auto; }
iframe { max-width: 100%; }

/* Mobile base */
@media (max-width: 768px) {
    /* Nav */
    .nav-menu {
        display: none;
    }
    
    .nav-mobile-btn {
        display: flex;
    }

    .nav-logo-img {
        height: 30px;
    }
    
    /* Footer */
    .footer {
        padding: 20px 16px;
    }
    
    .footer-brand {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .footer-tagline {
        display: none;
    }

    .footer-logo-img {
        height: 22px;
    }
    
    .footer-cols {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .footer-network-inline {
        flex-wrap: wrap;
        gap: 12px;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .nav {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .footer {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   SKIP NAV (accessibility)
   ============================================ */
.skip-nav {
    position: absolute;
    top: -50px;
    left: 16px;
    background: var(--accent, #e6b042);
    color: #000;
    padding: 8px 16px;
    border-radius: 0 0 6px 6px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10000;
    transition: top 0.2s;
    text-decoration: none;
}
.skip-nav:focus {
    top: 0;
}

/* ============================================
   TOOLTIPS — hover for abbreviations
   ============================================ */
.tip {
    position: relative;
    cursor: help;
    border-bottom: 1.5px dashed var(--accent, #e6b042);
    color: inherit;
    padding-bottom: 1px;
}
.tip:hover {
    background: rgba(230,176,66,0.12);
    border-radius: 2px;
}
.tip-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--dim, #9a9aa6);
    border: 1px solid var(--dim, #9a9aa6);
    border-radius: 50%;
    margin-left: 3px;
    vertical-align: super;
    cursor: help;
}
#agsist-tooltip {
    position: fixed;
    background: #1e1e24;
    color: #e2e2e6;
    border: 1px solid #3a3a42;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    max-width: 320px;
    width: max-content;
    z-index: 99999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.15s;
}
#agsist-tooltip.visible {
    opacity: 1;
}
