/* reader.css */
.reader-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--background-gray);
    padding-bottom: 4rem;
}

.reader-envelope {
    background: var(--white);
    max-width: 900px;
    margin: 2rem auto 0;
    width: 95%;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Document Header (Inside envelope) */
.reader-header {
    padding: 3rem 4rem 1rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.reader-header-actions {
    position: absolute;
    right: 2.5rem;
    top: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
}

.action-btn {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    color: #4B5563;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.action-btn:hover {
    background-color: #F9FAFB;
}

.tts-speed-select {
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: #4B5563;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
    height: 38px;
}

.reader-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.reader-badge.general { background-color: #ECFDF5; color: #047857; }
.reader-badge.compliance { background-color: #EFF6FF; color: #1D4ED8; }
.reader-badge.safety { background-color: #FEF2F2; color: #A03E21; }
.reader-badge.clinical { background-color: #F8FAFC; color: #334155; }

.reader-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.reader-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-gray);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Document Content Body */
.reader-content {
    padding: 3rem 4rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #374151;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE/Edge */
    user-select: none; /* Prevent text highlighting */
    -webkit-touch-callout: none; /* Prevent iOS callouts */
}

.reader-content h1, .reader-content h2, .reader-content h3 {
    color: var(--text-dark);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.reader-content p {
    margin-bottom: 1.5rem;
}

/* Certification Signature Block */
.certification-block {
    background: #FAFAFA;
    padding: 3rem 4rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

.cert-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #1A202C; /* Dark, slightly blue-tinted slate */
    margin-bottom: 1rem;
}

.cert-desc {
    font-size: 0.95rem;
    color: #4A5568;
    line-height: 1.6;
    margin-bottom: 2.5rem;
    max-width: 700px;
}

/* Input Grid structure matching screenshot */
.cert-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.cert-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cert-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cert-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #1A202C;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    transition: all 0.2s ease;
}

/* Multi-Modal Signature Extensions */
.cert-mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.btn-sig-mode {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sig-mode.active {
    background: #EFF6FF;
    border-color: #3B82F6;
    color: #1D4ED8;
}

.signature-font-selector {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-dark);
    background: var(--white);
    outline: none;
    margin-right: -1.25rem; /* align seamlessly in input group */
    align-self: stretch; /* Stretch to input height */
}

.font-inter { font-family: 'Inter', sans-serif !important; }
.font-caveat { font-family: 'Caveat', cursive !important; font-size: 1.5rem !important; font-weight: 500 !important; }
.font-dancing { font-family: 'Dancing Script', cursive !important; font-size: 1.5rem !important; font-weight: 500 !important; }
.font-pacifico { font-family: 'Pacifico', cursive !important; font-size: 1.25rem !important; font-weight: 400 !important; }

.canvas-container {
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    background: var(--white);
    position: relative;
    width: 100%;
    margin-top: 0.5rem;
}

.signature-canvas {
    width: 100%;
    height: 150px;
    cursor: crosshair;
    border-radius: 6px;
    touch-action: none; /* Prevent scrolling while drawing */
}

.btn-clear-canvas {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: #F1F5F9;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
}
.btn-clear-canvas:hover { background: #E2E8F0; }

/* Specific styling for the read-only date field */
.cert-date-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 1.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: #1A202C;
    background: #F8FAFC; /* Slightly different gray for read-only */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    user-select: none;
}

.cert-date-display i {
    color: #94A3B8;
    font-size: 1rem;
}

/* Placeholder specific styling */
.cert-input::placeholder {
    color: #9CA3AF;
    font-weight: 700;
}

.cert-input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Submission Action */
.cert-action-container {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 3rem;
}

.btn-certify {
    background-color: #F1F5F9; /* Light slate blue-gray */
    color: #64748B;
    border: none;
    border-radius: 8px;
    padding: 1rem 3rem;
    font-size: 1.1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: max-content;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Dynamic active states based on input validity */
.btn-certify.active {
    background-color: var(--primary-blue);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.btn-certify.active:hover {
    background-color: var(--primary-blue-hover);
}

.btn-certify.submitting {
    background-color: #005F54; /* Success Green */
    color: var(--white);
}

/* Certification Log Footer inside Block */
.cert-log-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

.log-status {
    font-size: 0.7rem;
    font-weight: 800;
    color: #9CA3AF;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.log-status .dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary-blue);
    border-radius: 50%;
}

.log-hash {
    font-size: 0.7rem;
    font-weight: 600;
    color: #CBD5E1;
    font-family: monospace;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .reader-envelope {
        margin: 1rem auto 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .cert-form-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .btn-certify {
        width: 100%;
    }

    .reader-header, .reader-content, .certification-block {
        padding: 2rem 1.5rem;
    }

    .reader-title {
        font-size: 2rem;
    }
    
    .reader-header-actions {
        position: static;
        flex-wrap: wrap;
        justify-content: flex-start;
        margin-bottom: 1.5rem;
        gap: 0.5rem;
    }
}

/* SECURITY: Print/PDF Block Data Loss Deterrent */
@media print {
    body * {
        display: none !important;
    }
    body::before {
        content: "SECURITY VIOLATION: Printing or saving this proprietary Clarafyed training material to PDF is strictly prohibited and has been logged.";
        display: block !important;
        font-family: 'Inter', sans-serif;
        font-size: 2rem;
        font-weight: bold;
        color: black;
        text-align: center;
        margin-top: 20%;
        padding: 40px;
    }
}
