/* ================================================================
   Team Linking Dashboard — redesigned to match league-view aesthetic
   ================================================================ */

.team-linking-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

/* ----------------------------------------------------------------
   Hero / Header
   ---------------------------------------------------------------- */

.tl-hero {
    position: relative;
    overflow: hidden;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: var(--spacing-md);
}

.tl-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.tl-hero::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.tl-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;
}

.tl-hero-copy {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tl-kicker {
    color: var(--primary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    font-family: var(--font-mono);
}

.tl-hero-title {
    margin: 0;
    color: #ffffff;
    font-size: 19px;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    font-family: var(--font-mono);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.tl-hero-text,
.tl-section-copy,
.tl-group-description,
.tl-empty-state p,
.tl-field-hint,
.tl-team-item-meta,
.tl-action-text,
.tl-metric-note,
.tl-hero-status {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    font-family: var(--font-mono);
}

.tl-hero-actions,
.tl-toolbar,
.tl-group-actions,
.tl-link-actions,
.tl-season-actions,
.tl-chip-row,
.tl-modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.tl-hero-status {
    font-size: 13px;
}

.tl-hero-status .separator {
    margin: 0 6px;
    color: var(--text-muted);
}

/* ----------------------------------------------------------------
   Metrics Grid (inside hero)
   ---------------------------------------------------------------- */

.tl-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.tl-metric-card {
    position: relative;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tl-metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.tl-metric-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.tl-metric-card:hover {
    border-color: var(--primary);
}

.tl-metric-card:hover::before,
.tl-metric-card:hover::after {
    border-color: var(--primary);
}

.tl-metric-label,
.tl-links-header,
.tl-season-meta,
.tl-link-season,
.tl-context-label,
.tl-toolbar-count,
.tl-label,
.tl-season-stat span {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    font-family: var(--font-mono);
}

.tl-metric-value {
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    font-weight: 700;
    font-family: var(--font-mono);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.tl-metric-note {
    font-size: 11px;
    line-height: 1.35;
}

/* ----------------------------------------------------------------
   Context Banner
   ---------------------------------------------------------------- */

.tl-context-banner {
    margin: 14px 0;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 107, 74, 0.45);
    border-left: 3px solid var(--primary);
}

.tl-context-body {
    color: #eceff4;
    font-size: 14px;
    line-height: 1.5;
    font-family: var(--font-mono);
}

/* ----------------------------------------------------------------
   Workspace (sidebar rail + main content)
   ---------------------------------------------------------------- */

.tl-workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin-top: 16px;
}

.tl-rail,
.tl-main {
    min-width: 0;
}

/* ----------------------------------------------------------------
   Surface Cards (sidebar panels)
   ---------------------------------------------------------------- */

.tl-surface {
    position: relative;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    padding: 16px;
}

.tl-surface::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.tl-surface::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.tl-rail .tl-surface + .tl-surface {
    margin-top: 16px;
}

.tl-surface-header,
.tl-section-bar,
.tl-group-header,
.tl-season-top,
.tl-link-row,
.tl-team-item,
.tl-links-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ffffff;
    font-family: var(--font-mono);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ----------------------------------------------------------------
   Quick Action Cards (sidebar)
   ---------------------------------------------------------------- */

.tl-action-stack,
.tl-season-list,
.tl-link-list,
.tl-team-items {
    display: grid;
    gap: 8px;
}

.tl-action-stack {
    margin-top: 12px;
}

.tl-action-card,
.tl-season-card {
    width: 100%;
    text-align: left;
    cursor: pointer;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.tl-action-card:hover,
.tl-season-card:hover {
    border-color: var(--primary);
    background: var(--bg-elevated);
}

.tl-action-card span {
    display: block;
}

.tl-action-title {
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-mono);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.tl-action-text {
    margin-top: 4px;
    font-size: 12px;
}

.tl-group-title,
.tl-season-name,
.tl-empty-title,
.tl-team-item-title {
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-mono);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ----------------------------------------------------------------
   Season Cards (sidebar)
   ---------------------------------------------------------------- */

.tl-season-card.is-current {
    border-color: rgba(74, 222, 128, 0.55);
}

.tl-season-name {
    font-size: 14px;
}

.tl-season-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 10px 0;
}

.tl-season-stat {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tl-season-stat strong {
    display: block;
    margin-top: 4px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.tl-season-actions {
    gap: 6px;
}

/* ----------------------------------------------------------------
   Section Bar (above group grid)
   ---------------------------------------------------------------- */

.tl-section-bar {
    margin-bottom: 14px;
    align-items: end;
}

.tl-toolbar {
    gap: 10px;
    align-items: center;
}

.tl-filter-input {
    width: 280px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    border-radius: 0;
}

.tl-input,
.tl-select,
.tl-textarea {
    width: 100%;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 14px;
    border-radius: 0;
}

.tl-filter-input:focus,
.tl-input:focus,
.tl-select:focus,
.tl-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(255, 107, 74, 0.22);
}

.tl-toolbar-count {
    white-space: nowrap;
    font-size: 12px;
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */

.tl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    padding: 4px 12px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-mono);
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.tl-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-elevated);
}

.tl-btn-primary {
    border-color: var(--primary);
    color: var(--primary);
}

.tl-btn-primary:hover {
    background: var(--primary);
    color: #000000;
}

.tl-btn-danger {
    border-color: #5b2b32;
    color: #fda4af;
}

.tl-btn-danger:hover {
    border-color: #fb7185;
    color: #ffffff;
    background: rgba(244, 63, 94, 0.16);
}

/* ----------------------------------------------------------------
   Group Cards Grid
   ---------------------------------------------------------------- */

.tl-group-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.tl-group-card {
    position: relative;
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    padding: 16px;
    transition: border-color 0.15s ease;
}

.tl-group-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    transition: border-color 0.15s ease;
}

.tl-group-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    transition: border-color 0.15s ease;
}

.tl-group-card:hover {
    border-color: var(--primary);
}

.tl-group-card:hover::before,
.tl-group-card:hover::after {
    border-color: var(--primary);
}

.tl-group-header {
    align-items: center;
}

.tl-group-primary {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-mono);
}

.tl-group-description {
    margin: 10px 0 12px;
    min-height: 0;
    font-size: 13px;
}

.tl-group-actions {
    gap: 6px;
    flex-wrap: nowrap;
}

/* ----------------------------------------------------------------
   Chips
   ---------------------------------------------------------------- */

.tl-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #d5dae3;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    font-family: var(--font-mono);
}

.tl-chip-current {
    border-color: rgba(74, 222, 128, 0.55);
    color: #86efac;
}

.tl-chip-row {
    gap: 6px;
}

/* ----------------------------------------------------------------
   Links Panel (inside group cards)
   ---------------------------------------------------------------- */

.tl-links-panel {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tl-links-header {
    margin-bottom: 10px;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tl-links-header span:last-child {
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
}

.tl-link-list {
    gap: 6px;
}

.tl-link-empty,
.tl-empty-state {
    padding: 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.12);
}

.tl-link-empty {
    display: grid;
    gap: 10px;
    justify-items: center;
}

.tl-link-row {
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    align-items: center;
    gap: 10px;
    transition: background 0.1s ease;
}

.tl-link-row:hover {
    background: var(--bg-elevated);
}

.tl-team-item {
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.025);
}

.tl-link-copy,
.tl-team-item-copy {
    min-width: 0;
}

.tl-link-season {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.tl-link-team {
    margin-top: 3px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.4;
}

.tl-link-actions {
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.tl-empty-state {
    display: grid;
    gap: 12px;
    justify-items: center;
}

/* ----------------------------------------------------------------
   Modals
   ---------------------------------------------------------------- */

.tl-modal-content {
    width: min(96vw, 760px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: var(--bg-card);
    position: relative;
}

.tl-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 1;
}

.tl-modal-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 1;
}

.tl-modal-body {
    padding: 20px;
    display: grid;
    gap: 14px;
}

.tl-modal-footer {
    padding: 0 20px 20px;
    justify-content: flex-end;
}

.tl-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.tl-form-group {
    display: grid;
    gap: 6px;
}

.tl-textarea {
    min-height: 100px;
    resize: vertical;
}

/* ----------------------------------------------------------------
   Toast Container
   ---------------------------------------------------------------- */

#toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 10010;
}

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

@media (max-width: 1100px) {
    .tl-hero-grid {
        grid-template-columns: 1fr;
    }

    .tl-metrics-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        margin-top: 14px;
    }

    .tl-workspace {
        grid-template-columns: 260px minmax(0, 1fr);
    }
}

@media (max-width: 960px) {
    .tl-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .tl-metrics-grid,
    .tl-form-grid,
    .tl-season-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tl-section-bar,
    .tl-group-header,
    .tl-context-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .tl-toolbar {
        width: 100%;
    }

    .tl-filter-input {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .team-linking-dashboard {
        padding: 10px;
    }

    .tl-hero-title {
        font-size: 17px;
    }

    .tl-metrics-grid,
    .tl-form-grid,
    .tl-season-stats {
        grid-template-columns: 1fr;
    }

    .tl-group-card,
    .tl-surface,
    .tl-metric-card {
        padding: 12px;
    }

    .tl-link-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tl-link-actions {
        justify-content: flex-end;
    }

    .tl-modal-body,
    .tl-modal-footer {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tl-action-card,
    .tl-season-card,
    .tl-group-card,
    .tl-btn {
        transition: none;
    }
}
