/* ===========================================
   License Certificate Validation - Professional
   =========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --white: #ffffff;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --success: #22c55e;
    --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: #f8fafc;
    color: #0f172a;
    line-height: 1.6;
    min-height: 100vh;
}

/* Top bar */
.validation-topbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.validation-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: #0f172a;
    text-decoration: none;
}

.validation-brand-icon { font-size: 1.5rem; }

.validation-brand-text { color: inherit; }

.validation-admin-link {
    font-size: 0.875rem;
    color: #64748b;
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

.validation-admin-link:hover { color: #2563eb; background: #eff6ff; }

/* Main */
.validation-wrap {
    max-width: 42rem;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.validation-wrap.validation-wrap-wide {
    max-width: 56rem;
}

.validation-hero {
    text-align: center;
    margin-bottom: 2rem;
}

.validation-hero h1 {
    font-size: 1.625rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.validation-hero p {
    font-size: 0.9375rem;
    color: #64748b;
    max-width: 36rem;
    margin: 0 auto;
}

/* Card */
.validation-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.validation-form-content { max-width: 100%; }

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

.input-group label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper input {
    width: 100%;
    min-width: 0;
    padding: 0.75rem 3rem 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.camera-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-btn:hover { color: var(--primary); background: var(--primary-50); }

.btn-validate {
    padding: 0.625rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-validate:hover { background: var(--primary-hover); }

/* Info section */
.info-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}

.info-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.info-section ol {
    margin-left: 1.25rem;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.8;
}

.info-section ol li strong { color: #0f172a; }

/* QR Modal */
.qr-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.qr-modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 28rem;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.qr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.qr-modal-header h3 { font-size: 1rem; font-weight: 600; }

.close-btn {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.close-btn:hover { background: var(--bg); color: var(--text); }

.qr-modal-body { padding: 1.25rem; }

#qr-reader { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* Validation result (validate.php) */
.validation-result {
    padding: 2rem 1.5rem;
    text-align: center;
}

.validation-result.validation-result-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.validation-result.valid .validation-result-card,
.validation-result.valid { background: #f0fdf4; border-color: #bbf7d0; }
.validation-result.invalid,
.validation-result.error { background: #fef2f2; border-color: #fecaca; }

.result-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

.validation-result h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1.25rem; color: #0f172a; }

.certificate-details {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.25rem 1.5rem;
    margin: 0 auto;
    max-width: 28rem;
    text-align: left;
}

.detail-row {
    display: flex;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

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

.detail-label { font-weight: 500; color: var(--text-muted); width: 10rem; flex-shrink: 0; }

.detail-value { color: var(--text); }

.detail-value.status-active { color: var(--success); font-weight: 500; }

.detail-value.status-revoked { color: var(--danger); font-weight: 500; }

.certificate-preview-section {
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
    margin-bottom: 1.5rem;
}

.preview-header { margin-bottom: 1rem; }
.preview-header h3 { font-size: 1rem; font-weight: 600; color: #0f172a; }

/* License Agreement section */
.agreement-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.agreement-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 1rem;
}

.agreement-actions {
    margin-bottom: 1rem;
}

.btn-agreement {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    background: #3b82f6;
    color: #fff;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-agreement:hover { background: #2563eb; }

.agreement-pdf-wrap {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f8fafc;
}

.agreement-pdf-iframe {
    width: 100%;
    height: 480px;
    border: none;
    display: block;
}

.agreement-placeholder {
    font-size: 0.875rem;
    color: #64748b;
}

.agreement-placeholder code {
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.8125rem;
}

.certificate-frame {
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    background: var(--white);
}

.verified-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
}

/* Certificate preview (validate.php) */
.certificate-canvas {
    position: relative;
    width: 100%;
    transform-origin: top left;
}

.certificate-canvas img.template-bg {
    width: 100%;
    height: auto;
    display: block;
}

.certificate-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.cert-element {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    user-select: none;
}

.cert-element.text-el { overflow: hidden; }

.cert-element img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.no-preview {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.no-preview-icon { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.6; }

.certificate-frame {
    position: relative;
    -webkit-user-select: none;
    user-select: none;
}

.certificate-frame img { pointer-events: none; }

@media (max-width: 640px) {
    .validation-wrap { padding: 1rem; }
    .validation-hero h1 { font-size: 1.25rem; }
    .detail-row { flex-direction: column; gap: 0.25rem; }
    .detail-label { width: 100%; }
}
