/* DST-DNS Dashboard Styles */

:root {
    --primary-color: #2563eb;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --header-bg: #1e293b;
    --header-text: #f1f5f9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.header-title {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.header-title .brand {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--header-text);
    text-decoration: none;
}

.header-title .subtitle {
    font-size: 0.9rem;
    color: rgba(241, 245, 249, 0.75);
}

.header-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.build-info {
    font-family: monospace;
    font-size: 0.85rem;
    color: #cbd5f5;
}

.build-info .divider {
    margin: 0 0.35rem;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.worker-counters {
    display: flex;
    gap: 0.75rem;
}

.worker-counter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 0 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 0.75rem;
}

.nav-link {
    color: #cbd5f5;
    text-decoration: none;
    font-weight: 500;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.05);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.nav-link.active {
    background: #1d4ed8;
    color: #ffffff;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.status-dot.connected {
    background-color: var(--success-color);
}

.status-dot.disconnected {
    background-color: var(--danger-color);
}

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

main.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Form Styles */
.form-group {
    margin-bottom: 0.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

/* Messages */
.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    display: none;
}

.message.show {
    display: block;
}

.message.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* Table Controls */
.table-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.table-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

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

thead {
    background-color: #f9fafb;
}

th {
    text-align: left;
    padding: 0.5rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
    background-color: #f9fafb;
}

tbody tr.clickable-row:hover {
    background-color: #e5e7eb;
    transition: background-color 0.2s;
}

.empty-state {
    text-align: center;
    color: #6b7280;
    padding: 2rem !important;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-badge.pending {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.processing {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-badge.completed {
    background-color: #d1fae5;
    color: #065f46;
}

.status-badge.failed {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Task Type Badge */
.task-type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #e0e7ff;
    color: #3730a3;
    font-family: 'Courier New', monospace;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

/* Live Updates Feed */
.updates-feed {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
}

/* Compact version with reduced spacing */
.updates-feed-compact .update-item {
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.3rem;
}

/* Scrollable Table Container for Tasks */
.card .table-container {
    max-height: 500px;
    overflow-y: auto;
}

.update-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    border-left: 4px solid;
    font-size: 0.875rem;
}

.update-item.info {
    background-color: #e0f2fe;
    border-color: #0ea5e9;
}

.update-item.success {
    background-color: #d1fae5;
    border-color: #10b981;
}

.update-item.warning {
    background-color: #fef3c7;
    border-color: #f59e0b;
}

.update-item.error {
    background-color: #fee2e2;
    border-color: #ef4444;
}

.update-timestamp {
    color: #6b7280;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Score and Badge Styles */
.score {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
}

.score-success {
    background-color: #d1fae5;
    color: #065f46;
}

.score-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.score-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-free {
    background-color: #e5e7eb;
    color: #374151;
}

.badge-parked {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-active_personal {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-active_commercial {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-suspicious {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-secondary {
    background-color: #f3f4f6;
    color: #4b5563;
}

/* Footer */
footer {
    background-color: var(--header-bg);
    color: var(--header-text);
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
}

.footer-inner {
    font-size: 0.9rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 2rem;
    border-radius: 8px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.modal-close:hover {
    color: var(--danger-color);
}

/* Worker Group Cards */
.worker-group-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.worker-group-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.worker-group-card .stat {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0.5rem 0;
}

.worker-group-card .detail {
    font-size: 0.85rem;
    opacity: 0.8;
    margin: 0.25rem 0;
}

/* Form Enhancements */
textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea:invalid {
    border-color: var(--danger-color);
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="number"]:invalid,
input[type="text"]:invalid {
    border-color: var(--danger-color);
}

/* Radio button focus styles */
input[type="radio"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Checkbox focus styles */
input[type="checkbox"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Better focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip to main content link (accessibility) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Worker Status Indicators */
.worker-online {
    color: var(--success-color);
    font-weight: bold;
}

.worker-offline {
    color: var(--danger-color);
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }

    /* Stack task type options on mobile */
    .task-type-option label {
        font-size: 0.9em;
    }

    /* Improve worker counters on mobile */
    #worker-counters {
        font-size: 0.85em !important;
        gap: 10px !important;
    }

    /* Make navigation responsive */
    nav {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }

    nav > div:first-child {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    nav > div:first-child a {
        font-size: 0.9em;
        margin-right: 0 !important;
    }
}

/* Tablet breakpoint */
@media (max-width: 1024px) {
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    main.container {
        padding: 0 1rem;
    }
}

/* Improve print styles */
@media print {
    header nav,
    .btn,
    .live-updates,
    #connection-status {
        display: none !important;
    }

    body {
        background: white;
    }

    .card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Fixed Live Updates Panel at Bottom */
.live-updates-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid #0066cc;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 200px;
    transition: max-height 0.3s ease;
}

.live-updates-fixed.minimized {
    max-height: 45px;
}

.live-updates-fixed.minimized .updates-feed {
    display: none;
}

.live-updates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.live-updates-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.btn-minimal {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.btn-minimal:hover {
    color: #0066cc;
}

.live-updates-fixed .updates-feed {
    max-height: 155px;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    border: none;
}

.live-updates-fixed .update-item {
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.live-updates-fixed .update-timestamp {
    flex-shrink: 0;
    margin-top: 0;
    font-weight: 600;
    min-width: 50px;
}

.live-updates-fixed .update-message {
    flex: 1;
}

/* Add padding to main content to avoid overlap with fixed panel */
body {
    padding-bottom: 210px;
}

body.live-updates-minimized {
    padding-bottom: 55px;
}

/* Task Type Labels (for task creation form) */
.task-type-label {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.task-type-label:hover {
    border-color: #0066cc;
    background-color: #f8f9fa;
}

.task-type-label input[type="radio"] {
    margin-right: 10px;
    margin-top: 3px;
}

.task-type-label strong {
    display: block;
    color: #0066cc;
    margin-bottom: 4px;
}

.task-type-label p {
    margin: 0;
    font-size: 0.9em;
    color: #666;
}

/* Field Group Box (for dynamic form sections) */
.field-group-box {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
    background: #f8f9fa;
}

.field-group-box legend {
    font-weight: 600;
    padding: 0 8px;
    color: #333;
}

/* Inline Radio Buttons */
.inline-radio {
    display: inline-flex;
    align-items: center;
    margin-right: 20px;
    cursor: pointer;
}

.inline-radio input[type="radio"] {
    margin-right: 6px;
}

.inline-radio span {
    font-size: 0.95em;
}

/* Checkbox Labels */
.checkbox-label {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
}

.checkbox-label span {
    font-size: 0.95em;
}

/* Back Link */
.back-link {
    display: inline-block;
    color: #0066cc;
    text-decoration: none;
    margin-bottom: 15px;
    font-size: 0.95em;
}

.back-link:hover {
    text-decoration: underline;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
}

.detail-value {
    font-weight: 600;
    color: var(--text-color);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-block {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    padding: 0.75rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.mono {
    font-family: monospace;
}

.mono-link {
    font-family: monospace;
    color: var(--primary-color);
    text-decoration: none;
}

.mono-link:hover {
    text-decoration: underline;
}

.muted {
    color: #6b7280;
}

.list {
    list-style: none;
    padding-left: 0;
}

.list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.history-entry {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ========================================================================
   Form layout helpers (task-create, classification-testing pages)
   ======================================================================== */

/* Two-column responsive grid for form fields */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 0.75rem;
}

/* Individual field in a form */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Uniform task form spacing */
.task-form > * + * {
    margin-top: 0.75rem;
}

/* Horizontal row of quick-action buttons */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.action-row .button,
.action-row .btn {
    flex: 0 0 auto;
}

/* Inline actions inside a form group */
.input-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Horizontal checkbox / radio group */
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 400;
    cursor: pointer;
}

/* Small button variant */
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

/* Small inline status message (no full block) */
.small-status {
    font-size: 0.85rem;
    color: #6b7280;
    min-height: 1.2em;
}
