/* PDF Auto Signer v2.0 - Custom Stylesheet */

:root {
    /* Reference UI palette: white surfaces with calm emerald actions */
    --primary: #168a5b;
    --primary-hover: #0f704a;
    --secondary: #475569;
    --accent: #1aa66e;
    --accent-violet: #64748b;
    --success: #168a5b;
    --danger: #dc5b5b;
    --warning: #c88a2d;
    --bg-page: #f7faf8;
    --card-bg: #ffffff;
    --ink: #17231e;
    --muted: #718078;
    --border: #e3ebe6;
    --soft-blue: #edf8f2;
    --soft-teal: #edf9f3;
    --soft-violet: #f2f6f4;
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--ink);
    direction: rtl;
    text-align: right;
    -webkit-tap-highlight-color: transparent;
}

.app-body { min-height: 100vh; }

/* Shared authenticated layout */
.app-sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    width: 270px;
    background: #fff;
    border-left: 1px solid var(--border);
    padding: 22px 16px 18px;
    display: flex;
    flex-direction: column;
    z-index: 40;
}
.app-brand, .app-mobile-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.app-brand { padding: 4px 8px 26px; border-bottom: 1px solid #f0f3f1; }
.app-brand-mark, .login-brand-mark {
    width: 40px; height: 40px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff; box-shadow: 0 8px 20px rgba(22, 138, 91, .18);
}
.app-brand h1 { font-size: 14px; font-weight: 800; line-height: 1.6; }
.app-brand p { color: var(--muted); font-size: 10px; }
.app-sidebar-section { color: #9aa7a0; font-size: 10px; font-weight: 700; margin: 23px 10px 8px; }
.app-sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.app-nav-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 11px; color: #68766e; font-size: 13px; font-weight: 600; transition: .2s ease; }
.app-nav-item:hover { color: var(--primary); background: #f1f8f4; }
.app-nav-active { color: var(--primary) !important; background: #eaf6ef; box-shadow: inset -3px 0 0 var(--primary); }
.app-sidebar-user { margin-top: auto; border-top: 1px solid #f0f3f1; padding: 17px 6px 12px; display: flex; gap: 9px; align-items: center; }
.app-avatar { width: 34px; height: 34px; flex: 0 0 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #dff3e7; color: var(--primary); }
.app-sidebar-user strong, .app-sidebar-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sidebar-user strong { font-size: 12px; } .app-sidebar-user span { color: var(--muted); font-size: 10px; margin-top: 2px; direction: ltr; text-align: right; }
.app-logout { color: #87938c; font-size: 12px; display: flex; gap: 9px; align-items: center; padding: 9px 10px; border-radius: 9px; }
.app-logout:hover { color: #c45353; background: #fff3f3; }
.app-topbar { position: fixed; top: 0; right: 270px; left: 0; height: 68px; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; z-index: 30; }
.app-topbar-actions { display: flex; align-items: center; gap: 12px; }
.app-status { color: #76847b; font-size: 11px; } .app-status i { color: var(--primary); font-size: 7px; margin-left: 5px; }
.app-mobile-brand, .app-mobile-nav, .app-mobile-menu { display: none; }
.app-body main { width: auto; max-width: none; margin-right: 270px; padding: 104px 42px 42px; }

/* Login */
.app-body .login-shell { margin: 0 !important; padding: 0 !important; width: auto; max-width: none; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(480px, .95fr); direction: ltr; background: #fff; }
.login-promo { position: relative; overflow: hidden; background: #25855c; color: #fff; min-height: 100vh; direction: rtl; display: flex; align-items: center; justify-content: center; padding: 56px; }
.login-promo-grid { position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.45) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.45) 1px, transparent 1px); background-size: 46px 46px; }
.login-promo-orbit { position: absolute; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; pointer-events: none; }
.login-promo-orbit-one { width: 520px; height: 520px; top: -260px; left: -180px; } .login-promo-orbit-two { width: 620px; height: 620px; bottom: -350px; right: -250px; }
.login-promo-content { position: relative; z-index: 1; max-width: 500px; text-align: center; }
.login-promo-mark { width: 66px; height: 66px; border: 1px solid rgba(255,255,255,.4); border-radius: 20px; margin: 0 auto 24px; display: flex; align-items: center; justify-content: center; font-size: 27px; background: rgba(255,255,255,.12); }
.login-eyebrow { font-size: 12px; opacity: .78; margin-bottom: 13px; } .login-promo h2 { font-size: clamp(28px, 3vw, 42px); line-height: 1.65; font-weight: 800; } .login-promo-content > p:not(.login-eyebrow) { max-width: 440px; margin: 20px auto 0; line-height: 2; font-size: 14px; color: rgba(255,255,255,.78); }
.login-feature-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px 18px; margin-top: 29px; color: rgba(255,255,255,.9); font-size: 11px; } .login-feature-list i { margin-left: 5px; color: #bff1d2; }
.login-panel { direction: rtl; display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; } .login-panel-inner { width: 100%; max-width: 430px; }
.login-brand-mark { margin: 0 auto 12px; width: 52px; height: 52px; border-radius: 16px; font-size: 21px; }
.login-panel .glass-card { border-color: #e5ece7; box-shadow: 0 22px 50px -28px rgba(32,70,51,.25); }

@media (max-width: 900px) {
    .app-sidebar { display: none; } .app-topbar { right: 0; padding: 0 18px; } .app-mobile-brand, .app-mobile-menu { display: flex; align-items: center; gap: 8px; } .app-mobile-brand .app-brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; } .app-mobile-menu { border: 0; background: none; color: var(--primary); font-size: 18px; } .app-mobile-nav { position: fixed; top: 68px; right: 0; left: 0; background: #fff; border-bottom: 1px solid var(--border); padding: 10px 14px; z-index: 29; display: none; flex-wrap: wrap; gap: 4px; } .app-mobile-nav.is-open { display: flex; } .app-mobile-nav .app-nav-item { flex: 1 1 45%; } .app-body main { margin-right: 0; padding: 94px 18px 28px; }
    .login-shell { display: block; } .login-promo { min-height: 300px; padding: 38px 24px; } .login-promo h2 { font-size: 25px; } .login-promo-content > p:not(.login-eyebrow), .login-feature-list { display: none; } .login-panel { padding: 32px 18px 42px; }
}


/* Glassmorphism card */
.glass-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(219, 227, 240, 0.9);
    box-shadow: 0 18px 45px -22px rgba(37, 63, 120, 0.28), 0 8px 18px -10px rgba(15, 23, 42, 0.08);
    border-radius: 1.15rem;
}

/* Upload Dropzones */
.dropzone {
    border: 2px dashed #cbd5e1;
    transition: all 0.25s ease-in-out;
    background-color: #f8faff;
    cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background-color: var(--soft-teal);
    transform: translateY(-2px);
}

/* Stamp Preview Checkerboard */
.checkerboard-bg {
    background-color: #ffffff;
    background-image: linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
                      linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
                      linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* Animations */
.animate-fade-in { animation: fadeIn 0.35s ease-out forwards; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-pulse-slow { animation: pulseSlow 2s ease-in-out infinite; }
@keyframes pulseSlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* OTP input styling */
.otp-input {
    width: 3rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid #cbd5e1;
    border-radius: 0.75rem;
    background: #ffffff;
    color: #0f172a;
    transition: all 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}
.otp-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
    transform: scale(1.05);
}
.otp-input.filled {
    border-color: var(--primary);
    background-color: var(--soft-blue);
}

/* Canvas for signature */
#signature-canvas, .signature-canvas {
    background-color: #ffffff;
    background-image:
        linear-gradient(transparent 0, transparent calc(100% - 1px), #e2e8f0 calc(100% - 1px), #e2e8f0 100%),
        linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), #e2e8f0 calc(100% - 1px), #e2e8f0 100%);
    background-size: 25px 25px;
    touch-action: none;
    cursor: crosshair;
    border: 2px solid #cbd5e1;
    border-radius: 0.75rem;
}

/* Signature canvas mode toggle */
.canvas-mode-active {
    background: linear-gradient(135deg, #168a5b 0%, #35b779 100%);
    color: white;
    border-color: #0f704a;
}

/* Score gauge */
.score-ring {
    --score: 0;
    --color: #ef4444;
    background: conic-gradient(var(--color) calc(var(--score) * 1%), #e2e8f0 0);
    border-radius: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.score-ring::after {
    content: '';
    position: absolute;
    inset: 8px;
    background: #fff;
    border-radius: 50%;
}
.score-ring > span {
    position: relative;
    z-index: 1;
    font-size: 1.6rem;
    font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Range slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 25px -5px rgba(0,0,0,0.3);
    z-index: 1000;
    font-size: 14px;
    animation: toast-in 0.3s ease-out;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.warning { background: #d97706; }
@keyframes toast-in {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* PDF preview overlay */
.pdf-preview-wrap {
    position: relative;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #f1f5f9;
}
.pdf-preview-marker {
    position: absolute;
    border: 3px dashed #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 4px;
    pointer-events: none;
}
.pdf-preview-marker.draggable {
    pointer-events: auto;
    cursor: move;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #168a5b 0%, #35b779 100%);
    color: white;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 12px;
    transition: all 0.2s;
    box-shadow: 0 6px 18px -5px rgba(22, 138, 91, 0.38);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -5px rgba(22, 138, 91, 0.5); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 12px;
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}
.btn-secondary:hover { background: #e2e8f0; }

/* Form inputs */
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], select, textarea {
    transition: all 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14) !important;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Background remover UI */
.bg-tool-active {
    background: linear-gradient(135deg, #168a5b 0%, #35b779 100%);
    color: white;
}

/* Long brand name fit */.app-brand h1 { font-size: 13px; letter-spacing: -0.2px; }.app-mobile-brand strong { font-size: 12px; max-width: 215px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.app-mobile-brand { min-width: 0; }
