/* Dim toggle button character/icon when off */
.action-link.toggle-off {
    color: var(--muted-text, #6e6e73) !important;
    background: transparent;
    box-shadow: none;
    text-shadow: none;
    transition: color 0.2s, box-shadow 0.2s, background 0.2s, text-shadow 0.2s;
}
/* Red highlight for pause button when paused */
#pause.is-paused {
    color: #fff;
    background: linear-gradient(90deg, #ffe5e5 0%, #ffd6d6 100%);
    box-shadow: 0 0 0 1.5px #ffb3b3, 0 0 6px #ffd6d6;
    border-radius: 8px;
    text-shadow: 0 0 4px #ffb3b3;
}
/* Toast notification styling */
/* #toast rules moved to content.css for bottom-right positioning */
/* Stylized divider for toolbar */
.toolbar-divider {
    display: inline-block;
    width: 1px;
    height: 28px;
    margin: 0 -4px;
    background: linear-gradient(to bottom, #e0e6ef 10%, #bfc9d8 50%, #e0e6ef 90%);
    border-radius: 2px;
    vertical-align: middle;
    opacity: 0.7;
}
/* ========================================
   VINE MONITOR - HEADER & CONTROLS STYLING
   Modern Apple-inspired UI design
   ======================================== */

/* Color palette (matches system.shade defaults) */
:root {
        --header-height: 56px;
        --toolbar2-height: 40px;
        --latestlogline-height: 24px;
    --bg: #f5f5f7;
    --surface: #ffffff;
    --border: #e5e5e7;
    --text: #1d1d1f;
    --muted-text: #6e6e73;
    --primary: #0071e3;
    --primary-hover: #449aef;
    --danger: #fb160a;
    --danger-hover: #fc1606b6;
    --success: #34c759;
    --muted-surface: #f2f2f3;
    --glass: rgba(0,0,0,0.06);
}

/* Main page layout: header + content + footer */
body {
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--surface);
    color: var(--text);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

/* ========================================
   HEADER SECTION
   ======================================== */

#header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    z-index: 1000;
    min-height: var(--header-height, 44px);
    height: auto;
    padding-top: 2px;
    padding-bottom: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    justify-content: center;
    flex-direction: row;
    flex-wrap: wrap;
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

/* Header warning state - login issues */
#header.login-warning {
    background: linear-gradient(180deg, #ffe49a 0%, #fff4cc 100%);
    border-bottom: 2px solid #ffb300;
    box-shadow: inset 0 0 0 1px rgba(255, 179, 0, 0.45);
}

/* Header error state - critical issues */
#header.error-state {
    background: linear-gradient(180deg, #ffe0e0 0%, #fff0f0 100%);
    border-bottom: 2px solid #ff4444;
}

/* App title bar (fixed at top) */
#appTitle {
    position: fixed;
    top: 8px;
    left: 0;
    width: 100%;
    font-size: 14px;
    letter-spacing: 0.2px;
    padding: 4px 8px;
    color: #070707;
    white-space: nowrap;
    z-index: 9998;
}

/* Toolbar (center) */
#toolbar-1 {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    row-gap: 2px;
    padding: 0 0 0 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 0;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    min-height: 40px;
    height: auto;
    max-width: 100%;
    margin: 0;
}

/* Secondary Toolbar (center) */
#serverControlToolbar {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    row-gap: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 0;
    justify-content: center;
    align-items: center;
    width: fit-content;
    height: auto;
    max-width: 100%;
    margin: 0 0 0 auto;
}

#settingsCluster {
    margin-bottom: 0;
    padding-bottom: 0;
    align-self: center;
}

.toolbar-cluster {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 13px;
    flex-shrink: 0;
}

.toolbar-cluster select,
.toolbar-cluster input {
    font-size: 13px;
}

#toolbar-1 > *,
#serverControlToolbar > * {
    font-size: 13px;
}

#toolbar-1 > button,
#serverControlToolbar > button {
    margin: 0;
}

#toolbar-1 > label,
#serverControlToolbar > label {
    margin: 0;
}

/* ========================================
   CONTROL BUTTONS SECTION
   ========================================  */

#controls {
    display: none;
}

/* Button group container (rounded pill shape) */
.toolbar-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(148, 163, 184, 0.06);
    border: 1px solid var(--border);
    border-radius: 999px;
    flex: 0 0 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: visible;
    height: 28px;
}

.toolbar-group > * {
    flex-shrink: 0;
    min-width: auto;
    height: 100%;
    display: flex;
    align-items: center;
}

.toolbar-group-actions {
    padding: 4px 6px;
    gap: 4px;
    margin: 0;
}

#toolbar-1,
#serverControlToolbar {
    padding-left: 6px;
    padding-right: 6px;
}

.btn {
    padding: 6px 9px;
    border: 1px solid var(--border);
    outline: none;
    background: var(--muted-surface);
    color: var(--text);
    cursor: pointer;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
    user-select: none;
}

.btn:hover {
    background: #f0f4fb;
    border-color: var(--primary);
}

.btn:active {
    transform: translateY(0.5px);
}

.btn:focus-visible {
    box-shadow: var(--ring);
}

.btn-primary {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
}
.btn-primary:hover {
    background: rgba(34, 197, 94, 0.26);
}

.btn-secondary {
    background: #e6f0fa;
    color: #007AFF;
    border-color: transparent;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 122, 255, 0.07);
}
.btn-secondary:hover {
    background: #d0e7fa;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.12);
    transform: translateY(-1px);
}

.btn-danger {
    background: #faeaea;
    color: #FF3B30;
    border-color: transparent;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(255, 59, 48, 0.07);
}
.btn-danger:hover {
    background: #f5d6d3;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.12);
    transform: translateY(-1px);
}

.btn-settings {
    background: #ffffff;
    border-color: #ededee;
}
.btn-settings:hover {
    background: #f2f0f0;
    border-color: var(--primary);
}

#searchWrapper {
    display: flex;
    align-items: center;
    position: relative;
}

#search {
    width: 140px;
    max-width: min(180px, 30vw);
    padding: 7px 26px 7px 9px;
    border-radius: 10px;
    border: 1px solid var(--border);
    outline: none;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    transition: all 0.2s;
}

#search:focus-visible {
    box-shadow: var(--ring);
}

#search.has-matches {
    background: rgba(52, 199, 89, 0.12);
    border-color: rgba(52, 199, 89, 0.4);
}

#search.no-matches {
    background: rgba(255, 59, 48, 0.12);
    border-color: rgba(255, 59, 48, 0.4);
}

#clearSearch {
    position: absolute;
    right: 6px;
    background: none;
    border: none;
    color: var(--muted-text);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
    line-height: 1;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    user-select: none;
}

#clearSearch:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

.grid-label {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
}

.grid-size-select {
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    outline: none;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.grid-size-select:hover {
    border-color: var(--primary);
}

.grid-size-select:focus-visible {
    box-shadow: var(--ring);
}

.filter-label {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
}

.filter-select,
.poll-interval-select {
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    outline: none;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.filter-select:hover,
.poll-interval-select:hover {
    border-color: var(--primary);
}

.filter-select:focus-visible,
.poll-interval-select:focus-visible {
    box-shadow: var(--ring);
}

.action-link {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
    font-size: 20px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: auto;
    height: auto;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    transition: color 120ms ease, background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
    user-select: none;
}

#top,
#bottom,
#pause,
#btnCheckNow,
#scrollFlagged {
    font-size: 20px;
}

#btnTurbo,
#btnServerInfo,
#btnDebugToggle,
#btnResetToggle {
    font-size: 17px;
}

.action-link.toggle-link {
    position: relative;
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 15px;
    min-width: 26px;
    min-height: 26px;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.action-link.is-active {
    color: #f59e0b;
    text-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.action-link.toggle-link.is-active:not(#pause),
.action-link.toggle-link.is-active:not(#pause):hover {
    color: #fef08a;
    background: rgba(34, 197, 94, 0.28);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.45), 0 0 14px rgba(34, 197, 94, 0.55);
    transform: translateY(-1px) scale(1.05);
    text-shadow: 0 0 10px rgba(254, 240, 138, 0.75);
}

.action-link:hover {
    color: var(--primary-hover);
    text-decoration: none;
    background: rgba(0, 113, 227, 0.08);
    box-shadow: 0 1px 2px var(--glass);
    transform: translateY(-1px);
}

.action-link:active {
    color: var(--primary-hover);
    transform: translateY(0);
    box-shadow: none;
}

.action-link:focus-visible {
    box-shadow: var(--ring);
}

#scrollFlagged.has-new-items {
    animation: scroll-flagged-beacon 1.8s ease-in-out infinite;
    color: #166534;
    background: linear-gradient(180deg, rgba(240, 253, 244, 0.98) 0%, rgba(220, 252, 231, 0.98) 100%);
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.28), 0 0 0 1px rgba(34, 197, 94, 0.12), 0 0 8px rgba(34, 197, 94, 0.16);
    border-radius: 8px;
    font-weight: 700;
    text-shadow: none;
}

@keyframes scroll-flagged-beacon {
    0%, 100% {
        filter: brightness(1);
        box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.28), 0 0 0 1px rgba(34, 197, 94, 0.12), 0 0 8px rgba(34, 197, 94, 0.16);
        background: linear-gradient(180deg, rgba(240, 253, 244, 0.98) 0%, rgba(220, 252, 231, 0.98) 100%);
        color: #166534;
    }
    50% {
        filter: brightness(1.08);
        box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.48), 0 0 0 4px rgba(134, 239, 172, 0.34), 0 0 18px rgba(34, 197, 94, 0.3);
        background: linear-gradient(180deg, rgba(236, 253, 245, 1) 0%, rgba(187, 247, 208, 1) 100%);
        color: #15803d;
    }
}
}

@media (max-width: 900px) {
    #header {
        align-items: center;
        justify-content: center;
    }
    #controls {
        justify-content: center;
    }
    #searchWrapper {
        min-width: 150px;
    }
    #search {
        width: 180px;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    #header {
        padding: 6px;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
    }
    #toolbar-1,
    #serverControlToolbar {
        position: relative;
        left: auto;
        transform: none;
        width: 100%;
        display: flex;
        gap: 2px;
        padding: 4px;
        margin: 0;
        order: 1;
        justify-content: center;
        font-size: 0;
    }
    #toolbar-1 > *,
    #serverControlToolbar > * {
        font-size: 12px;
    }
    #toolbar-1 .btn,
    #serverControlToolbar .btn {
        padding: 5px;
        font-size: 12px;
    }
    .toolbar-group {
        gap: 2px;
        padding: 5px;
        font-size: 12px;
    }
    #controls {
        width: 100%;
        margin: 0;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        order: 2;
    }
}

/* Header collapse/expand styles */
#header {
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    max-height: 500px;
    opacity: 1;
    visibility: visible;
    overflow: hidden;
}

body.header-collapsed #header,
body.header-collapsed #item-counts {
    display: none;
}

#btnToggleHeader {
    transition: transform 0.3s ease-in-out;
}

body.header-collapsed #btnToggleHeader {
    transform: rotate(180deg);
}

/* Latest log line display */
.latest-log-line {
    flex: 0 0 auto;
    width: 100%;
    padding: 4px 8px;
    background: var(--muted-surface);
    font-size: 12px;
    font-family: Arial, sans-serif;
    font-style: italic;
    color: var(--text);
    font-weight: 300;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    border-top: 1px solid var(--border);
    transition: all 0.3s ease;
}

.latest-log-line.login-issue {
    background: #fff3cd;
    color: #856404;
    font-weight: 300;
    border-top: 2px solid #ffc107;
}

.latest-log-line.error-issue {
    background: #ffe0e0;
    color: #d32f2f;
    font-weight: 300;
    border-top: 2px solid #ff4444;
}

/* Login Warning Overlay */
.login-warning-overlay {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    pointer-events: none;
}

.login-warning-content {
    position: relative;
    background: linear-gradient(135deg, #fff3cd 0%, #fff8e1 100%);
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 20px 50px 20px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 193, 7, 0.2);
    min-width: 400px;
    max-width: 600px;
    pointer-events: auto;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-dismiss-warning {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 20px;
    color: #856404;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-dismiss-warning:hover {
    background: rgba(133, 100, 4, 0.1);
    color: #533f03;
}

.login-warning-icon {
    font-size: 32px;
    text-align: center;
    margin-bottom: 10px;
}

.login-warning-title {
    font-size: 18px;
    font-weight: 700;
    color: #856404;
    text-align: center;
    margin-bottom: 8px;
}

.login-warning-message {
    font-size: 14px;
    color: #856404;
    text-align: center;
    line-height: 1.5;
}

/* Process Warning Overlay */
.process-warning-overlay {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9997;
    pointer-events: none;
}

.process-warning-content {
    position: relative;
    background: linear-gradient(135deg, #ffe0e0 0%, #fff0f0 100%);
    border: 2px solid #ff4444;
    border-radius: 12px;
    padding: 20px 50px 20px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 68, 68, 0.2);
    min-width: 350px;
    max-width: 500px;
    pointer-events: auto;
    animation: slideDown 0.3s ease-out;
}

.process-warning-icon {
    font-size: 32px;
    text-align: center;
    margin-bottom: 10px;
}

.process-warning-title {
    font-size: 18px;
    font-weight: 700;
    color: #d32f2f;
    text-align: center;
    margin-bottom: 8px;
}

.process-warning-message {
    font-size: 14px;
    color: #d32f2f;
    text-align: center;
    line-height: 1.5;
    margin-bottom: 12px;
}

.btn-restart-warning {
    display: block;
    margin: 0 auto;
    padding: 8px 16px;
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-restart-warning:hover {
    background: #b71c1c;
}

.vine-stopped {
    background: linear-gradient(90deg, #ffe5e5 0%, #ffd6d6 100%);
    color: #b30000 !important;
    box-shadow: 0 0 0 1.5px #ffb3b3, 0 0 6px #ffd6d6;
    border-radius: 8px;
    text-shadow: 0 0 4px #ffb3b3;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s, text-shadow 0.2s;
}