/* ============================================
   DevOps Dashboard — Dark Theme Styles
   ============================================ */

:root {
    --bg-primary: #1a1a2e;
    --bg-card: #16213e;
    --bg-accent: #0f3460;
    --text-primary: #e6e6e6;
    --text-muted: #8892a4;
    --border-color: #2a2a4a;
    --success: #00e676;
    --warning: #ffd600;
    --orange: #ff9100;
    --danger: #ff1744;
    --info: #448aff;
    --kanban-col-bg: #0d1b2a;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-accent);
    border-radius: 3px;
}

/* ---- Navbar ---- */
.navbar {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color);
    height: 48px;
    padding: 0 16px;
    z-index: 1030;
}

.navbar-brand {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary) !important;
}

/* ---- WS & Health indicators ---- */
.ws-indicator {
    font-size: 10px;
    cursor: default;
    transition: color 0.3s;
}
.ws-indicator.connected {
    color: var(--success);
}
.ws-indicator.disconnected {
    color: var(--danger);
}
.ws-indicator.connecting {
    color: var(--warning);
    animation: pulse-yellow 1s infinite;
}

.health-badge {
    font-size: 11px;
    font-weight: 500;
}

/* ---- Tab Navigation ---- */
.tab-navigation {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 1020;
    padding: 0;
}

.tab-navigation .nav-tabs {
    border-bottom: none;
    padding: 0 16px;
    gap: 0;
}

.tab-navigation .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    background: none;
}
.tab-navigation .nav-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}
.tab-navigation .nav-link.active {
    color: var(--text-primary);
    border-bottom-color: var(--info);
    background: rgba(68,138,255,0.08);
}

/* ---- Main Content ---- */
.main-content {
    margin-top: 96px;
    padding: 16px;
    min-height: calc(100vh - 96px);
}

.page-content {
    display: none;
}
.page-content.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.page-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

/* ---- Loading ---- */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

/* ============================================
   AGENTS PAGE
   ============================================ */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.agent-card:hover {
    border-color: var(--info);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.agent-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

.agent-info {
    flex: 1;
    min-width: 0;
}
.agent-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agent-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}
.agent-dept {
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Status indicator */
.agent-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

/* Working */
.status-working .status-dot {
    background: var(--success);
    animation: pulse-green 1.5s infinite;
}
.status-working {
    background: rgba(0,230,118,0.1);
    color: var(--success);
}

/* Idle */
.status-idle .status-dot {
    background: var(--warning);
}
.status-idle {
    background: rgba(255,214,0,0.1);
    color: var(--warning);
}

/* Waiting */
.status-waiting .status-dot {
    background: var(--orange);
    animation: blink-orange 1s infinite;
}
.status-waiting {
    background: rgba(255,145,0,0.1);
    color: var(--orange);
}

/* Error */
.status-error .status-dot {
    background: var(--danger);
    animation: blink-red 0.5s infinite;
}
.status-error {
    background: rgba(255,23,68,0.1);
    color: var(--danger);
}

.agent-task {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.agent-task i {
    margin-top: 2px;
    font-size: 10px;
}

.agent-heartbeat {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Agent Modal */
.agent-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.agent-detail-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 24px;
    color: #fff;
}

.agent-detail-info h5 {
    margin: 0 0 4px;
}
.agent-detail-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.agent-status-history {
    margin-top: 16px;
}
.agent-status-history h6 {
    font-size: 13px;
    margin-bottom: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.status-history-time {
    color: var(--text-muted);
    min-width: 130px;
    font-family: monospace;
    font-size: 11px;
}

/* ============================================
   KANBAN PAGE
   ============================================ */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: 400px;
    align-items: flex-start;
}

.kanban-column {
    background: var(--kanban-col-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    min-width: 280px;
    max-width: 320px;
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--kanban-col-bg);
    border-radius: 10px 10px 0 0;
    z-index: 1;
}
.kanban-column-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.kanban-count {
    background: var(--bg-accent);
    color: var(--text-muted);
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.kanban-column-add {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.2s;
}
.kanban-column-add:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.kanban-cards {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    min-height: 50px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.15s;
    position: relative;
}
.kanban-card:hover {
    border-color: var(--info);
}
.kanban-card.sortable-ghost {
    opacity: 0.4;
    border: 1px dashed var(--info);
}
.kanban-card.sortable-chosen {
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transform: rotate(2deg);
}

.kanban-card-priority {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 8px 8px 0 0;
}
.priority-low { background: #546e7a; }
.priority-medium { background: var(--info); }
.priority-high { background: var(--orange); }
.priority-critical { background: var(--danger); }

.kanban-card-title {
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
    margin-bottom: 6px;
    line-height: 1.3;
}

.kanban-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kanban-card-agent {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
}

.kanban-card-priority-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}
.priority-label-low { background: rgba(84,110,122,0.2); color: #90a4ae; }
.priority-label-medium { background: rgba(68,138,255,0.15); color: var(--info); }
.priority-label-high { background: rgba(255,145,0,0.15); color: var(--orange); }
.priority-label-critical { background: rgba(255,23,68,0.15); color: var(--danger); }

/* ============================================
   CRON PAGE
   ============================================ */
.cron-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.cron-table thead th {
    background: var(--bg-accent);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.cron-table tbody td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}

.cron-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.cron-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
}
.cron-status-active {
    background: rgba(0,230,118,0.1);
    color: var(--success);
}
.cron-status-paused {
    background: rgba(255,214,0,0.1);
    color: var(--warning);
}
.cron-status-error {
    background: rgba(255,23,68,0.1);
    color: var(--danger);
}

.cron-countdown {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--info);
}

.cron-expression {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: rgba(255,255,255,0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.cron-actions .btn {
    padding: 3px 8px;
    font-size: 11px;
}

/* ============================================
   MODALS
   ============================================ */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.modal-header {
    border-bottom-color: var(--border-color);
}
.modal-footer {
    border-top-color: var(--border-color);
}

.form-control, .form-select {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--info);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(68,138,255,0.15);
}
.form-text {
    color: var(--text-muted);
    font-size: 11px;
}
.form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ============================================
   TOASTS
   ============================================ */
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
}
.toast-header {
    background: var(--bg-accent);
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0,230,118,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(0,230,118,0); }
}

@keyframes blink-orange {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes blink-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .agents-grid {
        grid-template-columns: 1fr;
    }
    .kanban-column {
        min-width: 260px;
        flex: 0 0 260px;
    }
    .page-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .cron-table {
        font-size: 12px;
    }
    .cron-table thead th,
    .cron-table tbody td {
        padding: 8px 6px;
    }
}
