/* Reset e configurações básicas */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    color: #333;
    line-height: 1.6;
}

/* Prevenir overflow horizontal em mobile */
.container,
.section,
.device-info,
.monitors-list,
.devices-grid {
    max-width: 100%;
    overflow-x: hidden;
}

/* Utilitários */
.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
    padding: 20px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    background: white;
    padding: 15px 20px;
    margin: -20px -20px 20px -20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-title {
    font-size: 1.5rem;
    color: #667eea;
    margin: 0;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    margin: 0 auto;
    margin-top: 60px;
}

.title {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: 2rem;
}

/* Formulários */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 0.85rem;
}

/* Botões */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
}

/* Mensagens */
.error-message {
    color: #dc3545;
    background: #f8d7da;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    display: none;
    border: 1px solid #f5c6cb;
}

.error-message.show {
    display: block;
}

.success-message {
    color: #155724;
    background: #d4edda;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    display: none;
    border: 1px solid #c3e6cb;
}

.success-message.show {
    display: block;
}

.loading {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 1.2rem;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: white;
    font-size: 1.1rem;
}

/* Grid de Equipamentos */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.device-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.device-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

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

.device-icon {
    font-size: 2.5rem;
}

.device-card-title {
    font-size: 1.2rem;
    color: #333;
    margin: 0;
}

.device-card-info {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.device-card-info strong {
    color: #333;
}

.device-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 10px;
}

.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-inactive {
    background: #f8d7da;
    color: #721c24;
}

.badge-owner {
    background: #cfe2ff;
    color: #084298;
}

.badge-operator {
    background: #fff3cd;
    color: #664d03;
}

.badge-viewer {
    background: #e2e3e5;
    color: #383d41;
}

/* Informações do Dispositivo */
.device-info {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.device-info h2 {
    color: #667eea;
    margin-bottom: 15px;
}

.device-info-item {
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Seções */
.section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

/* Formulário de Monitor */
.monitor-form {
    max-width: 600px;
}

/* Lista de Monitores */
.monitors-list {
    display: grid;
    gap: 15px;
}

.monitor-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 2px solid #e0e0e0;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Estilos de monitor-item agora usam a estrutura de monitor-select-item */

.monitor-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Responsividade */
@media (max-width: 768px) {
    .screen {
        padding: 10px;
    }

    .header {
        margin: -10px -10px 15px -10px;
        padding: 12px 15px;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .card {
        padding: 20px;
        margin-top: 20px;
    }

    .title {
        font-size: 1.5rem;
    }

    .devices-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        font-size: 0.9rem;
        padding: 10px 20px;
    }

    .section {
        padding: 15px;
    }

    .device-card {
        padding: 15px;
    }

    .monitor-form {
        max-width: 100%;
    }

    /* Monitor items responsivos */
    .monitor-item {
        padding: 12px;
    }

    .monitor-item-header {
        flex-direction: column;
        gap: 10px;
    }

    .monitor-name {
        font-size: 1rem;
    }

    .monitor-info {
        font-size: 0.85rem;
    }

    /* Lista de monitores */
    .monitors-list {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Monitores disponíveis para adicionar - botão ocupa linha inteira em mobile */
    .monitor-select-item button {
        width: 100%;
        flex-basis: 100%;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-secondary {
        width: 100%;
    }

    .device-card-header {
        flex-direction: column;
        text-align: center;
    }

    .monitor-item-header {
        flex-direction: column;
        gap: 10px;
    }
}

/* Confirmação de usuário */
.user-confirmation {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
}

.user-confirmation h3 {
    color: #667eea;
    margin-bottom: 15px;
}

#user-data {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#user-data p {
    margin: 8px 0;
    color: #333;
}

#user-data strong {
    color: #667eea;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.button-group .btn {
    flex: 1;
}

/* Botão de remover */
.btn-danger {
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

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

.monitor-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.device-card,
.monitor-item,
.section {
    animation: fadeIn 0.5s ease-out;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

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

.dashboard-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    min-height: 400px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.panel-header h2 {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

.user-data-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.user-data-card p {
    margin: 0.5rem 0;
    color: #555;
}

.user-data-card strong {
    color: #333;
}

/* Monitor Items in My Monitors Panel - usando estilos globais de .monitor-item */

.monitor-item .monitor-info h4 {
    margin: 0 0 0.25rem 0;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-item .monitor-info p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-item .monitor-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.monitor-item button {
    align-self: flex-end;
}

.btn-remove {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.btn-remove:hover {
    background: #c82333;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-monitor {
    background: #17a2b8;
    color: white;
}

.badge-owner {
    background: #28a745;
    color: white;
}

.badge-active {
    background: #28a745;
    color: white;
}

.badge-inactive {
    background: #6c757d;
    color: white;
}

/* Modal Large */
.modal-large {
    max-width: 900px;
}

/* Bulk Assignment */
.bulk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

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

.bulk-column {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    background: #f8f9fa;
}

.bulk-column h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: #333;
}

.select-all-row {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

.select-all-row label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: #667eea;
}

.checkbox-list {
    max-height: 300px;
    overflow-y: auto;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: all 0.2s;
}

.checkbox-item:hover {
    background: #e9ecef;
    border-color: #667eea;
}

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

.checkbox-item-label {
    flex: 1;
    cursor: pointer;
    min-width: 0; /* Permite que o flex item encolha */
}

.checkbox-item-label h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.checkbox-item-label p {
    margin: 0;
    font-size: 0.85rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.help-text {
    color: #666;
    font-size: 0.95rem;
    margin: 0 0 1rem 0;
}

/* Available Monitors in Device Screen */
.monitor-select-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 2px solid #e0e0e0;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.monitor-select-item:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.monitor-select-item .monitor-info h4 {
    margin: 0 0 0.25rem 0;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-select-item .monitor-info p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-select-item button {
    white-space: nowrap;
    align-self: flex-end;
}
