/* ============================================================
   USPS BATCH TRACKING TOOL — 90s RETRO DESIGN SYSTEM
   Authentic Windows 95 / GeoCities aesthetic (1997)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* ---- Reset ---- */
* { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0 !important; }

/* ---- Design Tokens ---- */
:root {
    --bg: #C0C0C0;
    --fg: #000000;
    --muted: #808080;
    --white: #FFFFFF;
    --navy: #000080;
    --navy-end: #1084D0;
    --yellow: #FFD700;
    --bright-yellow: #FFFF00;
    --red: #FF0000;
    --green: #00FF00;
    --green-dark: #00AA00;
    --blue: #0000FF;
    --purple: #800080;
    --cyan: #008080;
    --panel-yellow: #FFFFCC;

    --font-body: "MS Sans Serif", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --font-heading: "Arial Black", Impact, Haettenschweiler, sans-serif;
    --font-mono: "VT323", "Courier New", Courier, monospace;

    /* 3D Bevel tokens */
    --bevel-out: #fff #808080 #808080 #fff;
    --bevel-in: #808080 #fff #fff #808080;
    --shadow-out: inset -1px -1px 0 #404040, inset 1px 1px 0 #dfdfdf;
    --shadow-in: inset 1px 1px 0 #404040, inset -1px -1px 0 #dfdfdf;
}

/* ---- Tiled Background Pattern ---- */
body {
    font-family: var(--font-body);
    color: var(--fg);
    font-size: 13px;
    background-color: var(--bg);
    background-image:
        linear-gradient(45deg, #b8b8b8 25%, transparent 25%),
        linear-gradient(-45deg, #b8b8b8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #b8b8b8 75%),
        linear-gradient(-45deg, transparent 75%, #b8b8b8 75%);
    background-size: 4px 4px;
    background-position: 0 0, 0 2px, 2px -2px, -2px 0px;
    line-height: 1.4;
}

/* ---- Selection ---- */
::selection { background: var(--navy); color: var(--white); }

/* ---- Win95 Scrollbar ---- */
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--bg); border: 1px solid var(--muted); }
::-webkit-scrollbar-thumb {
    background: var(--bg);
    border: 2px solid;
    border-color: var(--bevel-out);
}
::-webkit-scrollbar-button { display: block; height: 16px; background: var(--bg); border: 1px solid var(--muted); }

/* ---- Animations ---- */
@keyframes rainbow {
    0% { color: #ff0000; }
    17% { color: #ff8000; }
    33% { color: #ffff00; }
    50% { color: #00ff00; }
    67% { color: #0080ff; }
    83% { color: #8000ff; }
    100% { color: #ff0000; }
}
@keyframes ticker-scroll {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}
@keyframes blink-new {
    0%, 49% { visibility: visible; }
    50%, 100% { visibility: hidden; }
}
@keyframes pulse-glow {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,0,0,0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 10px 2px rgba(255,0,0,0.5); }
}
@media (prefers-reduced-motion: reduce) {
    .rainbow-text { animation: none !important; color: var(--red); }
    .ticker-content { animation: none !important; }
    .blink { animation: none !important; visibility: visible !important; }
}

/* ---- Ticker Bar ---- */
.ticker-bar {
    background: var(--navy);
    color: var(--bright-yellow);
    font-family: var(--font-mono);
    font-size: 15px;
    padding: 3px 0;
    white-space: nowrap;
    overflow: hidden;
    border-bottom: 2px solid var(--fg);
}
.ticker-content {
    display: inline-block;
    animation: ticker-scroll 25s linear infinite;
    letter-spacing: 2px;
}
.ticker-content .star { color: var(--red); }

/* ---- Title Bar (Windows 95 Window) ---- */
.title-bar {
    background: linear-gradient(90deg, var(--navy), var(--navy-end));
    padding: 3px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--white);
    font-weight: bold;
    font-size: 12px;
    font-family: var(--font-body);
    user-select: none;
}
.title-bar h1 {
    font-size: 12px;
    font-weight: bold;
    font-family: var(--font-body);
}
.title-bar-icon { margin-right: 4px; font-size: 14px; }
.win-buttons { display: flex; gap: 2px; }
.win-btn {
    width: 16px;
    height: 14px;
    background: var(--bg);
    border: 2px solid;
    border-color: var(--bevel-out);
    font-size: 8px;
    line-height: 10px;
    text-align: center;
    cursor: default;
    color: var(--fg);
    font-family: var(--font-body);
    font-weight: bold;
}
.win-btn:active {
    border-color: var(--bevel-in);
    transform: translate(1px, 1px);
}

/* ---- Menu Bar ---- */
.menu-bar {
    background: var(--bg);
    border-bottom: 2px solid;
    border-color: var(--muted);
    padding: 1px 2px;
    display: flex;
    gap: 0;
    font-size: 12px;
}
.menu-item {
    padding: 2px 8px;
    cursor: pointer;
    color: var(--fg);
    text-decoration: none;
}
.menu-item:hover { background: var(--navy); color: var(--white); }
.menu-item.back-link {
    color: var(--blue);
    text-decoration: underline;
}
.menu-item.back-link:hover { color: var(--red); }

/* ---- Filter Tabs (Win95 Property Sheet Tabs) ---- */
.filter-bar {
    background: var(--bg);
    padding: 6px 6px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid var(--fg);
}
.filter-tab {
    padding: 3px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    color: var(--fg);
    background: var(--bg);
    border: 2px solid;
    border-color: var(--white) var(--muted) var(--bg) var(--white);
    border-bottom: 2px solid var(--fg);
    margin-bottom: -2px;
    position: relative;
    font-family: var(--font-body);
}
.filter-tab:hover { background: #d4d4d4; }
.filter-tab.active {
    background: var(--bg);
    border-color: var(--white) var(--muted) var(--bg) var(--white);
    border-bottom: 2px solid var(--bg);
    z-index: 2;
}
.filter-tab .count { font-weight: normal; }
.filter-tab .new-badge {
    color: var(--red);
    font-size: 9px;
    font-weight: bold;
    animation: blink-new 1s step-end infinite;
    margin-left: 2px;
}

/* ---- Hazard Stripe ---- */
.hazard-stripe {
    height: 10px;
    background: repeating-linear-gradient(45deg, var(--bright-yellow), var(--bright-yellow) 10px, var(--fg) 10px, var(--fg) 20px);
}

/* ---- Groove HR ---- */
.hr-groove {
    border: none;
    height: 4px;
    background: linear-gradient(to bottom, var(--muted) 0%, var(--muted) 50%, var(--white) 50%, var(--white) 100%);
    margin: 4px 0;
}

/* ---- Progress Bar (Win95 Style) ---- */
.progress-bar {
    height: 20px;
    background: var(--white);
    border: 2px solid;
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
    margin: 2px 6px;
    display: none;
}
.progress-bar.active { display: block; }
.progress-fill {
    height: 100%;
    background: repeating-linear-gradient(90deg, var(--navy), var(--navy) 10px, #4444AA 10px, #4444AA 12px);
    width: 0%;
    transition: width 0.3s linear;
}

/* ---- Main Layout ---- */
.main-content {
    display: flex;
    height: calc(100vh - 100px);
    gap: 0;
    padding: 4px;
}

/* ---- Left Panel ---- */
.left-panel {
    width: 270px;
    min-width: 270px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---- Group Box (Win95 GroupBox) ---- */
.group-box {
    border: 2px solid;
    border-color: var(--white) var(--muted) var(--muted) var(--white);
    padding: 12px 8px 8px;
    position: relative;
    background: var(--bg);
}
.group-box .group-title {
    position: absolute;
    top: -8px;
    left: 8px;
    background: var(--bg);
    padding: 0 4px;
    font-size: 11px;
    font-weight: bold;
    color: var(--fg);
}

/* ---- Textarea ---- */
textarea#numberInput {
    width: 100%;
    height: 80px;
    border: 2px solid;
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
    padding: 4px;
    font-size: 13px;
    font-family: var(--font-mono);
    background: var(--white);
    resize: vertical;
    color: var(--fg);
}
textarea#numberInput:focus { outline: 2px dotted var(--fg); outline-offset: 2px; }

/* ---- Buttons (Win95 3D Bevel) ---- */
.btn-row { display: flex; gap: 4px; margin-top: 4px; }
.btn {
    padding: 4px 12px;
    border: 2px solid;
    border-color: var(--bevel-out);
    box-shadow: var(--shadow-out);
    background: var(--bg);
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font-body);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
    text-align: center;
    min-height: 23px;
    color: var(--fg);
    transition: none;
}
.btn:active {
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
    transform: translate(1px, 1px);
}
.btn:focus-visible { outline: 2px dotted var(--fg); outline-offset: 2px; }
.btn:disabled { color: var(--muted); text-shadow: 1px 1px var(--white); cursor: default; }
.btn.primary {
    background: var(--navy);
    color: var(--white);
    border-color: #5555ff #000060 #000060 #5555ff;
}
.btn.primary:active { border-color: #000060 #5555ff #5555ff #000060; }
.btn.danger {
    background: #CC0000;
    color: var(--white);
    border-color: #ff5555 #800000 #800000 #ff5555;
}
.btn.danger:active { border-color: #800000 #ff5555 #ff5555 #800000; }
.btn.warning {
    background: #CC8800;
    color: var(--white);
    border-color: #ffcc55 #664400 #664400 #ffcc55;
}
.btn.success {
    background: var(--green-dark);
    color: var(--white);
    border-color: #00ff00 #006600 #006600 #00ff00;
}
.btn.success:active { border-color: #006600 #00ff00 #00ff00 #006600; }
.btn.sm { padding: 2px 8px; font-size: 10px; min-height: 20px; }

/* ---- Search ---- */
.search-row { display: flex; gap: 4px; }
.search-row input {
    flex: 1;
    padding: 3px 4px;
    border: 2px solid;
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
    font-size: 12px;
    font-family: var(--font-body);
    background: var(--white);
}
.search-row input:focus { outline: 2px dotted var(--fg); outline-offset: 2px; }
.search-row input::placeholder { color: var(--muted); }

/* ---- Console (DOS Terminal) ---- */
.log-panel {
    flex: 1;
    background: var(--fg);
    border: 2px solid;
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
    padding: 4px 6px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--green);
    min-height: 80px;
}
.log-entry { margin-bottom: 1px; line-height: 1.5; }
.log-time { color: var(--muted); }
.log-msg { color: var(--green); }

/* ---- Center Panel (Data Grid) ---- */
.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 4px;
    background: var(--white);
    border: 2px solid;
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
}
.table-wrapper { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
thead { position: sticky; top: 0; z-index: 10; }
th {
    background: var(--bg);
    border: 2px solid;
    border-color: var(--white) var(--muted) var(--muted) var(--white);
    padding: 3px 6px;
    font-weight: bold;
    text-align: left;
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
}
th.cb-col { width: 24px; text-align: center; }
td {
    border-bottom: 1px solid #E0E0E0;
    border-right: 1px solid #E0E0E0;
    padding: 2px 6px;
    vertical-align: middle;
}
/* Alternating rows */
tbody tr:nth-child(even) { background: #E8E8E8; }
tbody tr:nth-child(odd) { background: var(--white); }
tbody tr:hover { background: var(--navy) !important; color: var(--white) !important; }
tbody tr:hover td { color: inherit; }
td.cb-col { text-align: center; }
td.status-col { font-weight: bold; font-size: 10px; text-transform: uppercase; }
td.query-status { font-weight: bold; text-align: center; font-size: 10px; }
td.detail-col {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
}
.empty-state {
    text-align: center;
    padding: 40px 20px;
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--muted);
}

/* ---- Right Panel ---- */
.right-panel {
    width: 96px;
    min-width: 96px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.right-panel .btn { flex: none; font-size: 10px; padding: 3px 4px; }
.right-panel .spacer { flex: 1; }

/* ---- Status Bar (Win95 Bottom) ---- */
.status-bar {
    background: var(--bg);
    border-top: 2px solid;
    border-color: var(--white) transparent transparent var(--white);
    padding: 2px 4px;
    display: flex;
    gap: 4px;
    font-size: 11px;
}
.status-item {
    border: 1px solid;
    border-color: var(--muted) var(--white) var(--white) var(--muted);
    padding: 1px 6px;
}
.status-item:first-child { flex: 2; }
.status-item:not(:first-child) { flex: 1; }
.status-item.running { color: var(--green-dark); font-weight: bold; }

/* ---- Hit Counter ---- */
.hit-counter {
    background: var(--fg);
    border: 2px solid;
    border-color: var(--bevel-in);
    box-shadow: var(--shadow-in);
    padding: 4px 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--green);
    text-align: center;
    display: inline-block;
}

/* ---- Rainbow Text ---- */
.rainbow-text { animation: rainbow 4s linear infinite; font-weight: bold; }

/* ---- Blink Badge ---- */
.blink { animation: blink-new 1s step-end infinite; }
.badge-new {
    background: var(--red);
    color: var(--white);
    font-size: 9px;
    font-weight: bold;
    padding: 1px 4px;
    font-family: var(--font-body);
    animation: pulse-glow 1.5s ease-in-out infinite;
    display: inline-block;
}

/* ---- File Input ---- */
#fileInput { display: none; }

/* ---- Links ---- */
a { color: var(--blue); text-decoration: underline; }
a:visited { color: var(--purple); }
a:hover { color: var(--red); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .main-content { flex-direction: column; height: auto; min-height: 100vh; }
    .left-panel { width: 100%; min-width: 0; max-height: 300px; }
    .right-panel { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; }
    .right-panel .spacer { display: none; }
    .center-panel { margin: 4px 0; min-height: 400px; }
}
