/* ============================================================
   ATLAS — Sub-Pool Manager styles
   WP04 — FR-008 / FR-011
   Uses CSS custom properties from styles.css (light + dark themes).
   ============================================================ */

/* ------------------------------------------------------------------
   Sub-Pool section layout
   ------------------------------------------------------------------ */

#sub-pools-section {
    padding: var(--spacing-lg);
}

.sp-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.sp-page-header h2 {
    margin: 0 0 0.25rem;
    font-size: var(--font-size-2xl);
    color: var(--text-primary);
}

.sp-page-header .subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ------------------------------------------------------------------
   Pool list
   ------------------------------------------------------------------ */

#sp-pool-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.sp-pool-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.sp-pool-card:hover {
    background: var(--surface-hover, var(--surface));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sp-pool-card--active {
    border-color: var(--primary, #2175d9);
    background: rgba(33, 117, 217, 0.05);
}

[data-theme="dark"] .sp-pool-card--active {
    background: rgba(33, 117, 217, 0.10);
}

/* Card body — name + count + badge */
.sp-pool-card-body {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1 1 auto;
    min-width: 0;
}

.sp-pool-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.sp-pool-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 28ch;
}

.sp-pool-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Active badge */
.sp-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.2em 0.65em;
    background: rgba(33, 117, 217, 0.15);
    color: var(--primary, #2175d9);
    border: 1px solid rgba(33, 117, 217, 0.3);
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

.sp-active-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

[data-theme="dark"] .sp-active-badge {
    background: rgba(33, 117, 217, 0.25);
    border-color: rgba(33, 117, 217, 0.45);
    color: #6aabf7;
}

/* ------------------------------------------------------------------
   Action buttons
   ------------------------------------------------------------------ */

.sp-pool-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.sp-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.8rem;
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    background: none;
    white-space: nowrap;
}

/* Toggle-active button */
.sp-btn--toggle {
    color: var(--text-secondary);
    border-color: var(--border);
    background: var(--surface);
}

.sp-btn--toggle:hover {
    color: var(--primary, #2175d9);
    border-color: var(--primary, #2175d9);
}

.sp-btn--toggle-active {
    color: var(--primary, #2175d9);
    border-color: var(--primary, #2175d9);
    background: rgba(33, 117, 217, 0.08);
}

.sp-btn--toggle-active:hover {
    background: rgba(33, 117, 217, 0.14);
}

/* Rename button */
.sp-btn--rename {
    color: var(--text-secondary);
    border-color: var(--border);
    background: var(--surface);
}

.sp-btn--rename:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Delete button */
.sp-btn--delete {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.05);
}

.sp-btn--delete:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
}

/* Primary (create) button — uses existing .btn .btn-primary tokens */
.sp-btn--primary {
    background: var(--primary, #2175d9);
    color: #fff;
    border-color: var(--primary, #2175d9);
    padding: 0.55rem 1.1rem;
    font-size: var(--font-size-sm);
    border-radius: var(--border-radius);
}

.sp-btn--primary:hover {
    opacity: 0.9;
}

/* ------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------ */

.sp-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--border-radius);
}

.sp-empty-state svg {
    opacity: 0.45;
}

.sp-empty-state p {
    margin: 0;
    font-size: var(--font-size-sm);
}

.sp-empty-hint {
    color: var(--text-muted);
    font-size: var(--font-size-xs) !important;
}

/* ------------------------------------------------------------------
   Create-pool modal
   ------------------------------------------------------------------ */

#sp-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.sp-modal-box {
    background: var(--surface-elevated, var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.sp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
}

.sp-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--text-primary);
}

.sp-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-muted);
    padding: 0 0.25rem;
    transition: color 0.15s ease;
}

.sp-modal-close:hover {
    color: var(--text-primary);
}

.sp-modal-body .form-group {
    margin-bottom: var(--spacing-md);
}

.sp-modal-body label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.sp-modal-body input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.sp-modal-body input[type="text"]:focus {
    outline: none;
    border-color: var(--primary, #2175d9);
    box-shadow: 0 0 0 2px rgba(33, 117, 217, 0.15);
}

.sp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* ------------------------------------------------------------------
   Active-pool status indicator (nav bar)
   Mirrors .tender-request-status from styles.css
   ------------------------------------------------------------------ */

#sp-active-pool-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius);
    background: rgba(33, 117, 217, 0.08);
    border: 1px solid rgba(33, 117, 217, 0.2);
    white-space: nowrap;
    font-size: var(--font-size-sm);
    height: fit-content;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

#sp-active-pool-status.hidden {
    display: none;
}

.sp-indicator-label {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: var(--font-size-xs);
}

.sp-indicator-name {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: var(--font-size-sm);
    /* Truncate a long pool name so the pill can share the nav row instead of
       forcing a wrap. Full name is on the element title (set by sub-pool-manager). */
    min-width: 0;
    max-width: min(100px, 11vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-indicator-count {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

[data-theme="dark"] #sp-active-pool-status {
    background: rgba(33, 117, 217, 0.14);
    border-color: rgba(33, 117, 217, 0.3);
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 640px) {
    .sp-pool-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .sp-pool-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .sp-page-header {
        flex-direction: column;
    }
}
