/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #0a0e27;
    color: #ffffff;
    line-height: 1.6;
}

/* Container Principal */
.dashboard-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.dashboard-header {
    background-color: #151a3a;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-left h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-left i {
    color: #00d4ff;
}

.project-name {
    color: #00d4ff;
    font-weight: 500;
}

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

.last-update {
    font-size: 0.875rem;
    color: #8892b0;
}

.btn-refresh {
    background-color: #00d4ff;
    color: #0a0e27;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-refresh:hover {
    background-color: #00a8cc;
    transform: rotate(180deg);
}

/* Cards de Estatísticas */
.stats-container {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.stat-card {
    background-color: #151a3a;
    border: 2px solid #2a3154;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #2a3154;
}

.stat-card.online::before { background: #00d4ff; }
.stat-card.good::before { background: #00ff88; }
.stat-card.warning::before { background: #ffd700; }
.stat-card.critical::before { background: #ff6b6b; }
.stat-card.offline::before { background: #6c757d; }

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.stat-card.online .stat-icon { color: #00d4ff; }
.stat-card.good .stat-icon { color: #00ff88; }
.stat-card.warning .stat-icon { color: #ffd700; }
.stat-card.critical .stat-icon { color: #ff6b6b; }
.stat-card.offline .stat-icon { color: #6c757d; }

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: #8892b0;
}

/* Slots Container */
.slots-container {
    flex: 1;
    padding: 0 2rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.slot-box {
    background-color: #151a3a;
    border: 2px solid #2a3154;
    border-radius: 10px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slot-box:hover {
    border-color: #00d4ff;
}

.slot-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.slot-header h2 {
    font-size: 1.5rem;
    color: #00d4ff;
}

.slot-count {
    background-color: #1e2444;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
}

.slot-arrow {
    transition: transform 0.3s ease;
}

.slot-arrow.rotated {
    transform: rotate(180deg);
}

/* Slot Content */
.slot-content {
    padding: 0 1.5rem 1.5rem;
    display: none;
}

.pons-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.75rem;
}

.pon-card {
    background-color: #1e2444;
    border: 2px solid #2a3154;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pon-card:hover {
    transform: translateY(-2px);
    border-color: #00d4ff;
    box-shadow: 0 4px 10px rgba(0, 212, 255, 0.3);
}

.pon-name {
    font-size: 0.875rem;
    color: #8892b0;
    margin-bottom: 0.25rem;
}

.pon-count {
    font-size: 1.25rem;
    font-weight: bold;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background-color: #151a3a;
    margin: 2% auto;
    width: 90%;
    max-width: 1200px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-close {
    background: none;
    border: none;
    color: #8892b0;
    font-size: 2rem;
    cursor: pointer;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* CTO Section */
.cto-section {
    background-color: #1e2444;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #2a3154;
    margin-bottom: 1rem;
}

.cto-title {
    color: #00d4ff;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.onu-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
}

.onu-port {
    aspect-ratio: 1;
    border: 2px solid #2a3154;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    min-height: 80px;
    padding: 0.5rem 0.25rem;
}

.onu-port.empty {
    background-color: #0a0e27;
    opacity: 0.5;
    cursor: default;
}

.onu-port.occupied {
    background-color: #1e2444;
    cursor: pointer;
}

.onu-port.occupied:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.5);
}

.onu-port.good {
    border-color: #00ff88;
    background-color: rgba(0, 255, 136, 0.1);
}

.onu-port.warning {
    border-color: #ffd700;
    background-color: rgba(255, 215, 0, 0.1);
}

.onu-port.critical {
    border-color: #ff6b6b;
    background-color: rgba(255, 107, 107, 0.1);
}

.onu-port.offline {
    border-color: #6c757d;
    background-color: rgba(108, 117, 125, 0.1);
}

.port-number {
    font-weight: bold;
    color: #ffffff;
}

.signal-value {
    font-size: 0.65rem;
    color: #8892b0;
}

.client-name {
    font-size: 0.6rem;
    color: #ffffff;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tabela de ONUs filtradas */
.filtered-results {
    max-height: 70vh;
    overflow-y: auto;
}

.onu-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.onu-table th {
    background-color: #1e2444;
    padding: 0.75rem;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}

.onu-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #2a3154;
}

.onu-table tr:hover {
    background-color: rgba(0, 212, 255, 0.1);
}

.signal-good { color: #00ff88; }
.signal-warning { color: #ffd700; }
.signal-critical { color: #ff6b6b; }
.signal-offline { color: #6c757d; }

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #1e2444;
    border-top: 3px solid #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade */
@media (max-width: 1400px) {
    .stats-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .pons-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* ===== ORIENTAÇÃO MOBILE ===== */
.orientation-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 39, 0.98);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.orientation-content {
    background: rgba(21, 26, 58, 0.95);
    padding: 3rem 2rem;
    border-radius: 20px;
    max-width: 90%;
    border: 2px solid rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
}

.rotate-icon {
    font-size: 4rem;
    color: #00d4ff;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.orientation-content h2 {
    color: #00d4ff;
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.orientation-content p {
    color: #ffffff;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

.rotate-animation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 2rem;
    color: #00ff88;
}

.rotate-animation i:nth-child(1) {
    animation: rotate-phone 3s infinite;
}

.rotate-animation i:nth-child(3) {
    color: #00ff88;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes rotate-phone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
}

/* Mostrar mensagem apenas em portrait mobile */
@media only screen and (max-width: 768px) and (orientation: portrait) {
    .orientation-message {
        display: flex;
    }
    
    /* Esconder dashboard em portrait */
    .dashboard-container {
        display: none;
    }
}

/* Garantir que funcione bem em landscape */
@media only screen and (orientation: landscape), (min-width: 769px) {
    .orientation-message {
        display: none !important;
    }
    
    .dashboard-container {
        display: flex !important;
    }
}

/* Ajustes responsivos para mobile landscape */
@media only screen and (max-width: 896px) and (orientation: landscape) {
    .dashboard-header {
        padding: 0.5rem 1rem;
    }
    
    .dashboard-header h1 {
        font-size: 1.2rem;
    }
    
    .stats-container {
        padding: 1rem;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .slots-container {
        padding: 0 1rem 1rem;
    }
    
    .slot-header {
        padding: 1rem;
    }
    
    .pons-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 0.5rem;
    }
    
    .pon-card {
        padding: 0.5rem;
    }
    
    .pon-name {
        font-size: 0.7rem;
    }
    
    .pon-count {
        font-size: 1rem;
    }
}

/* ===== CORREÇÃO MODAL ONUs MOBILE ===== */
@media only screen and (max-width: 768px) and (orientation: landscape) {
    /* Modal em tela cheia no mobile landscape */
    .modal-content {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    /* Ajustar grid das ONUs para não cortar */
    .onu-grid {
        display: grid !important;
        grid-template-columns: repeat(8, 1fr) !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Cards das ONUs menores mas completos */
    .onu-port {
        width: 100% !important;
        min-width: 0 !important;
        padding: 0.5rem 0.3rem !important;
        font-size: 0.7rem !important;
        box-sizing: border-box !important;
    }
    
    .onu-port .port-number {
        font-size: 0.9rem !important;
    }
    
    .onu-port .onu-signal {
        font-size: 0.65rem !important;
    }
    
    .onu-port .onu-name {
        font-size: 0.6rem !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Modal body com scroll se necessário */
    .modal-body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        padding: 0.75rem !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Garantir que as CTOs não sejam cortadas */
    .cto-section {
        margin-bottom: 1rem !important;
        overflow-x: hidden !important;
    }
    
    /* Header da CTO */
    .cto-header {
        padding: 0.5rem !important;
        font-size: 0.9rem !important;
    }
}

/* Para telas muito pequenas em landscape */
@media only screen and (max-width: 667px) and (orientation: landscape) {
    .onu-grid {
        grid-template-columns: repeat(8, minmax(70px, 1fr)) !important;
        gap: 0.4rem !important;
        font-size: 0.65rem !important;
    }
    
    .onu-port {
        min-height: 60px !important;
    }
}

/* Garantir que nada seja cortado */
@media only screen and (max-width: 896px) and (orientation: landscape) {
    /* Container principal do modal */
    .modal-overlay {
        padding: 0 !important;
    }
    
    /* Prevenir overflow horizontal */
    .modal-content,
    .modal-body,
    .cto-section,
    .onu-grid {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Ajuste fino para 16 portas */
    .onu-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
        width: calc(100% - 1rem) !important;
        margin: 0 0.5rem !important;
    }
}
