/* ========================================
   Battery Emulator Cloud - Frontend Styles
   ======================================== */

:root {
    --be-primary: #2563eb;
    --be-primary-hover: #1d4ed8;
    --be-success: #10b981;
    --be-warning: #f59e0b;
    --be-error: #ef4444;
    --be-gray-50: #f9fafb;
    --be-gray-100: #f3f4f6;
    --be-gray-200: #e5e7eb;
    --be-gray-300: #d1d5db;
    --be-gray-600: #4b5563;
    --be-gray-700: #374151;
    --be-gray-900: #111827;
    --be-border-radius: 8px;
    --be-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --be-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* Dashboard Container */
.be-mqtt-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header + Stats */
.be-mqtt-header {
    margin-bottom: 30px;
}

.be-mqtt-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--be-gray-900);
    margin: 0 0 20px 0;
}

.be-mqtt-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-box {
    background: white;
    border: 1px solid var(--be-gray-200);
    border-radius: var(--be-border-radius);
    padding: 20px;
    flex: 1;
    min-width: 150px;
    text-align: center;
    box-shadow: var(--be-shadow);
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--be-primary);
    margin-bottom: 5px;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: var(--be-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Empty State */
.be-mqtt-empty {
    background: white;
    border: 2px dashed var(--be-gray-300);
    border-radius: var(--be-border-radius);
    padding: 60px 20px;
    text-align: center;
}

.be-mqtt-empty p {
    font-size: 18px;
    color: var(--be-gray-600);
    margin-bottom: 20px;
}

/* Devices Grid */
.be-mqtt-devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Device Card */
.device-card {
    background: white;
    border: 1px solid var(--be-gray-200);
    border-radius: var(--be-border-radius);
    padding: 20px;
    box-shadow: var(--be-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--be-gray-200);
}

.device-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.device-status.status-online {
    background: #dcfce7;
    color: #166534;
}

.device-status.status-idle {
    background: #fef3c7;
    color: #92400e;
}

.device-status.status-offline {
    background: #fee2e2;
    color: #991b1b;
}

.status-icon {
    font-size: 10px;
}

.device-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: var(--be-gray-100);
    border: 1px solid var(--be-gray-300);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--be-gray-200);
}

.device-body {
    margin-bottom: 15px;
}

.device-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--be-gray-900);
    margin: 0 0 5px 0;
    cursor: pointer;
}

.device-uid {
    font-size: 13px;
    font-family: 'Courier New', monospace;
    color: var(--be-gray-600);
    background: var(--be-gray-50);
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 15px;
}

.device-cloud {
    font-size: 14px;
    color: var(--be-gray-700);
    margin-bottom: 10px;
    padding: 10px;
    background: var(--be-gray-50);
    border-radius: 6px;
}

.device-cloud.cloud-inactive {
    background: #fee2e2;
}

.device-cloud.expire-warning {
    background: #fef3c7;
    border: 1px solid var(--be-warning);
}

.device-last-seen {
    font-size: 12px;
    color: var(--be-gray-600);
    margin-top: 10px;
}

.device-footer {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--be-gray-200);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.badge-warning {
    background: var(--be-warning);
    color: white;
}

.badge-error {
    background: var(--be-error);
    color: white;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    flex: 1;
}

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

.btn-primary:hover {
    background: var(--be-primary-hover);
}

.btn-secondary {
    background: var(--be-gray-100);
    color: var(--be-gray-700);
    border: 1px solid var(--be-gray-300);
}

.btn-secondary:hover {
    background: var(--be-gray-200);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* Modal */
.be-mqtt-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: var(--be-border-radius);
    box-shadow: var(--be-shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--be-gray-200);
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--be-gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--be-gray-600);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--be-gray-900);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--be-gray-200);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* MQTT Info Fields */
.mqtt-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mqtt-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--be-gray-700);
    margin-bottom: 5px;
}

.field-copy {
    display: flex;
    gap: 8px;
}

.field-copy input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--be-gray-300);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.btn-copy,
.btn-toggle-password {
    background: var(--be-gray-100);
    border: 1px solid var(--be-gray-300);
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-copy:hover,
.btn-toggle-password:hover {
    background: var(--be-gray-200);
}

.btn-copy.copied {
    background: var(--be-success);
    color: white;
    border-color: var(--be-success);
}

.mqtt-warning {
    background: #fef3c7;
    border-left: 4px solid var(--be-warning);
    padding: 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--be-gray-700);
    margin-top: 15px;
}

/* Form Input */
.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--be-gray-300);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

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

/* Notice */
.be-mqtt-notice {
    background: var(--be-gray-50);
    border: 1px solid var(--be-gray-300);
    border-radius: var(--be-border-radius);
    padding: 20px;
    text-align: center;
    color: var(--be-gray-700);
}

/* Responsive */
@media (max-width: 768px) {
    .be-mqtt-devices-grid {
        grid-template-columns: 1fr;
    }

    .be-mqtt-stats {
        flex-direction: column;
    }

    .device-footer {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}
