/* ===================================================
   ATHENA REUSABLE COMPONENTS
   Unified design system based on SavedPlans pattern
   =================================================== */

/* --- Panel --- */
.ath-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.ath-panel-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    cursor: pointer;
    transition: background 0.15s;
}
.ath-panel-header:hover {
    background: rgba(255,255,255,0.04);
}

/* --- Table --- */
.ath-table {
    width: 100%;
    font-size: 0.7rem;
    border-collapse: collapse;
    color: var(--text-primary);
}

.ath-table-head {
    position: sticky;
    top: 0;
    z-index: 2;
}

.ath-table-head tr {
    font-size: 0.62rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.ath-table-head th {
    padding: 5px 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-highlight) !important;
}

.ath-table tbody td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}

/* --- Rows --- */
.ath-row {
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ath-row:hover > td {
    background: rgba(255,255,255,0.03);
}
.ath-row-expanded > td {
    background: rgba(52,152,219,0.04);
}

/* Detail sub-row (expanded content) */
.ath-detail-row > td {
    padding: 0 !important;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-highlight) !important;
}

/* Sub-table row inside expanded detail */
.ath-sub-row {
    font-size: 0.68rem;
    background: var(--bg-dark);
    border-bottom: 1px solid rgba(255,255,255,0.02);
}
.ath-sub-row:hover > td {
    background: rgba(255,255,255,0.02);
}

/* Inline-editable habitat name */
.hab-name-editable {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: border-color 0.15s, color 0.15s;
    padding-bottom: 1px;
    margin-left: 4px;
}
.hab-name-editable:hover {
    border-bottom-color: var(--primary, #3498db);
    color: var(--text-primary, #e2e8f0);
}

/* --- Chevron --- */
.ath-chevron {
    font-size: 0.55rem;
    color: var(--text-muted);
    display: inline-block;
    transition: transform 0.15s;
    width: 12px;
    text-align: center;
}

/* --- Stat Card (refined) --- */
.ath-stat-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-surface) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    text-align: center;
    transition: border-color 0.15s;
}
.ath-stat-card:hover {
    border-color: var(--border-highlight);
}
.ath-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}
.ath-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Inline stat pill (used in headers) --- */
.ath-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
}
.ath-stat-pill-val {
    font-weight: 700;
}

/* --- Badge (small) --- */
.ath-badge {
    font-size: 0.55rem;
    vertical-align: middle;
    padding: 1px 5px;
    border-radius: 3px;
}

/* --- Progress --- */
.ath-progress {
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}
.ath-progress-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

/* --- Scrollable table container --- */
.ath-table-scroll {
    max-height: 70vh;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}

/* --- Resource bar (inline resource display) --- */
.ath-resource-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
}
.ath-resource-bar .ath-res-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.ath-resource-bar .ath-res-sep {
    color: var(--border);
    margin: 0 0.25rem;
}
.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

#components-reconnect-modal {
    background-color: var(--bg-card, #1c1d21);
    color: var(--text-primary, #e2e8f0);
    width: 22rem;
    margin: 20vh auto;
    padding: 2.5rem 2rem;
    border: 1px solid var(--border, #2d3748);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
    animation: components-reconnect-modal-fadeOutOpacity 0.4s both;
}

#components-reconnect-modal[open] {
    animation: components-reconnect-modal-slideUp 0.6s cubic-bezier(.05, .89, .25, 1.02) 0.1s, 
               components-reconnect-modal-fadeInOpacity 0.4s ease-in-out 0.1s;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: rgba(0, 0, 0, 0.85); /* Much darker overlay */
    backdrop-filter: blur(4px); /* Glassmorphism background blur */
    animation: components-reconnect-modal-fadeInOpacity 0.4s ease-in-out;
    opacity: 1;
}

@keyframes components-reconnect-modal-slideUp {
    0% { transform: translateY(40px) scale(0.95); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes components-reconnect-modal-fadeInOpacity {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes components-reconnect-modal-fadeOutOpacity {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
}

#components-reconnect-modal p {
    margin: 0;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
}

.text-danger {
    color: var(--danger, #ff4c4c) !important;
    font-weight: 500;
}

/* ================== LOGO & ANIMATION ================== */
.components-reconnect-logo-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem;
}

.components-reconnect-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    z-index: 2;
    filter: drop-shadow(0 0 12px rgba(52, 152, 219, 0.5));
    animation: components-reconnect-logo-pulse 2s ease-in-out infinite;
}

@keyframes components-reconnect-logo-pulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(52, 152, 219, 0.4)); }
    50% { transform: scale(1.08); filter: drop-shadow(0 0 18px rgba(52, 152, 219, 0.8)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(52, 152, 219, 0.4)); }
}

.components-rejoining-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    z-index: 1;
}

.components-rejoining-animation div {
    position: absolute;
    border: 2px solid rgba(52, 152, 219, 0.4);
    opacity: 1;
    border-radius: 50%;
    animation: components-rejoining-anim 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-rejoining-anim {
    0% { top: 60px; left: 60px; width: 0; height: 0; opacity: 0; }
    5% { top: 60px; left: 60px; width: 0; height: 0; opacity: 1; }
    100% { top: 0px; left: 0px; width: 120px; height: 120px; opacity: 0; }
}

/* ================== BUTTON ================== */
.athena-btn {
    border: 0;
    background-color: var(--primary, #3498db);
    color: white;
    padding: 8px 32px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.athena-btn:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
}

.athena-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}
