/* ================================================
   Release Copilot — Dashboard Styles
   Dark-first design using FluentUI design tokens
   ================================================ */

/* ===== Dashboard Layout ===== */
.dashboard {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.dashboard-header {
    text-align: left;
}

.dashboard-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
    color: var(--neutral-foreground-rest);
}

.dashboard-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    opacity: 0.6;
    color: var(--neutral-foreground-rest);
}

/* ===== Dashboard Header Actions ===== */
.dashboard-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ===== Collapsible Release Type Sections ===== */
.release-type-header.collapsible {
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0.35rem;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.release-type-header.collapsible:hover {
    background: var(--neutral-fill-secondary-hover);
}

.collapse-icon {
    display: inline-block;
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    opacity: 0.5;
    margin-right: 0.15rem;
}

.collapse-icon.expanded {
    transform: rotate(90deg);
}

.release-type-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-left: 0.5rem;
    margin-top: 0.5rem;
}

/* ===== Train Sub-Groups (within release type) ===== */
.train-subgroup {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.train-subgroup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.train-subgroup-title {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    color: var(--neutral-foreground-rest);
    opacity: 0.7;
}

.unassigned-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.unassigned-subgroup {
    margin-top: 0.25rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--neutral-stroke-rest);
}

/* ===== Unassigned Tile Assign Action ===== */
.unassigned-tile-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.assign-action {
    display: flex;
    align-items: center;
}

.assign-action fluent-select {
    width: 100%;
    --neutral-fill-input-rest: var(--neutral-layer-2);
}

/* ===== Dashboard Tabs ===== */
.dashboard-tabs {
    display: flex;
    gap: 0;
    margin-top: 0.75rem;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}

.dashboard-tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--neutral-foreground-rest);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dashboard-tab:hover {
    opacity: 0.85;
}

.dashboard-tab.active {
    opacity: 1;
    font-weight: 600;
    border-bottom-color: #3b82f6;
    color: #3b82f6;
}

/* ===== Connection Status Indicator ===== */
.connection-indicator {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.3s ease, color 0.3s ease;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.connection-text {
    opacity: 0.9;
}

.connection-connected {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.connection-connected .connection-dot {
    background: #22c55e;
    box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.connection-reconnecting {
    background: rgba(234, 179, 8, 0.1);
    color: #eab308;
}

.connection-reconnecting .connection-dot {
    background: #eab308;
    animation: pulse 1.5s ease-in-out infinite;
}

.connection-disconnected {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.connection-disconnected .connection-dot {
    background: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Loading State ===== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
    color: var(--neutral-foreground-rest);
    opacity: 0.7;
}

.loading-state p {
    margin: 0;
    font-size: 0.95rem;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--neutral-stroke-rest);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Error State ===== */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    gap: 0.75rem;
    border: 1px dashed rgba(239, 68, 68, 0.3);
    border-radius: calc(var(--control-corner-radius) * 2);
    background: rgba(239, 68, 68, 0.05);
}

.error-icon {
    font-size: 2rem;
}

.error-message {
    margin: 0;
    font-size: 0.9rem;
    color: #ef4444;
    text-align: center;
    max-width: 400px;
}

.retry-button {
    padding: 0.4rem 1.2rem;
    border: 1px solid #3b82f6;
    border-radius: calc(var(--control-corner-radius));
    background: transparent;
    color: #3b82f6;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.retry-button:hover {
    background: #3b82f6;
    color: #fff;
}

/* ===== Empty Dashboard State ===== */
.empty-dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    border: 1px dashed var(--neutral-stroke-rest);
    border-radius: calc(var(--control-corner-radius) * 2);
    opacity: 0.7;
}

.empty-dashboard-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.empty-dashboard h2 {
    margin: 0 0 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--neutral-foreground-rest);
}

.empty-dashboard p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--neutral-foreground-rest);
    max-width: 400px;
    line-height: 1.5;
}

/* ===== Release Type Sections ===== */
.release-type-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.release-type-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.release-type-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--neutral-foreground-rest);
}

.release-type-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.vnext-indicator {
    background: #60a5fa;
}

.servicing-indicator {
    background: #a78bfa;
}

.release-type-count {
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--neutral-fill-secondary-rest);
    color: var(--neutral-foreground-rest);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    opacity: 0.7;
}

/* ===== Tile Grid ===== */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 1px dashed var(--neutral-stroke-rest);
    border-radius: calc(var(--control-corner-radius) * 2);
    opacity: 0.5;
}

.empty-state .empty-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.empty-state p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--neutral-foreground-rest);
}

/* ===== Release Tile ===== */
.release-tile {
    background: var(--neutral-layer-card-container);
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: calc(var(--control-corner-radius) * 2);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    position: relative;
}

.release-tile:hover {
    border-color: var(--neutral-stroke-rest);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* Security release accent */
.release-tile.security {
    border-left: 3px solid #ef4444;
}

.release-tile.security .tile-header-top {
    background: rgba(239, 68, 68, 0.06);
}

.release-tile.security:hover {
    border-color: #ef4444;
    border-left-width: 3px;
}

/* Health status accents */
.release-tile.health-attention {
    border-top: 2px solid #eab308;
}

.release-tile.health-blocked {
    border-top: 2px solid #ef4444;
}

/* ===== Tile Header ===== */
.tile-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.tile-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--neutral-fill-secondary-rest);
    margin: -0.85rem -0.85rem 0;
    padding: 0.6rem 0.85rem;
    border-radius: calc(var(--control-corner-radius) * 2) calc(var(--control-corner-radius) * 2) 0 0;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}

.tile-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: var(--neutral-foreground-rest);
    line-height: 1.3;
    flex-shrink: 1;
    min-width: 0;
}

.tile-header-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.health-indicator {
    font-size: 0.7rem;
    flex-shrink: 0;
    cursor: default;
    transition: transform 0.2s ease;
}

.health-indicator:hover {
    transform: scale(1.3);
}

/* ===== Security & Ship Date (inline with title) ===== */
.security-indicator {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.shield-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.15s ease;
}

.security-indicator.is-security .shield-icon {
    --shield-check-color: #fff;
    color: #0078d4;
}

.security-indicator.not-security .shield-icon {
    --shield-slash-color: #9ca3af;
    color: #d1d5db;
    opacity: 0.6;
}

@media (prefers-color-scheme: dark) {
    .security-indicator.is-security .shield-icon {
        --shield-check-color: #0a0a0a;
        color: #47a7ff;
    }

    .security-indicator.not-security .shield-icon {
        --shield-slash-color: #6b7280;
        color: #4b5563;
        opacity: 0.5;
    }
}

.ship-date {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--neutral-foreground-rest);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.calendar-icon {
    width: 14px;
    height: 14px;
    opacity: 0.6;
    flex-shrink: 0;
}

.tile-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
}

.badge-vnext {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.badge-servicing {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
}

.badge-type {
    background: var(--neutral-fill-secondary-rest);
    color: var(--neutral-foreground-rest);
}

/* ===== State Indicator ===== */
.tile-state {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--neutral-foreground-rest);
    opacity: 0.8;
}

.state-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.state-started {
    background: #22c55e;
}

.state-shipped {
    background: #3b82f6;
}

.state-cancelled {
    background: #6b7280;
}

.state-notstarted {
    background: #eab308;
}

.state-text {
    font-weight: 500;
}

.state-separator {
    opacity: 0.4;
}

.stage-in-time {
    opacity: 0.7;
}

/* ===== Stage Progress Indicator ===== */
.stage-progress {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 0.4rem 0;
}

.stage-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    flex: 0 0 auto;
}

.stage-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.stage-step.completed .stage-dot {
    background: #22c55e;
    color: #fff;
}

.stage-step.current .stage-dot {
    background: transparent;
    border: 2px solid #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.stage-step.future .stage-dot {
    background: transparent;
    border: 1.5px solid var(--neutral-stroke-rest);
    opacity: 0.5;
}

.stage-check {
    font-weight: 700;
    line-height: 1;
}

.stage-label {
    font-size: 0.55rem;
    text-align: center;
    color: var(--neutral-foreground-rest);
    white-space: nowrap;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-step.completed .stage-label {
    opacity: 0.7;
}

.stage-step.current .stage-label {
    font-weight: 600;
    color: #3b82f6;
}

.stage-step.future .stage-label {
    opacity: 0.4;
}

.stage-sub-progress {
    font-size: 0.55rem;
    color: #3b82f6;
    font-style: italic;
    white-space: nowrap;
}

.stage-connector {
    flex: 1;
    height: 2px;
    background: var(--neutral-stroke-rest);
    margin-top: 7px;
    min-width: 6px;
    opacity: 0.3;
    transition: background 0.3s ease, opacity 0.3s ease;
}

.stage-connector.completed {
    background: #22c55e;
    opacity: 0.7;
}

/* ===== Tile Details Grid ===== */
.tile-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--neutral-stroke-divider-rest);
}

.tile-detail {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.detail-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.5;
    color: var(--neutral-foreground-rest);
    flex-shrink: 0;
}

.detail-value {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--neutral-foreground-rest);
    font-family: var(--body-font), 'Cascadia Code', 'Consolas', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Quick Links ===== */
.tile-links {
    padding-top: 0.4rem;
    border-top: 1px solid var(--neutral-stroke-divider-rest);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.quick-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.45rem;
    border-radius: calc(var(--control-corner-radius));
    background: var(--neutral-fill-secondary-rest);
    color: var(--neutral-foreground-rest);
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease;
}

.quick-link:hover {
    background: var(--neutral-fill-secondary-hover);
    text-decoration: none;
    transform: translateY(-1px);
}

.quick-link-icon {
    font-size: 0.75rem;
}

.quick-link-text {
    font-weight: 500;
}

/* ===== Schedule / Reschedule Action ===== */
.schedule-action {
    margin-left: auto;
    position: relative;
    flex-shrink: 0;
}

.schedule-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    background: var(--neutral-layer-floating, #fff);
    border: 1px solid var(--neutral-stroke-rest, #d1d1d1);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 180px;
    padding: 4px 0;
}

.schedule-dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--neutral-foreground-rest, #242424);
    text-align: left;
}

.schedule-dropdown-item:hover {
    background: var(--neutral-fill-stealth-hover, #f5f5f5);
}

.schedule-menu-date {
    font-size: 12px;
    color: var(--neutral-foreground-hint, #707070);
    margin-left: 12px;
}

/* ===== Tile Error Fallback ===== */
.tile-error {
    background: var(--neutral-layer-card-container, #fff);
    border: 1px dashed var(--neutral-stroke-rest, #d1d1d1);
    border-radius: calc(var(--control-corner-radius, 4px) * 2);
    padding: 1rem;
    text-align: center;
    color: var(--neutral-foreground-hint, #707070);
    font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .dashboard {
        padding: 1rem 0.75rem;
    }

    .dashboard-header-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tile-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-title {
        font-size: 1.4rem;
    }

    .connection-indicator {
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .stage-label {
        display: none;
    }

    .stage-sub-progress {
        display: none;
    }

    .tile-details {
        grid-template-columns: 1fr;
    }

    .connection-text {
        display: none;
    }
}
