/* ========== RESET & BASE ========== */
* {
    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%);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Oculta exibição do endereço da API na tela de configuração */
#apiInfo {
    display: none !important;
}

/* ========== CONTAINER ========== */
.kiosk-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== HEADER ========== */
.header {
    background: transparent;
    padding: 20px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-spacer {
    width: 52px;
    flex: 0 0 52px;
}

.kiosk-lockBtn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(255, 255, 255, 0.95);
    color: #6b7280;
    box-shadow: none;
    transition: filter .12s ease;
}

.kiosk-lockIcon {
    width: 22px;
    height: 22px;
    display: block;
}

.kiosk-lockBtn:active {
    filter: brightness(.98);
}

.kiosk-lockOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    z-index: 10000;
}

.kiosk-lockOverlay.is-open {
    display: flex;
}

.kiosk-lockModal {
    width: 100%;
    max-width: 520px;
    background: #ffffff;
    border-radius: 24px;
    padding: 26px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.30);
}

.kiosk-lockTitle {
    font-size: 1.6em;
    font-weight: 800;
    color: #111827;
}

.kiosk-lockSubtitle {
    margin-top: 10px;
    color: #6b7280;
    font-size: 1.05em;
}

.kiosk-lockInput {
    margin-top: 18px;
    width: 100%;
    border: 2px solid #dbe3f0;
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 1.2em;
    outline: none;
}

.kiosk-lockInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.12);
}

.kiosk-lockError {
    min-height: 18px;
    margin-top: 10px;
    color: #b91c1c;
    font-weight: 600;
}

.kiosk-lockActions {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.kiosk-lockAction {
    border: none;
    border-radius: 999px;
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;
    transition: filter .12s ease;
}

.kiosk-lockAction:active {
    filter: brightness(.98);
}

.kiosk-lockAction--primary {
    background: #667eea;
    color: #ffffff;
}

.kiosk-lockAction--secondary {
    background: #4b5563;
    color: #ffffff;
}

.logo {
    font-size: 3em;
}

.header h1 {
    font-size: 2.5em;
    color: white;
    flex: 1;
    text-align: center;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.datetime {
    font-size: 1.2em;
    color: white;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* ========== LOADING OVERLAY ========== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 1.8em;
    margin-top: 20px;
    font-weight: 600;
}

/* ========== SCREENS ========== */
.screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 10px 20px;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content {
    background: white;
    padding: 60px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    text-align: center;
}

/* ========== TELA CPF ========== */
.welcome-icon {
    font-size: 6em;
}

.welcome-logo {
    max-height: 120px;
    max-width: 200px;
    height: auto;
    width: auto;
    object-fit: contain;
}

.cpf-screen h2 {
    font-size: 3em;
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.5em;
    color: #666;
    margin-bottom: 40px;
}

.input-group {
    margin: 40px 0;
}

.input-group label {
    display: block;
    font-size: 1.5em;
    color: #333;
    margin-bottom: 15px;
    font-weight: 600;
}

.input-cpf {
    width: 100%;
    padding: 25px 30px;
    font-size: 2.5em;
    border: 3px solid #ddd;
    border-radius: 15px;
    text-align: center;
    letter-spacing: 2px;
    transition: all 0.3s;
}

.input-cpf:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.input-hint {
    font-size: 1.2em;
    color: #999;
    margin-top: 10px;
}

.schedule-cta {
    margin-top: 14px;
}

.schedule-group {
    margin: 22px 0;
    text-align: left;
}

.schedule-label {
    display: block;
    font-size: 1.15em;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 10px;
}

.schedule-select,
.schedule-note {
    font-size: 1.25em;
    letter-spacing: 0;
    text-align: left;
    padding: 18px 20px;
}

.schedule-select {
    appearance: none;
    background-color: #fff;
}

/* ========== TELA SELEÇÃO ========== */
.patient-info h2 {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 10px;
}

.appointments-list {
    margin: 40px 0;
    max-height: 500px;
    overflow-y: auto;
}

.appointment-card {
    background: #f8f9fa;
    border: 3px solid transparent;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    gap: 30px;
    align-items: center;
    text-align: left;
}

.appointment-card.selected {
    border-color: #667eea;
    background: #f0f3ff;
}

.appointment-card.waiting {
    background: #e8f5e9;
    border-color: #4caf50;
}

.appointment-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.time-icon {
    font-size: 3em;
}

.time {
    font-size: 2em;
    font-weight: 700;
    color: #667eea;
    margin-top: 10px;
}

.appointment-details {
    flex: 1;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-row .label {
    font-weight: 600;
    color: #666;
    min-width: 140px;
}

.detail-row .value {
    color: #333;
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95em;
}

.status-badge.status-1 {
    background: #fff3cd;
    color: #856404;
}

.status-badge.status-5 {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-9 {
    background: #d1ecf1;
    color: #0c5460;
}

.waiting-badge {
    display: inline-block;
    padding: 10px 20px;
    background: #4caf50;
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1.1em;
}

/* ========== TELA CONFIRMAÇÃO ========== */
.success-icon {
    font-size: 8em;
    color: #4caf50;
    margin-bottom: 20px;
}

.info-icon {
    font-size: 8em;
    color: #2196f3;
    margin-bottom: 20px;
}

.confirmation-screen h2 {
    font-size: 3em;
    color: #333;
    margin-bottom: 20px;
}

.confirmation-message {
    font-size: 1.8em;
    color: #666;
    margin-bottom: 40px;
    line-height: 1.6;
}

.ticket-box {
    background: #f8f9fa;
    border-radius: 20px;
    padding: 26px 30px;
    margin: 0 auto 40px;
    max-width: 520px;
    border: 3px solid rgba(102, 126, 234, 0.25);
}

.ticket-label {
    font-size: 1.2em;
    color: #666;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ticket-code {
    font-size: 4.2em;
    font-weight: 900;
    color: #667eea;
    margin: 6px 0;
    letter-spacing: 0.08em;
}

.ticket-local {
    font-size: 1.4em;
    color: #333;
    font-weight: 800;
}

.appointment-summary {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 40px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.5em;
    margin-bottom: 15px;
}

.summary-item:last-child {
    margin-bottom: 0;
}

.summary-label {
    font-weight: 600;
    color: #666;
}

.summary-value {
    font-weight: 700;
    color: #667eea;
}

.reset-timer {
    padding: 20px;
    background: #fff3cd;
    border-radius: 15px;
    color: #856404;
    font-size: 1.3em;
    font-weight: 600;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 20px 50px;
    font-size: 1.8em;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-large {
    width: 100%;
    padding: 25px;
    font-size: 2em;
}

.button-group {
    display: flex;
    gap: 20px;
    margin-top: 40px;
}

.button-group .btn {
    flex: 1;
}

/* ========== ERROR MESSAGE ========== */
.error-message {
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    color: #721c24;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: 1.4em;
    margin: 30px 0;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-icon {
    font-size: 2em;
}

/* ========== FOOTER ========== */
.footer {
    background: transparent;
    padding: 20px;
    text-align: center;
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.8);
}

.powered-by {
    margin-top: 15px;
    opacity: 0.7;
}

.powered-logo {
    height: 30px;
    width: auto;
}

/* ========== SCROLLBAR ========== */
.appointments-list::-webkit-scrollbar {
    width: 12px;
}

.appointments-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.appointments-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.appointments-list::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .header {
        padding: 16px 20px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .screen {
        padding: 20px 20px 10px 20px;
    }
    
    .content {
        padding: 30px 20px;
        border-radius: 20px;
    }

    .cpf-screen .content {
        min-height: 70vh;
    }

    .cpf-screen h2 {
        font-size: 2.2em;
    }

    .subtitle {
        font-size: 1.2em;
        margin-bottom: 24px;
    }
    
    .input-cpf {
        font-size: 1.7em;
        padding: 18px 16px;
        letter-spacing: 1px;
    }

    .btn {
        font-size: 1.3em;
        padding: 16px 18px;
    }

    .btn-large {
        font-size: 1.4em;
        line-height: 1.2;
        letter-spacing: 0.5px;
        padding: 18px 14px;
    }
    
    .appointment-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        gap: 14px;
    }

    .appointments-list {
        max-height: none;
        overflow-y: visible;
        margin: 24px 0;
    }

    .appointment-time {
        min-width: auto;
    }

    .time-icon {
        font-size: 2.3em;
    }

    .time {
        font-size: 1.6em;
        margin-top: 4px;
    }

    .detail-row {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .detail-row .label {
        min-width: 0;
    }

    .status-badge {
        font-size: 0.9em;
        padding: 7px 14px;
    }

    .waiting-badge {
        font-size: 1em;
        padding: 8px 14px;
    }
    
    .detail-row {
        flex-direction: row;
        justify-content: center;
        gap: 8px;
    }

    .selection-screen .content {
        padding-top: 22px;
        padding-bottom: 18px;
    }

    .patient-info h2 {
        font-size: 2em;
        margin-bottom: 6px;
    }

    .selection-screen .subtitle {
        margin-bottom: 16px;
        font-size: 1.05em;
    }
    
    .button-group {
        flex-direction: row;
        margin-top: 18px;
    }

    .button-group .btn {
        font-size: 1.15em;
        padding: 14px 10px;
        min-width: 0;
    }

    .confirmation-screen .content {
        padding-top: 24px;
        padding-bottom: 18px;
    }

    .success-icon,
    .info-icon {
        font-size: 5.2em;
        margin-bottom: 12px;
    }

    .confirmation-screen h2 {
        font-size: 2.2em;
        margin-bottom: 14px;
    }

    .confirmation-message {
        font-size: 1.35em;
        line-height: 1.4;
        margin-bottom: 20px;
    }

    .appointment-summary {
        padding: 20px;
        margin-bottom: 18px;
    }

    .summary-item {
        font-size: 1.2em;
        margin-bottom: 10px;
    }

    .reset-timer {
        font-size: 1.05em;
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.35em;
    }

    .screen {
        padding: 12px 20px 6px 20px;
    }

    .content {
        padding: 18px 14px;
        border-radius: 16px;
    }

    .cpf-screen .content {
        min-height: 72vh;
    }

    .selection-screen .content {
        padding-top: 14px;
        padding-bottom: 12px;
    }

    .patient-info h2 {
        font-size: 1.8em;
        line-height: 1.2;
    }

    .selection-screen .subtitle {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    .welcome-logo {
        max-height: 72px;
        max-width: 140px;
    }

    .cpf-screen h2 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
        margin-bottom: 16px;
    }

    .input-group {
        margin: 20px 0;
    }

    .input-cpf {
        font-size: 1.55em;
        padding: 14px 10px;
    }

    .btn {
        font-size: 1.1em;
        letter-spacing: 0;
        padding: 14px 10px;
    }

    .btn-large {
        font-size: 1.1em;
        padding: 14px 10px;
    }

    .appointments-list {
        margin: 16px 0;
    }

    .appointment-card {
        padding: 14px;
        border-radius: 14px;
        gap: 10px;
    }

    .time-icon {
        font-size: 2em;
    }

    .time {
        font-size: 1.35em;
    }

    .detail-row {
        font-size: 1em;
        margin-bottom: 8px;
        gap: 6px;
    }

    .selection-screen .detail-row {
        flex-direction: row;
        justify-content: center;
    }

    .selection-screen .appointment-details .detail-row:first-child {
        flex-direction: column;
        gap: 2px;
    }

    .selection-screen .appointment-details .detail-row:first-child .value {
        max-width: 100%;
        word-break: break-word;
    }

    .selection-screen .detail-row .label,
    .selection-screen .detail-row .value {
        display: inline;
    }

    .selection-screen .appointment-details .detail-row:first-child .label,
    .selection-screen .appointment-details .detail-row:first-child .value {
        display: block;
    }

    .button-group {
        margin-top: 12px;
        gap: 10px;
        flex-direction: row;
    }

    .button-group .btn {
        font-size: 0.95em;
        padding: 12px 8px;
        min-width: 0;
    }

    .confirmation-screen .content {
        padding-top: 14px;
        padding-bottom: 10px;
    }

    .success-icon,
    .info-icon {
        font-size: 4.2em;
        margin-bottom: 8px;
    }

    .confirmation-screen h2 {
        font-size: 1.85em;
        line-height: 1.2;
        margin-bottom: 10px;
    }

    .confirmation-message {
        font-size: 1.05em;
        margin-bottom: 14px;
    }

    .appointment-summary {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 12px;
    }

    .summary-item {
        font-size: 1em;
        margin-bottom: 8px;
    }

    .reset-timer {
        font-size: 0.95em;
        padding: 10px;
        border-radius: 10px;
    }

    .waiting-badge {
        font-size: 0.95em;
    }

    .footer {
        padding: 12px 8px;
        font-size: 1em;
    }
}
