/* Importando a fonte Inter do Google Fonts na própria folha de estilo ou no HTML */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #0b5cff;
    --primary-hover: #0848cc;
    --success-color: #10b981;
    --success-bg: #d1fae5;
    --success-border: #a7f3d0;
    --danger-color: #ef4444;
    --danger-bg: #fee2e2;
    --danger-border: #fecaca;
    --background-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--background-color);
    color: var(--text-main);
}

/* TOPBAR: Efeito Glassmorphism Premium */
.topbar {
    width: 100%;
    height: 70px;
    padding: 0 20px;
    position: fixed;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    float: left;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    top: 0;
    transition: all 0.3s ease;
}

.topbar h3 {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.topbar > div {
    flex: 1;
}

.topbar > div:first-child {
    text-align: left;
}

.topbar > div:nth-child(2) {
    text-align: center;
}

.topbar > div:last-child {
    text-align: right;
}

/* Toolbar */
.toolbar {
    width: 100%;
    height: 48px;
    padding: 0 20px;
    position: fixed;
    top: 70px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e7eb;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

.toolbar-btn-danger {
    color: #dc2626;
    background-color: #fef2f2;
    border-color: #fecaca;
}

.toolbar-btn-danger:hover {
    background-color: #fee2e2;
    border-color: #fca5a5;
}

.toolbar-btn-disabled {
    color: #6b7280;
    background-color: #f3f4f6;
    border-color: #e5e7eb;
    cursor: default;
    opacity: 0.7;
}

.toolbar-btn-link {
    color: #059669;
    background-color: #ecfdf5;
    border-color: #a7f3d0;
}

.toolbar-btn-link:hover {
    background-color: #d1fae5;
    border-color: #6ee7b7;
}

.toolbar-icon {
    font-size: 0.9rem;
}

/* Receita Documento */
#receita {
    width: 75%;
    max-width: 900px;
    height: auto;
    min-height: 200px;
    position: relative;
    margin: 180px auto 50px auto; /* Afasta da topbar e toolbar */
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0,0,0,0.05);
    padding: 40px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#receita:hover {
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1), 0 2px 5px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

.row {
    width: 100%;
    height: auto;
    position: relative;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.row:last-child {
    border-bottom: none;
}

.row-sem-borda {
    width: 100%;
    height: auto;
    position: relative;
    padding: 20px 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    border-bottom: none !important;
    line-height: 1.6;
    color: var(--text-main);
}

.logoClinica {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.logoClinica img {
    max-height: 50px;
    width: auto;
}

.titulo {
    flex: 1;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.qr {
    flex: 1;
    text-align: right;
    color: var(--text-muted);
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 500;
    background: #f1f5f9;
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-flex;
    justify-content: flex-end;
}

.left, .pac_left {
    flex: 1;
    min-width: 250px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.right, .pac_right {
    flex: 1;
    min-width: 250px;
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: right;
    color: var(--text-muted);
}

.left b, .pac_left b, .right b, .pac_right b {
    color: var(--text-main);
    font-weight: 600;
}

.quads {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 20px;
    margin-top: 20px;
}

.quad {
    flex: 1;
    position: relative;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 20px;
    font-weight: 500;
    font-size: 0.85rem;
    text-align: center;
    background-color: #f8fafc;
    color: var(--text-muted);
}

.line {
    width: 100%;
    height: auto;
    min-height: 12px;
    position: relative;
    margin-bottom: 12px;
    text-align: left;
    line-height: 1.4;
}

.line[style*="text-align: center"] {
    text-align: center;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 16px;
}

.assinatura {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 40px;
    gap: 5px;
}

.assinatura img {
    filter: contrast(1.2) drop-shadow(0px 2px 4px rgba(0,0,0,0.1));
}

.assinatura span {
    display: block;
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.assinatura span:nth-child(2) {
    color: #e2e8f0;
    letter-spacing: -2px;
}

.assinatura span:nth-child(3) {
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
    margin-top: 4px;
}

/* Botões modernos */
.btn-pdf {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: #fff;
    padding: 12px 32px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
    border: none;
}

.btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-pdf:active {
    transform: translateY(0);
}

.btn-dispensar {
    background: linear-gradient(135deg, var(--primary-color), #2563eb);
    color: white;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(11, 92, 255, 0.3);
}

.btn-dispensar:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(11, 92, 255, 0.4);
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.link-dispensar {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 6px 16px;
    background-color: #eff6ff;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.link-dispensar:hover {
    background-color: #dbeafe;
    color: #1d4ed8;
}

/* Alertas Success/Error repaginados */
.success {
    color: #065f46;
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    padding: 16px 20px;
    border-radius: 8px;
    margin: 10px 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.error {
    color: #991b1b;
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
    padding: 16px 20px;
    border-radius: 8px;
    margin: 10px 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

/* Receita Dispensada - Efeito moderno */
.receita-dispensada::before {
    content: "RECEITA JÁ DISPENSADA";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 4.5rem;
    font-weight: 800;
    color: rgba(239, 68, 68, 0.08); /* Vermelho muito suave para não atrapalhar leitura */
    z-index: 5;
    pointer-events: none;
    white-space: nowrap;
    text-align: center;
    letter-spacing: -0.02em;
    user-select: none;
}

.receita-dispensada-text {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--danger-bg);
    color: #b91c1c;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    border: 1px solid var(--danger-border);
}

/* Orientações ao Farmacêutico */
.orientacoes-farmaceutico {
    width: 100%;
    background-color: #f8fafc;
    padding: 24px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.titulo-orientacoes b {
    color: var(--text-main);
    font-size: 1.1rem;
}

.validacao-receita b {
    color: var(--success-color) !important;
}

/* Receita 2 Vias */
.receita-duas-vias {
    display: flex;
    gap: 2px;
    width: 100%;
    max-width: 1200px;
    margin: 180px auto 50px auto;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

.receita-duas-vias .via-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
}

.receita-duas-vias .via-container:last-child {
    border-right: none;
}

.receita-duas-vias #receita,
.receita-duas-vias #receita-via2 {
    width: 100%;
    margin: 0;
    padding: 20px;
    border: none;
    box-shadow: none;
    border-radius: 0;
    box-sizing: border-box;
    transform: scale(0.65);
    transform-origin: top left;
}

.receita-duas-vias .row:first-child {
    flex-wrap: nowrap;
}

.receita-duas-vias .row:first-child .logoClinica {
    flex: 1;
}

.receita-duas-vias .row:first-child .titulo {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    font-size: 1.1rem;
}

.receita-duas-vias .row:first-child .titulo {
    flex: 1;
    text-align: center;
}

/* Text Selection and Protection */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    user-select: auto; /* Permite seleção no body, mas protege img */
}

img {
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

@media print {
    .btn-pdf, .card-pdf, .topbar, .toolbar, .orientacoes-farmaceutico, .no-print-orientacoes { display: none !important; }
    @page { size: A4 landscape; margin: 8mm 10mm; }
    html, body { 
        background-color: white; 
        margin: 0;
        padding: 0;
        height: 100%;
        overflow: hidden;
    }
    body {
        zoom: 0.92;
    }
    #receita {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 10px;
        width: 100%;
        max-width: none;
        box-sizing: border-box;
    }
    .quad {
        border-color: #333;
    }
    .row {
        page-break-inside: avoid;
        page-break-after: avoid;
        flex-wrap: nowrap;
    }
    .row .titulo {
        font-size: 1rem;
        white-space: nowrap;
        flex: 1;
        text-align: center;
    }
    .row .logoClinica img {
        height: 30px;
    }
    .row .logoClinica {
        flex: 1;
    }
    .row .qr {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
    .left, .pac_left, .right, .pac_right {
        font-size: 0.75rem;
        min-width: auto;
        flex: 1;
    }
    .row-sem-borda {
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    .receita-duas-vias {
        display: flex;
        gap: 0;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        border-radius: 0;
        page-break-inside: avoid;
    }
    .receita-duas-vias .via-container {
        flex: 1;
        border-right: 1px solid #ccc;
        display: flex;
        flex-direction: column;
    }
    .receita-duas-vias .via-container:last-child {
        border-right: none;
    }
    .receita-duas-vias #receita,
    .receita-duas-vias #receita-via2 {
        width: 100%;
        padding: 10px 4%;
        border: none;
        box-shadow: none;
        border-radius: 0;
        background: transparent;
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }
    .receita-duas-vias #receita .quads,
    .receita-duas-vias #receita-via2 .quads {
        margin-top: auto;
    }
}

/* Responsivo */
@media screen and (max-width: 800px) {
    #receita {
        width: 95%;
        padding: 20px;
        margin-top: 100px;
    }
    .row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .qr {
        align-self: flex-start;
        text-align: left;
    }
    .pac_right, .right {
        text-align: left;
        margin-top: 10px;
    }
    .quads {
        flex-direction: column;
    }
    .receita-dispensada::before {
        font-size: 2.5rem;
    }
    .receita-duas-vias {
        flex-direction: column;
        gap: 0;
    }
    .receita-duas-vias .via-container {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .receita-duas-vias .via-container:last-child {
        border-bottom: none;
    }
}

.msg-receita {
    width: 100%;
    border: 2px solid #000;
    padding: 12px 20px;
    margin: 40px 0 15px 0;
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    line-height: 1.5;
    color: #000;
    box-sizing: border-box;
}

.info-vias-centralizada {
    width: 100%;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    padding: 8px 0;
}

@media (max-width: 768px) {
    .login-sidebar {
        width: 100%;
        min-width: 100%;
    }
    .content-area {
        display: none;
    }
}/* Login-style layout */
.login-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

.login-sidebar {
    width: 30%;
    min-width: 350px;
    background-color: var(--card-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
    border-right: 1px solid var(--border-color);
    z-index: 10;
}

.content-area {
    flex: 1;
    background-color: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.content-area::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--card-bg);
    z-index: -1;
}

.validation-info {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 600px;
    padding: 20px;
}

.validation-info::before {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background-color: #8cc63f;
    margin: 0 auto 30px;
    border-radius: 2px;
}

.validation-info p {
    font-size: 1.25rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

.slogan-text {
    font-size: 1.1rem;
    color: #8cc63f;
    font-style: italic;
    font-weight: 500;
    max-width: 500px;
    margin: 0 auto;
    border-top: 1px solid #eee;
    padding-top: 24px;
}

.logo-container {
    text-align: center;
    margin-bottom: 40px;
}

.logo-container img {
    max-width: 280px;
    height: auto;
}

.login-form-wrapper {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    text-align: center;
}

.login-form-wrapper h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #111;
}

.login-form-wrapper > p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: #444;
    text-align: left;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #fff;
    transition: all 0.2s ease;
    outline: none;
    text-transform: uppercase;
}

.form-control:focus {
    border-color: #8cc63f;
    box-shadow: 0 0 0 3px rgba(140, 198, 63, 0.1);
}

.btn-login {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background-color: #8cc63f;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin-top: 10px;
}

.btn-login:hover {
    background-color: #7ab32f;
}

.btn-login:active {
    transform: scale(0.98);
}

.footer-text {
    margin-top: 30px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

#login-alert {
    display: none;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

@media (max-width: 768px) {
    .login-sidebar {
        width: 100%;
        min-width: 100%;
    }
    .content-area {
        display: none;
    }
}