/**
 * DCI Control Center v1.0 - Styles
 * Dark theme matching existing crawler design
 */

/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   CONTAINER
   ============================================ */
.dci-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   HEADER
   ============================================ */
.dci-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #161b22 0%, #21262d 100%);
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #30363d;
}

.dci-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: #58a6ff;
}

.dci-logo h1 {
    font-size: 24px;
    font-weight: 600;
    color: #f0f6fc;
}

.dci-logo .version {
    font-size: 12px;
    color: #8b949e;
    font-weight: normal;
    background: #21262d;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.dci-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-link {
    color: #58a6ff;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-link:hover {
    color: #79c0ff;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #21262d;
    border-radius: 20px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f0883e;
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: #3fb950;
    animation: none;
}

.connection-status.disconnected .status-dot {
    background: #f85149;
}

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

/* ============================================
   STATS BAR
   ============================================ */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #161b22 0%, #21262d 100%);
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stat-card.running {
    border-color: #238636;
    background: linear-gradient(135deg, #0d1117 0%, #0d2818 100%);
}

.stat-card.paused {
    border-color: #9e6a03;
    background: linear-gradient(135deg, #0d1117 0%, #2d1f00 100%);
}

.stat-card.success {
    border-color: #238636;
}

.stat-card.error {
    border-color: #f85149;
    background: linear-gradient(135deg, #0d1117 0%, #2d0f0f 100%);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #f0f6fc;
    line-height: 1.2;
}

.stat-card.running .stat-value { color: #3fb950; }
.stat-card.paused .stat-value { color: #f0883e; }
.stat-card.success .stat-value { color: #3fb950; }
.stat-card.error .stat-value { color: #f85149; }

.stat-label {
    font-size: 12px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ============================================
   CONTROLS BAR
   ============================================ */
.controls-bar {
    background: linear-gradient(135deg, #161b22 0%, #21262d 100%);
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.controls-bar h2 {
    font-size: 14px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.control-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-icon {
    font-size: 14px;
}

.btn-primary {
    background: #238636;
    color: #fff;
}

.btn-primary:hover {
    background: #2ea043;
}

.btn-success {
    background: #238636;
    color: #fff;
}

.btn-success:hover {
    background: #2ea043;
}

.btn-warning {
    background: #9e6a03;
    color: #fff;
}

.btn-warning:hover {
    background: #bb8009;
}

.btn-danger {
    background: #da3633;
    color: #fff;
}

.btn-danger:hover {
    background: #f85149;
}

.btn-secondary {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
}

.btn-secondary:hover {
    background: #30363d;
}

.btn-info {
    background: #1f6feb;
    color: #fff;
}

.btn-info:hover {
    background: #388bfd;
}

.btn-config {
    background: #6e40c9;
    color: #fff;
}

.btn-config:hover {
    background: #8957e5;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 4px;
    cursor: pointer;
}

.btn-small:hover {
    background: #30363d;
}

.btn-icon-only {
    padding: 6px 10px;
    min-width: auto;
}

/* ============================================
   ALERTS BANNER
   ============================================ */
.alerts-banner {
    background: linear-gradient(135deg, #2d1f00 0%, #3d2800 100%);
    border: 1px solid #9e6a03;
    border-radius: 10px;
    padding: 12px 20px;
    margin-bottom: 20px;
}

.alerts-content {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.alert-item.error {
    border-left: 3px solid #f85149;
}

.alert-item.warning {
    border-left: 3px solid #f0883e;
}

.alert-item.info {
    border-left: 3px solid #58a6ff;
}

.alert-dismiss {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

.alert-dismiss:hover {
    color: #f0f6fc;
}

/* ============================================
   MAIN GRID
   ============================================ */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: linear-gradient(135deg, #161b22 0%, #21262d 100%);
    border: 1px solid #30363d;
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #30363d;
    background: rgba(0, 0, 0, 0.2);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #f0f6fc;
}

.card-actions {
    display: flex;
    gap: 10px;
}

.card-body {
    padding: 15px 20px;
}

.badge {
    background: #21262d;
    color: #8b949e;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* ============================================
   PROCESSES TABLE
   ============================================ */
.processes-card {
    min-height: 400px;
}

.processes-card .card-body {
    padding: 0;
    overflow-x: auto;
}

.processes-table {
    width: 100%;
    border-collapse: collapse;
}

.processes-table th {
    text-align: left;
    padding: 12px 15px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b949e;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #30363d;
    position: sticky;
    top: 0;
}

.processes-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #21262d;
    font-size: 13px;
}

.processes-table tr:hover {
    background: rgba(56, 139, 253, 0.1);
}

.processes-table .loading-row td {
    text-align: center;
    color: #8b949e;
    padding: 40px;
}

.process-id {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11px;
    color: #8b949e;
    cursor: pointer;
}

.process-id:hover {
    color: #58a6ff;
}

.mode-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.mode-viral { background: #8957e5; color: #fff; }
.mode-ultimate { background: #1f6feb; color: #fff; }
.mode-multi { background: #238636; color: #fff; }
.mode-infinite { background: #f0883e; color: #fff; }
.mode-search { background: #6e40c9; color: #fff; }
.mode-deep { background: #da3633; color: #fff; }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.status-running {
    background: rgba(63, 185, 80, 0.2);
    color: #3fb950;
}

.status-paused {
    background: rgba(240, 136, 62, 0.2);
    color: #f0883e;
}

.status-pending {
    background: rgba(139, 148, 158, 0.2);
    color: #8b949e;
}

.status-stopped {
    background: rgba(248, 81, 73, 0.2);
    color: #f85149;
}

.status-dead {
    background: rgba(110, 118, 129, 0.2);
    color: #6e7681;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-running .status-dot {
    animation: pulse 1.5s infinite;
}

.process-actions {
    display: flex;
    gap: 5px;
}

.process-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.process-actions .btn-pause {
    background: #9e6a03;
    color: #fff;
}

.process-actions .btn-resume {
    background: #238636;
    color: #fff;
}

.process-actions .btn-stop {
    background: #da3633;
    color: #fff;
}

.suspected-dead {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(248, 81, 73, 0.1) 10px,
        rgba(248, 81, 73, 0.1) 20px
    );
}

select {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
}

select:hover {
    border-color: #58a6ff;
}

/* ============================================
   SIDE PANEL
   ============================================ */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Leaderboard */
.leaderboard-card {
    max-height: 350px;
}

.leaderboard-card .card-body {
    padding: 0;
    overflow-y: auto;
    max-height: 280px;
}

.leaderboard-list {
    padding: 10px 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    border-bottom: 1px solid #21262d;
    transition: background 0.2s;
}

.leaderboard-item:hover {
    background: rgba(56, 139, 253, 0.1);
}

.leaderboard-rank {
    width: 30px;
    font-size: 14px;
    font-weight: 700;
    color: #8b949e;
}

.leaderboard-rank.top-3 {
    color: #f0883e;
}

.leaderboard-domain {
    flex: 1;
    font-size: 13px;
    color: #c9d1d9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-stats {
    display: flex;
    gap: 15px;
    font-size: 12px;
}

.leaderboard-stat {
    color: #8b949e;
}

.leaderboard-stat.imports {
    color: #3fb950;
    font-weight: 600;
}

/* Activity Log */
.activity-card {
    flex: 1;
    max-height: 350px;
}

.activity-card .card-body {
    padding: 0;
}

.activity-log {
    overflow-y: auto;
    max-height: 280px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11px;
}

.activity-entry {
    display: flex;
    padding: 6px 15px;
    border-bottom: 1px solid #21262d;
    gap: 10px;
}

.activity-entry:hover {
    background: rgba(56, 139, 253, 0.05);
}

.activity-time {
    color: #6e7681;
    flex-shrink: 0;
}

.activity-mode {
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.activity-url {
    color: #58a6ff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-status {
    flex-shrink: 0;
}

.activity-status.imported { color: #3fb950; }
.activity-status.error { color: #f85149; }
.activity-status.skipped { color: #8b949e; }

/* ============================================
   CHARTS ROW
   ============================================ */
.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    min-height: 300px;
}

.chart-card .card-body {
    height: 230px;
    padding: 15px;
}

.chart-card canvas {
    max-height: 100%;
}

/* ============================================
   RECENT CARD
   ============================================ */
.recent-card .card-body {
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.recent-list {
    display: flex;
    flex-direction: column;
}

.recent-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #21262d;
    gap: 15px;
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-mode {
    flex-shrink: 0;
}

.recent-status {
    flex-shrink: 0;
}

.recent-stats {
    flex: 1;
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: #8b949e;
}

.recent-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.recent-time {
    font-size: 12px;
    color: #6e7681;
    flex-shrink: 0;
}

/* ============================================
   MODALS
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #30363d;
}

.modal-header h3 {
    font-size: 18px;
    color: #f0f6fc;
}

.modal-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #f0f6fc;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #30363d;
}

/* Config Form */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 13px;
    color: #8b949e;
}

.form-group input[type="number"],
.form-group input[type="text"] {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px;
    color: #c9d1d9;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #58a6ff;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Pool Stats */
.pool-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.pool-stat {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.pool-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #f0f6fc;
}

.pool-stat-label {
    display: block;
    font-size: 12px;
    color: #8b949e;
    margin-top: 5px;
}

.pool-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Network Stats Grid */
.network-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    height: 100%;
    align-content: center;
}

.network-stat {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.network-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #58a6ff;
}

.network-stat-label {
    font-size: 12px;
    color: #8b949e;
    margin-top: 5px;
    text-transform: uppercase;
}

/* Process Details */
.process-details {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.process-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.process-info-item {
    background: #0d1117;
    border-radius: 6px;
    padding: 12px;
}

.process-info-label {
    font-size: 11px;
    color: #8b949e;
    text-transform: uppercase;
}

.process-info-value {
    font-size: 18px;
    font-weight: 600;
    color: #f0f6fc;
    margin-top: 4px;
}

.process-logs {
    background: #0d1117;
    border-radius: 6px;
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 11px;
}

.process-log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #21262d;
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading {
    text-align: center;
    padding: 40px;
    color: #8b949e;
}

.loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* ============================================
   UTILITIES
   ============================================ */
.text-success { color: #3fb950; }
.text-warning { color: #f0883e; }
.text-danger { color: #f85149; }
.text-muted { color: #8b949e; }

.number-format {
    font-variant-numeric: tabular-nums;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .dci-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .control-buttons {
        justify-content: center;
    }

    .process-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pool-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}
