/* ══════════════════════════════════════════════════════════
   IT Enterprise Design System — Components
   /opt/shared-ui/static/components.css
   Reusable UI primitives. Depends on tokens.css.
   Mirrors the embedded styles previously inlined in
   base_unified.html (extracted 2026-04-28).
   ══════════════════════════════════════════════════════════ */

/* ── Reset ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ══════════════ Card ══════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
}
.card-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: var(--space-4); }

/* ══════════════ Tile / Stat card ══════════════ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}
.stat-card, .tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    text-align: center;
}
.stat-card .num, .tile .num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-card .label, .tile .label { font-size: 11px; color: var(--text2); }

/* ══════════════ Buttons ══════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    min-height: var(--tap-min);
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { opacity: 0.9; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(248,81,73,0.1); }

/* Icon button — token drives min-size; on touch (coarse pointer) it auto-rises to 44px */
.icon-btn {
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text2);
    padding: 4px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
}
.icon-btn:hover { color: var(--text); background: var(--border); }

/* ══════════════ Badges & dots ══════════════ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-ok, .badge-green  { background: rgba(63,185,80,0.15);  color: var(--green); }
.badge-err, .badge-red   { background: rgba(248,81,73,0.15);  color: var(--red); }
.badge-warn, .badge-yellow { background: rgba(210,153,34,0.15); color: var(--yellow); }
.badge-blue              { background: rgba(88,166,255,0.15); color: var(--blue); }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    vertical-align: middle;
}
.dot-green  { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.dot-red    { background: var(--red);    box-shadow: 0 0 6px var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-gray   { background: var(--text2); }

/* ══════════════ Tables ══════════════ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left;
    padding: 6px 10px;
    color: var(--text2);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(255,255,255,0.02); }

/* ══════════════ Forms ══════════════ */
.form-group { margin-bottom: var(--space-3); }
.form-group label { display: block; color: var(--text2); font-size: 12px; margin-bottom: 4px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    font-size: 13px;
    min-height: var(--tap-min);
}
.form-group input:focus,
.form-group textarea:focus { outline: none; border-color: var(--cyan); }

/* ══════════════ Toast ══════════════ */
.toast-container {
    position: fixed;
    top: 60px;
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
    min-width: 250px;
    max-width: 400px;
}
.toast.toast-ok   { border-left: 3px solid var(--green); }
.toast.toast-err  { border-left: 3px solid var(--red); }
.toast.toast-warn { border-left: 3px solid var(--yellow); }
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }

/* ══════════════ Utilities ══════════════ */
.mono { font-family: var(--font-mono); font-size: 12px; }
.text-muted { color: var(--text2); }
.text-sm { font-size: 12px; }
.flex-center { display: flex; align-items: center; gap: 6px; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--text2); padding: 2rem; }
.container { max-width: 1400px; margin: 0 auto; }

/* ══════════════ Tooltip ══════════════ */
.tip { position: relative; cursor: default; }
.tip .tip-content {
    display: none;
    position: fixed;
    z-index: var(--z-tooltip);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
    max-width: 90vw;
}
.tip:hover .tip-content,
.tip.tip-active .tip-content { display: block; }

/* ══════════════ Modal ══════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: var(--z-modal);
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-overlay.show { display: flex; }
body.modal-open { overflow: hidden; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    max-width: min(680px, 95vw);
    width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal h3 { margin-bottom: var(--space-4); font-size: 16px; }
.modal label { display: block; color: var(--text2); font-size: 12px; margin-bottom: 4px; margin-top: var(--space-3); }
.modal input,
.modal select,
.modal textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    min-height: var(--tap-min);
}
.modal textarea { min-height: 80px; resize: vertical; }
.modal .modal-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-4);
}

/* ══════════════ Progress bars ══════════════ */
.hw-bar-wrap {
    width: 60px; height: 6px;
    background: var(--border);
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
}
.hw-bar { height: 100%; border-radius: 3px; min-width: 2px; }
.hw-bar-green  { background: var(--green); }
.hw-bar-yellow { background: var(--yellow); }
.hw-bar-red    { background: var(--red); }

/* ══════════════ Detail views ══════════════ */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text2); font-size: 13px; }
.detail-value { font-size: 13px; font-weight: 500; }

/* ══════════════ Action dropdown ══════════════ */
.action-menu { position: relative; display: inline-block; }
.action-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 50;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-width: 180px;
    padding: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.action-dropdown.show { display: block; }
.action-dropdown a,
.action-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-decoration: none;
    text-align: left;
    min-height: var(--tap-min);
}
.action-dropdown a:hover,
.action-dropdown button:hover { background: var(--border); text-decoration: none; }

/* ══════════════ Mobile overrides ══════════════ */
@media (max-width: 640px) {
    .detail-grid { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .btn, .icon-btn { min-height: 44px; min-width: 44px; }
}
