/* Modern Admin Interface Styles */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: var(--dark);
    margin: 0;
    padding: 0;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--dark) 0%, #334155 100%) !important;
    box-shadow: var(--shadow-lg);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Summary Cards */
.summary-card {
    border-left: 4px solid var(--primary);
}

.summary-card.online {
    border-left-color: var(--success);
}

.summary-card.active {
    border-left-color: var(--info);
}

.summary-card.offline {
    border-left-color: var(--danger);
}

.summary-card h2 {
    font-size: 2rem;
    font-weight: 700;
}

/* Machine Cards */
.machine-card {
    border-radius: 12px;
    transition: all 0.3s;
}

.machine-card.status-idle {
    border-left: 4px solid var(--secondary);
}

.machine-card.status-running {
    border-left: 4px solid var(--primary);
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.machine-card.status-finished {
    border-left: 4px solid var(--success);
}

.machine-card.status-error {
    border-left: 4px solid var(--danger);
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.machine-card.status-offline {
    border-left: 4px solid var(--secondary);
    opacity: 0.7;
}

/* Status Badge */
.status-badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Progress Bar */
.progress {
    height: 8px;
    border-radius: 4px;
    background: var(--border);
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary) 0%, var(--info) 100%);
    border-radius: 4px;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 500;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    border-radius: 8px;
    font-weight: 500;
}

/* Modal */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    background: var(--light);
    border-radius: 16px 16px 0 0;
}

.modal-footer {
    border-top: 1px solid var(--border);
    background: var(--light);
    border-radius: 0 0 16px 16px;
}

/* Tabs */
.nav-tabs {
    border-bottom: 2px solid var(--border);
}

.nav-tabs .nav-link {
    border: none;
    color: var(--secondary);
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    background: white;
    border-bottom: 2px solid var(--primary);
    margin-bottom: -2px;
}

/* Form Controls */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0.625rem 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--dark);
    margin-bottom: 0.375rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--secondary);
}

/* Field Mapping Cards */
.capability-card {
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.capability-card.enabled {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

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

.capability-card .capability-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.capability-card .mapping-fields {
    display: none;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.capability-card.enabled .mapping-fields {
    display: block;
}

/* Command/Program Cards */
.command-card, .program-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.command-card:hover, .program-card:hover {
    box-shadow: var(--shadow);
}

/* Toggle Switch */
.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.section-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--dark);
}

/* Protocol Badge */
.protocol-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.protocol-badge.mqtt-binary,
.protocol-badge.mqtt_binary {
    background: #fef3c7;
    color: #92400e;
}

.protocol-badge.mqtt-simple,
.protocol-badge.mqtt_simple {
    background: #d1fae5;
    color: #065f46;
}

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

/* Additional status colors for filters */
.machine-card.status-busy {
    border-left: 4px solid var(--warning);
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
}

/* Table */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: var(--light);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--secondary);
    border-bottom: 2px solid var(--border);
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.02);
}

/* Events Table */
.event-row {
    font-size: 0.875rem;
}

.event-timestamp {
    color: var(--secondary);
    font-size: 0.8rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Sidebar (for future use) */
.sidebar {
    background: white;
    min-height: 100vh;
    box-shadow: var(--shadow);
}

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

::-webkit-scrollbar-track {
    background: var(--light);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
    }

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

    .capability-card {
        padding: 0.75rem;
    }
}

/* Code/Offset Input */
.offset-input {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

/* Help tooltip */
.help-icon {
    color: var(--secondary);
    cursor: help;
    font-size: 0.875rem;
}

/* Add/Remove buttons */
.btn-add-item {
    border-style: dashed;
}

/* JSON preview */
.json-preview {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
}

/* Accordion for model config */
.config-accordion .accordion-button {
    font-weight: 600;
    background: var(--light);
}

.config-accordion .accordion-button:not(.collapsed) {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}
