* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 0;
}

.container {
    max-width: 100%;
    margin: 0;
    background: white;
    min-height: 100vh;
}

header {
    background: #0C326F;
    color: white;
    padding: 12px 40px;
    border-bottom: 4px solid #168821;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: space-between;
}

.logo {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.header-text {
    flex: 1;
}

.header-relogio {
    text-align: center;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0 20px;
    min-width: 180px;
}

.header-relogio .relogio-label {
    font-size: 0.75em;
    font-weight: 600;
    margin-bottom: 3px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-relogio .relogio-data {
    font-size: 0.85em;
    font-weight: 500;
    margin-bottom: 2px;
    opacity: 0.95;
}

.header-relogio .relogio-hora {
    font-size: 1.4em;
    font-weight: 700;
    letter-spacing: 1px;
    font-family: 'Courier New', monospace;
}

.header-info {
    text-align: center;
    padding: 0 20px;
    min-width: 280px;
}

.header-info p {
    margin: 3px 0;
    font-size: 0.85em;
    line-height: 1.4;
}

.header-info .desenvolvido {
    font-weight: 600;
    font-size: 0.8em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-info .prefeitura {
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 5px;
}

.header-info .email {
    font-size: 0.8em;
    opacity: 0.95;
    font-weight: 500;
}

header h1 {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 3px;
}

header p {
    font-size: 0.95em;
    opacity: 0.95;
    font-weight: 300;
}

.toggle-controls-btn {
    width: 100%;
    padding: 10px 40px;
    background: #f8f9fa;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    color: #0C326F;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-controls-btn:hover {
    background: #e9ecef;
}

.toggle-controls-btn #toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s ease;
    display: inline-block;
}

.toggle-controls-btn.collapsed #toggle-icon {
    transform: rotate(-90deg);
}

.controls {
    padding: 20px 40px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 30px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.controls.collapsed {
    max-height: 0;
    padding: 0 40px;
    border-bottom: none;
}

.btn-refresh {
    background: #168821;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #146d1c;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(22, 136, 33, 0.3);
}

.controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    cursor: pointer;
    color: #333;
}

.unidade-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.unidade-selector label {
    font-weight: 600;
    color: #0C326F;
}

.unidade-selector select {
    min-width: 280px;
    padding: 8px 10px;
    border: 1px solid #d0d7de;
    border-radius: 4px;
    font-size: 0.9em;
    background: #fff;
    color: #1f2328;
}

.unidade-selector select:focus {
    outline: none;
    border-color: #0C326F;
}

.btn-config-delay {
    background: #0C326F;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-config-delay:hover {
    background: #0a2859;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(12, 50, 111, 0.3);
}

.auto-refresh-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.last-update {
    color: #666;
    font-size: 0.85em;
    font-style: italic;
}

.last-update.updating {
    color: #168821;
    font-weight: 600;
}

.no-unidade-warning {
    margin: 20px 40px;
    padding: 15px 18px;
    border: 1px solid #ffc107;
    border-radius: 6px;
    background: #fff3cd;
    color: #856404;
    font-weight: 600;
}

.controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Configuração do Vídeo */
.video-config {
    padding: 20px 40px;
    background: #f0f7ff;
    border-bottom: 1px solid #d0e4ff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
    margin-bottom: 15px;
}

.config-content {
    max-width: 1200px;
    margin: 0 auto;
}

.config-content label {
    display: block;
    color: #0C326F;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.input-group input[type="text"] {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #d0e4ff;
    border-radius: 4px;
    font-size: 0.95em;
    transition: border-color 0.2s;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #168821;
}

.btn-salvar {
    background: #168821;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-salvar:hover {
    background: #146d1c;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(22, 136, 33, 0.3);
}

.config-content small {
    color: #666;
    font-size: 0.85em;
    display: block;
    margin-top: 5px;
}

/* Configuração de Volume */
.volume-config {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #d0e4ff;
}

.volume-config label {
    display: block;
    color: #0C326F;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.volume-control input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #d0e4ff;
    outline: none;
    -webkit-appearance: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #168821;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.volume-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #168821;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.volume-value {
    min-width: 50px;
    text-align: center;
    font-weight: 700;
    color: #168821;
    font-size: 1.1em;
}

/* Modal de Configuração de Delay */
.delay-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(12, 50, 111, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    animation: fadeIn 0.3s;
}

.delay-modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    border-top: 4px solid #168821;
}

.delay-modal-content h3 {
    color: #0C326F;
    font-size: 1.5em;
    margin-bottom: 20px;
    font-weight: 600;
}

.delay-config {
    margin-bottom: 25px;
}

.delay-config label {
    display: block;
    color: #0C326F;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.95em;
}

.delay-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.delay-control input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #d0e4ff;
    outline: none;
    -webkit-appearance: none;
}

.delay-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #0C326F;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.delay-control input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #0C326F;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.delay-value {
    min-width: 50px;
    text-align: center;
    font-weight: 700;
    color: #0C326F;
    font-size: 1.3em;
}

.delay-config small {
    color: #666;
    font-size: 0.85em;
    display: block;
}

.delay-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-cancelar {
    background: #666;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-cancelar:hover {
    background: #555;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Wrapper para Status e Vídeo lado a lado */
.status-video-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 20px;
}

/* Container do Vídeo */
.video-container {
    flex: 1;
    padding: 0;
    background: transparent;
    position: relative;
    z-index: 5;
}

.video-header {
    margin: 0 0 10px;
    display: flex;
    justify-content: flex-end;
}

.btn-reconfigurar {
    background: #0C326F;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-reconfigurar:hover {
    background: #0a2859;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(12, 50, 111, 0.3);
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* Aspect ratio 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    background: #000;
}

/* M3U wrapper precisa de altura fixa para vídeo renderizar */
#m3u-wrapper {
    padding-bottom: 56.25%; /* Aspect ratio 16:9 */
    height: 0;
    min-height: 0;
    background: #000;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Elemento video precisa de altura fixa, não funciona com padding-bottom */
.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pacientes-list {
    padding: 40px;
    background: #fafafa;
    min-height: calc(100vh - 200px);
}

#sistema-ativo.hidden {
    display: none;
}

#tabela-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-top: 20px;
}

/* Sistema Ativo - Status Display */
.sistema-ativo {
    display: flex;
    align-items: center;
    gap: 24px;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    min-width: 400px;
    flex-shrink: 0;
}

.status-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #168821, #0C326F);
    position: relative;
    flex-shrink: 0;
    animation: pulse-icon 2s infinite;
}

.status-icon::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes pulse-icon {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(22, 136, 33, 0.5);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(22, 136, 33, 0);
    }
}

.status-info h2 {
    color: #0C326F;
    font-size: 1.6em;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.status-info p {
    color: #666;
    margin: 4px 0;
    font-size: 1em;
    line-height: 1.5;
}

.update-info {
    margin-top: 12px !important;
    padding-top: 12px;
    border-top: 1px solid #e8e8e8;
    font-size: 0.9em !important;
    color: #888 !important;
}

.pacientes-count {
    font-weight: 600;
    color: #168821;
}

/* Últimos Chamados */
.ultimos-chamados {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
}

.ultimos-chamados h3 {
    font-size: 0.9em;
    color: #0C326F;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.lista-ultimos-chamados {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lista-ultimos-chamados .chamado-item {
    font-size: 0.85em;
    color: #555;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.lista-ultimos-chamados .chamado-item .nome {
    font-weight: 600;
    color: #333;
}

.lista-ultimos-chamados .chamado-item .sala {
    font-size: 0.8em;
    color: #168821;
    font-weight: 500;
}

.lista-ultimos-chamados .sem-chamados {
    font-size: 0.85em;
    color: #999;
    font-style: italic;
}

#tabela-pacientes {
    width: 100%;
    border-collapse: collapse;
    background: white;
    transition: opacity 0.3s ease;
}

#tabela-pacientes thead {
    background: #0C326F;
    color: white;
}

#tabela-pacientes th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#tabela-pacientes td {
    padding: 14px 16px;
    border-bottom: 1px solid #e8e8e8;
    font-size: 0.95em;
}

#tabela-pacientes tbody tr {
    transition: all 0.2s;
}

#tabela-pacientes tbody tr:hover {
    background: #f9f9f9;
}

#tabela-pacientes tbody tr.chamado {
    background: #e8f5e9;
    border-left: 4px solid #168821;
}

thead {
    background: #0C326F;
    color: white;
}

th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid #e8e8e8;
    font-size: 0.95em;
}

tbody tr {
    transition: all 0.2s;
}

tbody tr:hover {
    background: #f9f9f9;
}

tbody tr.chamado {
    background: #e8f5e9;
    border-left: 4px solid #168821;
}

.nome-paciente strong {
    color: #0C326F;
    font-size: 1em;
    font-weight: 600;
}

.data-hora {
    color: #555;
    font-size: 0.9em;
    white-space: nowrap;
}

.sala {
    color: #168821;
    font-weight: 600;
    font-size: 0.95em;
}

.info {
    color: #666;
    font-size: 0.88em;
}

.btn-chamar {
    background: #168821;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-chamar:hover {
    background: #146d1c;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(22, 136, 33, 0.3);
}

.btn-chamar:active {
    transform: translateY(0);
}

.chamada-display {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(12, 50, 111, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.chamada-content {
    background: white;
    padding: 60px 80px;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 800px;
    width: 90%;
    border-top: 6px solid #168821;
}

.chamada-content h2 {
    color: #0C326F;
    font-size: 2em;
    margin-bottom: 30px;
    font-weight: 600;
}

.nome-chamado {
    font-size: 2.5em;
    color: #0C326F;
    font-weight: 700;
    margin-bottom: 40px;
    line-height: 1.3;
}

.btn-fechar {
    background: #0C326F;
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-fechar:hover {
    background: #0a2859;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(12, 50, 111, 0.4);
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 1.1em;
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Responsivo */
@media (max-width: 768px) {
    header {
        padding: 15px 20px;
    }
    
    .logo {
        height: 40px;
    }
    
    .header-content {
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .header-info {
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.3);
        padding-left: 0;
        padding-top: 10px;
        width: 100%;
        text-align: center;
        min-width: auto;
    }
    
    .header-info p {
        font-size: 0.75em;
    }
    
    .header-info .prefeitura {
        font-size: 0.85em;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    .controls {
        padding: 15px 20px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .video-config {
        padding: 15px 20px;
        margin-bottom: 15px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group input[type="text"] {
        width: 100%;
    }
    
    .btn-salvar {
        width: 100%;
    }
    
    .volume-config {
        margin-top: 15px;
        padding-top: 15px;
    }
    
    .volume-control {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .volume-value {
        text-align: left;
    }
    
    .video-container {
        padding: 15px 0;
    }
    
    .video-wrapper {
        max-width: 100%;
        margin: 0 20px;
        padding-bottom: 40%; /* Aspect ratio mais alto em mobile */
    }
    
    .video-header {
        margin: 0 20px 10px;
    }
    
    .btn-reconfigurar {
        font-size: 0.8em;
        padding: 5px 10px;
    }
    
    .pacientes-list {
        padding: 20px;
    }
    
    #tabela-container {
        overflow-x: auto;
    }
    
    .sistema-ativo {
        flex-direction: column;
        text-align: center;
        padding: 30px 20px;
    }
    
    .status-icon {
        width: 60px;
        height: 60px;
    }
    
    .status-icon::after {
        width: 24px;
        height: 24px;
    }
    
    .status-info h2 {
        font-size: 1.3em;
    }
    
    .status-info p {
        font-size: 0.9em;
    }
    
    #tabela-pacientes {
        font-size: 0.85em;
    }
    
    #tabela-pacientes th, 
    #tabela-pacientes td {
        padding: 10px 8px;
    }
    
    .chamada-content {
        padding: 40px 30px;
    }
    
    .nome-chamado {
        font-size: 1.8em;
    }
}

/* Impressão */
@media print {
    .controls, .btn-chamar, .chamada-display {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    #tabela-pacientes {
        box-shadow: none;
    }
}
