/* DAQ MAP web client */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #1a1a1a;
    background: #f4f4f6;
}

#app { height: 100%; }

h1:focus { outline: none; }

/* ---- loading splash (template) ---- */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}
.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: #512BD4;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto 0.2rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 3000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ---- app shell ---- */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

.topbar {
    display: flex;
    align-items: center;
    gap: 18px;
    background: #2d2440;
    color: #fff;
    padding: 0 16px;
    height: 48px;
    flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: 1px; }
.topnav { display: flex; gap: 4px; }
.topnav a {
    color: #cfc8e8;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
}
.topnav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.topnav a.active { background: #512BD4; color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.session-chip {
    background: rgba(255,255,255,0.15);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.online-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.online-dot.on { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.online-dot.off { background: #e74c3c; box-shadow: 0 0 6px #e74c3c; }

.app-main { flex: 1 1 auto; min-height: 0; }

/* ---- map page ---- */
.map-page { display: flex; flex-direction: column; height: 100%; }

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border-bottom: 1px solid #ddd;
    padding: 8px 14px;
    flex: 0 0 auto;
    flex-wrap: wrap;
}
.stats-left { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.stats-right { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }

.map-wrap { display: flex; flex: 1 1 auto; min-height: 0; position: relative; }

.grid-panel {
    width: 230px;
    flex: 0 0 auto;
    background: #ffffff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 8px;
}
.grid-panel h4 { margin: 0; }
.grid-panel-header { display: flex; justify-content: space-between; align-items: center; }
.panel-toggle {
    border: 1px solid #ccc;
    background: #fafafa;
    border-radius: 6px;
    width: 30px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.panel-toggle:hover { background: #eee; }

.panel-open-btn {
    position: absolute;
    top: 84px;
    left: 12px;
    z-index: 1000;
    background: #ffffff;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 1px 6px rgba(0,0,0,0.25);
}
.panel-open-btn:hover { background: #f2f2f2; }
.grid-list { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }

.grid-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    background: #fff;
}
.grid-item:hover { border-color: #b39ddb; }
.grid-item.selected { border-color: #512BD4; background: #ede7fb; }
.grid-item-name { font-weight: 600; }
.grid-item-sub { font-size: 12px; color: #777; margin: 2px 0 6px 0; }
.grid-item-actions { display: flex; gap: 4px; }
.grid-item-actions button {
    border: 1px solid #ccc;
    background: #fafafa;
    border-radius: 5px;
    width: 26px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}
.grid-item-actions button:hover { background: #eee; }
.grid-item-actions button.danger { color: #C0392B; }

.map-host { position: relative; flex: 1 1 auto; min-width: 0; }
#daqmap { position: absolute; inset: 0; }

.map-banner {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
}
.map-banner.exclusion { background: rgba(192, 57, 43, 0.9); font-weight: 600; }
.map-banner.busy { background: rgba(81, 43, 212, 0.9); }

.map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 70vw;
    gap: 6px;
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.25);
}
.map-controls .ctl {
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 13px;
}
.map-controls .ctl.active { background: #512BD4; color: #fff; border-color: #512BD4; }
.map-controls .ctl.active.danger { background: #C0392B; border-color: #C0392B; }

.no-session-overlay {
    position: absolute;
    inset: 0;
    z-index: 1100;
    background: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}
.no-session-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.25);
    padding: 26px 34px;
    width: 340px;
    text-align: center;
}
.no-session-card h3 { margin-top: 0; }

.bottom-bar {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: #ffffff;
    border-top: 1px solid #ddd;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

/* ---- buttons ---- */
.btn {
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 14px;
}
.btn.primary { background: #512BD4; color: #fff; }
.btn.primary:hover { background: #4023a8; }
.btn.primary.bold { font-weight: 700; }
.btn.gray { background: #757575; color: #fff; }
.btn.danger { background: #C0392B; color: #fff; }
.btn.flat { background: #f0f0f2; color: #333; }
.btn.flat:hover { background: #e2e2e6; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* label-wrapped file input styled as a button */
.file-btn { cursor: pointer; display: inline-block; }
.file-btn input[type="file"] { display: none; }
.file-btn-disabled { opacity: 0.45; pointer-events: none; }

.muted { color: #777; }
.pad { padding: 10px; }

/* ---- map overlay labels (leaflet divIcons) ---- */
.daq-grid-name span {
    background: rgba(0,0,0,0.75);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.daq-area-no span {
    color: #C82828;
    font-weight: 700;
    font-size: 12px;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
/* 0x0 flex container centers the overflowing span exactly on the marker point */
.daq-cell-label { display: flex; align-items: center; justify-content: center; }
.daq-cell-label span {
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    white-space: nowrap;
    display: inline-block;
}

/* ---- cell entry modal ---- */
.modal-backdrop-daq {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cell-modal {
    background: #fff;
    border-radius: 14px;
    padding: 18px 22px;
    width: 400px;
    max-width: 94vw;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 6px 30px rgba(0,0,0,0.35);
}
.cell-modal h3 { margin: 0 0 10px 0; text-align: center; }
.cell-modal label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px 0; }
.cell-modal input[type="text"], .cell-modal input:not([type]), .cell-modal textarea {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 14px;
}
.cell-modal .check-row { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-top: 12px; }
.cell-modal .check-row input { width: auto; }

.cell-preview {
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    text-align: center;
    padding: 12px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.quick-row { display: flex; gap: 4px; margin-top: 5px; }
.quick-row .quick {
    flex: 1;
    border: none;
    border-radius: 5px;
    color: #fff;
    padding: 6px 0;
    cursor: pointer;
    font-size: 12px;
}
.quick-row .quick.pass { background: #1B8A3A; }
.quick-row .quick.fail { background: #C0392B; }
.quick-row .quick:disabled { opacity: 0.4; }

.error-text { color: #C0392B; font-size: 12px; margin-top: 8px; }

.modal-buttons { display: flex; gap: 8px; margin-top: 16px; }
.modal-buttons .btn { flex: 1; }

/* ---- sessions page ---- */
.sessions-page { padding: 20px; max-width: 900px; margin: 0 auto; }
.sessions-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.sessions-header h2 { margin: 0; }
.sessions-header .btn { margin-left: 6px; }

.sync-message {
    background: #ede7fb;
    border: 1px solid #b39ddb;
    color: #3a2e5c;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 12px 0;
}

.session-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.session-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
}
.session-card:hover { border-color: #512BD4; }
.session-card-name { font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.session-card-sub { margin-top: 3px; }
.session-card-right { display: flex; align-items: center; gap: 12px; }

.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}
.badge.warn { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.badge.info { background: #d6e4ff; color: #1d4ed8; border: 1px solid #b6ccfa; }

@media (max-width: 760px) {
    /* On phones the open panel overlays the map instead of squeezing it */
    .grid-panel {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 240px;
        z-index: 1300;
        box-shadow: 4px 0 16px rgba(0,0,0,0.25);
    }
    .stats-bar { font-size: 12px; }
    .bottom-bar { gap: 4px; padding: 6px 4px; }
    .bottom-bar .btn { padding: 8px 10px; font-size: 12px; }
}
