/* Reset e configurações globais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
}

/* Cabeçalho principal */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.main-header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.upload-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.upload-button, .process-button, .save-button {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.process-button {
    background: linear-gradient(45deg, #e67e22, #f39c12);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.3);
}

.process-button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    box-shadow: none;
}

.upload-button:hover, .save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
    background: linear-gradient(45deg, #219a52, #27ae60);
}

.process-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
    background: linear-gradient(45deg, #d68910, #e67e22);
}

.print-button {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.print-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
    background: linear-gradient(45deg, #2980b9, #1f5582);
}

.print-button:active {
    transform: translateY(0);
}

/* Container principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Painel de informações */
.info-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.info-row {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.info-panel p {
    font-size: 1.1rem;
    font-weight: 500;
    color: #2c3e50;
    margin: 0.5rem 0;
}

.info-panel span {
    color: #3498db;
    font-weight: 700;
}

.status-message {
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
    margin-top: 1rem;
    display: none;
}

.status-message.success {
    background: rgba(46, 204, 113, 0.1);
    color: #27ae60;
    border: 1px solid #2ecc71;
    display: block;
}

.status-message.error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border: 1px solid #e74c3c;
    display: block;
}

.status-message.loading {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
    border: 1px solid #3498db;
    display: block;
}

/* Painel de configuração */
.config-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.config-panel h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    text-align: center;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.config-row label {
    font-weight: 600;
    color: #2c3e50;
}

.config-row input[type="password"] {
    flex: 1;
    max-width: 300px;
    padding: 0.8rem;
    border: 2px solid #e8eaf0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.config-row input[type="password"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Container das etiquetas */
.labels-container {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

/* Grid das etiquetas para visualização */
.labels-page {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 8mm;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 20mm auto;
    padding: 20mm;
    page-break-after: always;
    background: white;
}

.labels-page:last-child {
    page-break-after: auto;
}

/* Etiqueta individual */
.label {
    width: 85mm;
    height: 32mm;
    border: 2px solid #e8eaf0;
    border-radius: 8px;
    padding: 6mm;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.label:hover {
    border-color: #3498db;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
    transform: translateY(-1px);
}

/* Cabeçalho da etiqueta - HFAG */
.label-header {
    text-align: center;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 4mm;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border-bottom: 2px solid #3498db;
    padding-bottom: 2mm;
}

/* Informações do paciente */
.label-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2mm;
}

.label-field {
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.3;
}

.label-field strong {
    color: #34495e;
    font-weight: 700;
}

.patient-name {
    font-size: 12px;
    color: #2c3e50;
    font-weight: 600;
}

.patient-room {
    font-size: 11px;
    color: #7f8c8d;
    font-weight: 500;
}

/* Estilos para impressão */
@media print {
    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    .main-header,
    .info-panel,
    .config-panel {
        display: none;
    }

    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .labels-container {
        background: white;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
        margin: 0;
    }

    .labels-page {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 15mm;
        page-break-after: always;
        gap: 6mm;
    }

    .labels-page:last-child {
        page-break-after: auto;
    }

    .label {
        width: 85mm;
        height: 32mm;
        border: 1.5px solid #333;
        border-radius: 6px;
        padding: 4mm;
        background: white;
        box-shadow: none;
        break-inside: avoid;
    }

    .label:hover {
        border-color: #333;
        box-shadow: none;
        transform: none;
    }

    .label-header {
        font-size: 14px;
        color: #000;
        text-shadow: none;
        border-bottom: 1px solid #333;
        margin-bottom: 3mm;
        padding-bottom: 1mm;
    }

    .label-field {
        font-size: 10px;
        color: #000;
    }

    .label-field strong {
        color: #000;
    }

    .patient-name {
        font-size: 11px;
        color: #000;
    }

    .patient-room {
        font-size: 10px;
        color: #000;
    }
}

/* Responsividade */
@media (max-width: 768px) {
    .main-header {
        padding: 1.5rem 1rem;
    }

    .main-header h1 {
        font-size: 2rem;
    }

    .header-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .upload-section {
        flex-direction: column;
        width: 100%;
    }

    .upload-button, .process-button, .print-button {
        width: 100%;
        justify-content: center;
    }

    .container {
        padding: 0 1rem;
    }

    .info-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .config-row {
        flex-direction: column;
        align-items: stretch;
    }

    .config-row input[type="password"] {
        max-width: none;
    }

    .labels-page {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(14, auto);
        width: 100%;
        padding: 1rem;
        min-height: auto;
    }

    .label {
        width: 100%;
        height: auto;
        min-height: 80px;
    }
}