/* ==========================================================================
   SDN SIGNATURE - MASTER STYLE (UNIFIED DESIGN SYSTEM)
   One shared stylesheet for every page: auth, dashboard, editor, admin,
   guest signing & verification. Page-local <style> blocks should only
   contain rules that are truly unique to that one page.
   ========================================================================== */

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

:root {
    /* BRAND */
    --primary: #4361ee;
    --primary-dark: #304ffe;
    --primary-darker: #3a0ca3;
    --primary-light: #eef2ff;
    --primary-gradient: linear-gradient(135deg, #4361ee 0%, #304ffe 100%);
    --secondary: #64748b;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --white: #ffffff;
    --bg-page: #f1f5f9;

    /* SEMANTIC */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --success-border: #a7f3d0;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-text: #b91c1c;
    --danger-border: #fecaca;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-text: #92400e;
    --warning-border: #fde68a;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --info-text: #1e40af;
    --info-border: #bfdbfe;

    /* DIMENSIONS */
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;

    /* SHADOWS */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

/* ==========================================================================
   1. RESET & BODY
   ========================================================================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg-page);
    min-height: 100vh; margin: 0; padding: 0;
    color: var(--dark);
    display: flex; justify-content: center; align-items: flex-start;
}

a { color: inherit; }
h1, h2, h3, h4 { font-family: inherit; }

/* Fixed-width icon slot so Font Awesome icons line up next to text everywhere */
.icon, .nav-item i, .btn-primary i, .btn-secondary i, .btn-icon-action i, .logo-area i {
    width: 1.1em; text-align: center; flex-shrink: 0;
}

/* ==========================================================================
   2. STANDALONE CARD PAGES (Login, Register, Forgot, Guest Success, Verify)
   Body gets .page-standalone to center a single card on a plain background.
   ========================================================================== */
body.page-standalone {
    align-items: center;
    padding: 20px;
}

.standalone-card {
    width: 100%; max-width: 420px;
    padding: 40px;
    background: var(--white);
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-card);
    margin: 20px auto;
}
.standalone-card.result-card { max-width: 480px; }

.standalone-card .logo-area img,
.standalone-card .logo { width: 90px; margin-bottom: 20px; display: inline-block; }
.standalone-card h1, .standalone-card h2, .standalone-card h3 {
    color: var(--primary); margin: 0 0 5px; font-size: 1.5rem;
}
.standalone-card p { color: var(--secondary); font-size: 0.9rem; margin: 0; }
.standalone-card .foot-links { margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--secondary); }
.standalone-card .foot-links p { margin-bottom: 10px; }
.standalone-card .foot-links a { color: var(--primary); font-weight: 700; text-decoration: none; }
.standalone-card .foot-links a:hover { text-decoration: underline; }

/* ==========================================================================
   3. DASHBOARD SHELL (Sidebar + Mobile Header + Content) — used on every
   logged-in page via partials/sidebar_nav.php
   ========================================================================== */
.dashboard-wrapper {
    display: flex; width: 100%; min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 25px 20px;
    display: flex; flex-direction: column;
    position: fixed; height: 100vh; left: 0; top: 0; z-index: 50;
    overflow-y: auto;
}
.logo-area { text-align: center; margin-bottom: 30px; }
.logo-area img { width: 80px; margin-bottom: 10px; }
.logo-area h3 { font-size: 1.1rem; color: var(--primary); margin: 0; }
.logo-area p { font-size: 0.85rem; color: var(--secondary); margin: 0; }

.menu-group { display: flex; flex-direction: column; gap: 8px; }

.nav-item {
    padding: 12px 15px; border-radius: var(--radius);
    color: var(--secondary); text-decoration: none; font-weight: 600; font-size: 0.95rem;
    display: flex; align-items: center; gap: 12px; transition: 0.2s;
    border: none; background: transparent; cursor: pointer; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--light); color: var(--primary); }
.nav-item.active { background: var(--primary-gradient); color: white; box-shadow: var(--shadow-glow); }
.nav-item.nav-danger { color: var(--danger); }
.nav-item.nav-danger:hover { background: var(--danger-bg); }
.logout-btn { margin-top: auto; color: var(--danger); }
.logout-btn:hover { background: var(--danger-bg); }

.content {
    margin-left: var(--sidebar-w);
    flex: 1; padding: 40px; background: var(--light);
    width: calc(100% - var(--sidebar-w));
}
.content h2 { font-size: 1.8rem; margin: 0 0 5px 0; color: #0f172a; }
.subtitle { color: var(--secondary); margin-bottom: 30px; }

.page-header-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 30px; flex-wrap: wrap; }
.page-header-row .subtitle { margin-bottom: 0; }

.mobile-header { display: none; }

@media (max-width: 768px) {
    body:not(.page-standalone) { display: block; }
    .dashboard-wrapper { flex-direction: column; }

    .mobile-header {
        display: flex; align-items: center; justify-content: space-between;
        background: white; padding: 15px 20px;
        position: fixed; top: 0; left: 0; width: 100%; z-index: 40;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-sm);
    }
    .mobile-logo { display: flex; align-items: center; gap: 10px; font-weight: bold; color: var(--primary); }
    .mobile-logo img { height: 32px; }
    .mobile-header .close-link { text-decoration: none; color: var(--danger); font-weight: bold; }

    .sidebar {
        width: 100%; height: auto;
        position: fixed; bottom: 0; left: 0; top: auto;
        flex-direction: row; padding: 8px 15px;
        border-right: none; border-top: 1px solid var(--border);
        justify-content: space-around;
        background: rgba(255,255,255,0.98);
        backdrop-filter: blur(10px);
        box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    }
    .sidebar .logo-area { display: none; }

    .menu-group {
        flex-direction: row; width: 100%; justify-content: space-around; gap: 0;
    }
    .nav-item {
        flex-direction: column; gap: 4px; padding: 6px 4px;
        font-size: 0.68rem; text-align: center; border-radius: 8px;
        flex: 1; background: transparent !important; box-shadow: none !important;
        color: #94a3b8;
    }
    .nav-item.active { color: var(--primary); }
    .nav-item i { font-size: 1.15rem; }
    .logout-btn { margin-top: 0; }

    .content {
        margin-left: 0; width: 100%;
        padding: 80px 16px 100px 16px;
    }
    .page-header-row .btn-primary { width: 100%; }
}

/* ==========================================================================
   4. BUTTONS
   ========================================================================== */
.btn-primary {
    background: var(--primary-gradient); color: white; padding: 12px 18px;
    border-radius: var(--radius-sm); border: none; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 10px rgba(67,97,238,0.2); transition: 0.2s; text-decoration: none;
    font-size: 1rem; font-family: inherit;
}
form > .btn-primary, .card-white > .btn-primary { width: 100%; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(67,97,238,0.3); }
.btn-primary.w-auto { width: auto; }

.btn-secondary {
    background: white; border: 1px solid var(--border); color: var(--dark);
    padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit; font-size: 0.95rem; font-weight: 600; text-decoration: none; transition: 0.2s;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: var(--light); }
.btn-secondary.btn-danger-outline { color: var(--danger); border-color: var(--danger-border); }
.btn-secondary.btn-danger-outline:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger-text); }
.btn-secondary.btn-sm { padding: 7px 12px; font-size: 0.85rem; }
.btn-secondary.dashed { border: 2px dashed #cbd5e1; background: white; }

.btn-icon {
    padding: 8px 10px; border: 1px solid var(--border); background: white;
    border-radius: var(--radius-sm); cursor: pointer; color: var(--dark);
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }

/* Small action buttons used in data tables (history, admin lists, etc.) */
.btn-act {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
    border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600;
    text-decoration: none; transition: 0.2s; border: 1px solid transparent; cursor: pointer; height: 38px;
    font-family: inherit; background: white; color: var(--dark);
}
.btn-act.download { background: var(--primary); color: white; border-color: var(--primary); }
.btn-act.download:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn-act.check { background: white; color: var(--dark); border-color: var(--border); }
.btn-act.check:hover { border-color: var(--primary); color: var(--primary); background: var(--light); }
.btn-act.delete { background: white; color: var(--danger); border-color: var(--danger-border); padding: 8px 10px; }
.btn-act.delete:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger-text); }
.btn-act.disabled { background: #e2e8f0; color: #94a3b8; border-color: #cbd5e1; cursor: not-allowed; pointer-events: none; }
.btn-act.btn-edit-user { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.btn-act.btn-del-user { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.btn-add-new { background: var(--primary); color: white; padding: 10px 20px; text-decoration: none; border-radius: var(--radius-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.btn-add-new:hover { background: var(--primary-dark); }

.btn-resend { background: #25D366; color: white; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: none; cursor: pointer; font-size: 0.9rem; transition: 0.2s; }
.btn-resend:hover { transform: scale(1.1); background: #128C7E; }

/* Input file button */
input[type="file"] { padding: 8px; background: white; width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); }
input[type="file"]::file-selector-button {
    background: var(--primary-gradient); color: white; border: none;
    padding: 8px 15px; border-radius: 6px; margin-right: 10px; cursor: pointer;
}

/* ==========================================================================
   5. FORMS
   ========================================================================== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; color: var(--dark); }
small.hint { color: var(--secondary); display: block; margin-top: 5px; font-size: 0.8rem; }
.form-control {
    width: 100%; padding: 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 1rem; transition: 0.2s; font-family: inherit; background: white;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1); }

/* ==========================================================================
   6. CARDS
   ========================================================================== */
.card-white {
    background: white; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 25px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.card-white > label.section-label, .card-white > .section-label { margin-bottom: 15px; display: block; font-weight: 700; }
.card-white .section-hint { font-size: 0.85rem; color: var(--secondary); margin-bottom: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
    padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow-sm);
    border: 1px solid var(--border); text-align: center;
}
.stat-card h3 { font-size: 2.5rem; margin: 0; color: var(--primary); }
.stat-card p { margin: 5px 0 0; color: var(--secondary); font-weight: 600; text-transform: uppercase; font-size: 0.8rem; letter-spacing: .03em; }
.stat-card.stat-success h3 { color: var(--success); }
.stat-card.stat-danger h3 { color: var(--danger); }

.stat-card.panel-card { text-align: left; padding: 32px; }
.stat-card.panel-card h3.panel-title {
    font-size: 1.15rem; color: var(--primary); text-transform: none; letter-spacing: 0;
    margin: 0 0 20px; border-bottom: 1px solid var(--border); padding-bottom: 15px;
    display: flex; align-items: center; gap: 8px;
}
.stat-card.panel-card.danger-accent h3.panel-title { color: var(--danger); }

.settings-card { background: #fff; padding: 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 20px; }
.settings-card h4 { margin-top: 0; display: flex; align-items: center; gap: 8px; }

/* ==========================================================================
   7. ALERTS & BADGES
   ========================================================================== */
.alert {
    padding: 14px 16px; border-radius: var(--radius-sm); margin-bottom: 20px;
    font-size: 0.9rem; border: 1px solid transparent; display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.alert-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }

.badge, .role-badge, .status-badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
    border-radius: 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap;
}
.badge-primary, .role-badge.admin { background: var(--primary-light); color: var(--primary); border-color: #c7d2fe; }
.badge-neutral, .role-badge.user { background: #f1f5f9; color: var(--secondary); border-color: var(--border); }
.badge-success, .status-badge.signed, .status-badge.success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-warning, .status-badge.pending { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-danger, .status-badge.failed { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }

/* ==========================================================================
   8. TABS
   ========================================================================== */
.sig-option-tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 5px; border-radius: 10px; margin-bottom: 15px; overflow-x: auto; }
.tab-btn { flex: 1; padding: 10px; background: transparent; border: none; color: var(--secondary); font-weight: 600; border-radius: 8px; cursor: pointer; white-space: nowrap; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tab-btn.active { background: white; color: var(--primary); box-shadow: var(--shadow-sm); }

.nav-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; gap: 4px; }
.nav-tab { padding: 10px 20px; cursor: pointer; font-weight: 600; color: var(--secondary); border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 8px; }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   9. TABLES
   ========================================================================== */
.table-container, .table-card {
    background: white; border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03); overflow: hidden;
}
.table-container.scrollable { max-height: 500px; overflow-y: auto; }
.table-responsive { overflow-x: auto; }
.custom-table { width: 100%; border-collapse: collapse; }
.custom-table th {
    background: #f8fafc; padding: 16px 22px; text-align: left; font-size: 0.8rem;
    font-weight: 700; color: var(--secondary); text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.custom-table td { padding: 18px 22px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.custom-table tbody tr:last-child td { border-bottom: none; }
.sticky-header th { position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 2px -1px rgba(0,0,0,0.06); }

.doc-title { font-weight: 700; color: var(--dark); font-size: 0.95rem; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.doc-date { font-size: 0.8rem; color: #94a3b8; display: flex; align-items: center; gap: 5px; }
.file-missing { font-size: 0.7rem; background: var(--danger-bg); color: var(--danger-text); padding: 2px 6px; border-radius: 4px; font-weight: bold; margin-left: 5px; }

.action-group { display: flex; gap: 8px; justify-content: flex-end; align-items: flex-start; flex-wrap: wrap; }
.invite-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff; border: 1px solid #f1f5f9; padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 5px; }

.security-wrapper { display: flex; flex-direction: column; align-items: flex-end; margin-right: 4px; }
.security-check {
    display: flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--danger); font-weight: 600;
    background: var(--danger-bg); padding: 5px 10px; border-radius: 6px; border: 1px dashed var(--danger-border);
    height: 38px; cursor: pointer;
}
.security-check input { cursor: pointer; accent-color: var(--danger); width: 14px; height: 14px; }
.security-note { font-size: 0.6rem; color: var(--danger-text); margin-top: 4px; font-weight: 500; display: none; background: var(--danger-bg); padding: 2px 6px; border-radius: 4px; white-space: nowrap; }

.input-cell { width: 100%; border: 1px solid var(--border); padding: 6px 8px; border-radius: 4px; font-size: 0.9rem; font-family: inherit; }
.input-cell:focus { border-color: var(--primary); outline: none; background: var(--primary-light); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--secondary); }
.empty-state .icon-lg { font-size: 2.75rem; display: block; margin-bottom: 12px; color: #cbd5e1; }
.empty-state a { color: var(--primary); font-weight: 700; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* ==========================================================================
   10. SIGNATURE CAPTURE & UPLOAD
   ========================================================================== */
.saved-sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 10px; margin-top: 10px; }
.sig-item { border: 1px solid var(--border); border-radius: var(--radius-sm); height: 70px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; background: white; }
.sig-item.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2); }
.sig-item img { max-width: 100%; max-height: 100%; }
.btn-delete-sig { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; background: var(--danger); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; }

.upload-box-dashed {
    border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 30px 20px;
    text-align: center; cursor: pointer; transition: 0.2s; background: #fafbff;
}
.upload-box-dashed:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-box-dashed .icon-lg { font-size: 1.6rem; color: var(--primary); display: block; margin-bottom: 8px; }

.invite-card { position: relative; background: #f8fafc; padding: 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 10px; }
.invite-card .invite-head { font-weight: bold; margin-bottom: 10px; display: flex; justify-content: space-between; color: var(--secondary); }
.btn-remove-invite { color: var(--danger); font-weight: bold; cursor: pointer; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 4px; }

.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px; }
.option-card { background: white; border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 15px; text-align: center; cursor: pointer; transition: 0.2s; }
.option-card:hover { border-color: var(--primary); background: var(--light); }
.option-card .option-icon { font-size: 1.5rem; display: block; margin-bottom: 5px; color: var(--primary); }
.option-card .option-text { font-weight: 600; font-size: 0.9rem; }
@media (max-width: 768px) { .option-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   11. PHOTO EDITOR MODAL (crop / magic eraser / text) — index.php & guest_sign.php
   ========================================================================== */
.pane-title { font-weight: 700; font-size: 0.9rem; color: var(--dark); margin-bottom: 10px; }
.canvas-wrapper, .canvas-container {
    flex: 1; background: #eee; border: 1px solid #ddd; border-radius: var(--radius-sm);
    display: flex; justify-content: center; align-items: center; overflow: hidden;
    margin-bottom: 10px; position: relative;
}
.bg-checker { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABhJREFUOE9jZGBg+M+ABAD5QAY5gG00eAAAAABJRU5ErkJggg=='); }
#cropper-image, #clean-canvas, #cropper-target { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }

.editor-toolbar, .tool-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; padding: 5px; background: white; border: 1px solid #ddd; border-radius: var(--radius-sm); }
.tool-btn { padding: 8px 12px; border: 1px solid #ccc; background: white; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; font-family: inherit; }
.tool-btn:hover { background: var(--light); }
.tool-btn.primary { background: var(--primary); color: white; border: none; }

.tool-group { display: flex; align-items: center; gap: 8px; }
.color-dot { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid var(--border); }
.color-dot.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(67,97,238,0.25); }

.text-wrapper, .text-overlay {
    position: absolute; left: 50%; top: 50%; padding: 5px 10px;
    background: rgba(255,255,255,0.75); border: 1px dashed var(--primary);
    font-weight: bold; cursor: move; font-size: 20px; z-index: 200; font-family: sans-serif;
}
.text-content { outline: none; }
.btn-del-text, .text-overlay .btn-x {
    position: absolute; top: -10px; right: -10px; width: 20px; height: 20px;
    background: var(--danger); color: white; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-size: 12px; cursor: pointer; line-height: 1;
}

/* ==========================================================================
   12. MODAL SHELL
   ========================================================================== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(4px); z-index: 2000; display: none; justify-content: center; align-items: center; padding: 10px; }
.modal-content, .modal-card { background: white; width: 100%; max-width: 1000px; height: 90vh; border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 15px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; font-weight: bold; background: #fff; }
.modal-header .close-x { cursor: pointer; color: var(--danger); font-size: 1.4rem; line-height: 1; }
.modal-body { flex: 1; display: flex; overflow: hidden; }
.pane-left, .pane-crop { flex: 1; padding: 15px; background: white; border-right: 1px solid #eee; display: flex; flex-direction: column; }
.pane-right, .pane-edit { flex: 1; padding: 15px; background: #f8fafc; display: flex; flex-direction: column; }

@media (max-width: 768px) {
    .modal-body { flex-direction: column; overflow-y: auto; }
    .pane-left, .pane-crop { min-height: 380px; border-right: none; border-bottom: 1px solid #eee; }
    .pane-right, .pane-edit { min-height: 420px; }
}

/* ==========================================================================
   13. PDF EDITOR (canvas viewer + draggable/resizable/rotatable signature)
   ========================================================================== */
.editor-card {
    background: white; border-radius: var(--radius); padding: 20px;
    min-height: 85vh; display: flex; flex-direction: column;
    margin-bottom: 20px; border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.editor-area {
    background: #525659; border-radius: 8px; overflow: hidden;
    display: flex; justify-content: center; position: relative;
    border: 1px solid #ccc; margin-bottom: 20px; min-height: 500px;
}
#pdf-canvas { display: block; max-width: 100%; height: auto; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }

.page-controls { display: flex; justify-content: center; align-items: center; gap: 15px; margin-bottom: 15px; }
.page-btn { background: white; border: 1px solid var(--border); padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; font-family: inherit; }
.page-badge { background: #f1f5f9; padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; color: var(--secondary); }
.btn-nav { background: white; border: 1px solid #cbd5e0; padding: 6px 14px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; font-family: inherit; }

.ttd-wrapper { position: absolute; top: 50%; left: 50%; width: 150px; height: 80px; z-index: 100; touch-action: none; user-select: none; transform-origin: center center; }
.ttd-box { width: 100%; height: 100%; position: relative; border: 2px solid var(--primary); background: rgba(67, 97, 238, 0.1); cursor: grab; }
.ttd-image { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

.resize-node { position: absolute; width: 24px; height: 24px; background: white; border: 2px solid var(--primary); border-radius: 50%; z-index: 102; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.rn-tl { top: -12px; left: -12px; } .rn-tr { top: -12px; right: -12px; }
.rn-bl { bottom: -12px; left: -12px; } .rn-br { bottom: -12px; right: -12px; }

.rotate-handle {
    position: absolute; top: -45px; left: 50%; transform: translateX(-50%);
    width: 32px; height: 32px; background: white; border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center;
    cursor: grab; z-index: 102; color: var(--primary); font-weight: bold; font-size: 16px;
}
.rotate-line { position: absolute; top: -28px; left: 50%; width: 2px; height: 28px; background: var(--primary); z-index: 101; }

.sig-list-container { background: #f8fafc; padding: 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 20px; max-height: 200px; overflow-y: auto; }
.sig-item-row { display: flex; justify-content: space-between; align-items: center; background: white; padding: 10px; border-radius: 6px; margin-bottom: 5px; border: 1px solid #e2e8f0; }
.btn-remove-sig { color: var(--danger); cursor: pointer; font-weight: bold; font-size: 0.9rem; }
.btn-add-sig {
    background: var(--success); color: white; border: none; padding: 12px; width: 100%;
    border-radius: var(--radius-sm); font-weight: bold; cursor: pointer; margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: inherit; font-size: 1rem;
}

/* ==========================================================================
   14. ADMIN: WHATSAPP COMPOSER (blast.php) & VARIABLE CHIPS
   ========================================================================== */
.user-checklist { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); padding: 10px; border-radius: var(--radius-sm); background: #fff; }
.user-item { display: flex; align-items: center; padding: 5px 0; border-bottom: 1px dashed #edf2f7; }

.var-info-box { margin-top: 15px; background: var(--info-bg); padding: 15px; border-radius: var(--radius-sm); border: 1px dashed var(--info); }
.var-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.var-item {
    font-size: 0.85rem; color: var(--info-text); background: #fff; padding: 8px 12px;
    border-radius: 6px; border: 1px solid var(--info-border); cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; position: relative;
}
.var-item:hover { background: var(--info); color: white; border-color: var(--info); transform: translateY(-2px); box-shadow: 0 3px 5px rgba(0,0,0,0.1); }
.var-item code { background: rgba(0,0,0,0.06); padding: 2px 6px; border-radius: 4px; font-weight: bold; margin-right: 8px; font-family: monospace; }

.msg-container { position: relative; width: 100%; margin-top: 5px; border: 2px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.toolbar { background: #f7fafc; padding: 8px 10px; border-bottom: 1px solid var(--border); display: flex; gap: 5px; }
.format-btn { background: #fff; border: 1px solid #cbd5e0; border-radius: 5px; padding: 5px 10px; cursor: pointer; font-size: 0.9rem; font-weight: 600; font-family: inherit; }
.format-btn:hover { background: var(--border); }
.msg-textarea { width: 100%; min-height: 200px; padding: 15px; font-size: 1rem; border: none; resize: vertical; font-family: inherit; outline: none; }
.schedule-box { background: #fff; border: 2px solid var(--border); padding: 15px; border-radius: var(--radius-sm); margin-bottom: 15px; }

.template-card { background: #fff; border: 1px solid var(--border); padding: 15px; border-radius: var(--radius-sm); position: relative; margin-bottom: 10px; }
.template-card .tpl-actions { position: absolute; top: 15px; right: 15px; display: flex; gap: 5px; }
.template-card .tpl-actions button { border: none; color: white; border-radius: 4px; cursor: pointer; padding: 5px 9px; font-size: 0.85rem; }
.template-card .tpl-actions .tpl-edit { background: var(--warning); }
.template-card .tpl-actions .tpl-delete { background: var(--danger); }
.template-card .tpl-body { margin-top: 10px; font-size: 0.9rem; color: #4a5568; background: #f7fafc; padding: 8px; border-radius: 5px; white-space: pre-wrap; }

#toast {
    visibility: hidden; min-width: 200px; margin-left: -100px; background-color: #333; color: #fff;
    text-align: center; border-radius: 5px; padding: 10px; position: fixed; z-index: 99999;
    left: 50%; bottom: 30px; font-size: 14px;
}
#toast.show { visibility: visible; animation: fadein 0.5s, fadeout 0.5s 2.5s; }
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeout { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

/* ==========================================================================
   15. GUEST-FACING GLASS CARD (guest_sign.php, verify.php)
   Distinct, friendlier presentation for people without accounts, still on
   brand: same primary blue, same font, same radii/shadow language.
   ========================================================================== */
body.page-guest {
    background: linear-gradient(160deg, var(--primary-light) 0%, #dbeafe 100%);
    padding: 15px; padding-bottom: 160px; align-items: flex-start;
}
.glass-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    width: 100%; max-width: 900px; margin: 20px auto; overflow: hidden;
}
.header-section { background: white; padding: 25px 20px; text-align: center; border-bottom: 1px solid #f1f5f9; }
.header-title { font-size: 1.3rem; font-weight: 800; margin: 0; color: var(--primary); }
.header-sub { font-size: 0.9rem; color: var(--secondary); margin-top: 5px; }

.editor-wrapper { background: #2b2d31; padding: 20px; min-height: 400px; position: relative; display: flex; justify-content: center; overflow: hidden; }
.footer-bar { padding: 15px 20px; background: white; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }

.fab-panel {
    position: fixed; bottom: 0; left: 0; width: 100%; padding: 20px; z-index: 900;
    background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid rgba(0,0,0,0.05); box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.fab-form { width: 100%; max-width: 600px; display: flex; justify-content: center; }
.btn-add-pos {
    width: 100%; max-width: 600px; background: white; color: var(--primary); border: 2px solid var(--primary);
    padding: 14px; border-radius: 14px; font-weight: 700; font-size: 0.95rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s; font-family: inherit;
}
.btn-add-pos:hover { background: var(--primary-light); }
.btn-add-pos:active { transform: scale(0.98); }
.btn-save-final {
    width: 100%; max-width: 600px; background: linear-gradient(135deg, var(--primary), var(--primary-darker));
    color: white; border: none; padding: 16px; border-radius: 14px; font-weight: 700; font-size: 1rem; cursor: pointer;
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3); transition: all 0.2s; font-family: inherit;
}
.btn-save-final:hover { box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4); }
.btn-save-final:active { transform: scale(0.98); }

@media (min-width: 769px) {
    .fab-panel { flex-direction: row; justify-content: center; gap: 20px; padding: 25px; }
    .btn-add-pos, .fab-form { width: auto; min-width: 250px; flex: 1; max-width: 350px; }
    .fab-form { display: block; }
    .btn-save-final { width: 100%; max-width: none; }
}
@media (max-width: 768px) {
    body.page-guest { padding: 0; padding-bottom: 180px; }
    .glass-card { border-radius: 0 0 var(--radius-lg) var(--radius-lg); border: none; box-shadow: none; margin: 0 auto; }
}

/* Document verification certificate (verify.php) */
.verify-card { max-width: 600px; margin: 20px auto; background: white; padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow-card); text-align: center; border-top: 5px solid var(--success); }
.verify-status { background: var(--success-bg); color: var(--success-text); padding: 10px 20px; border-radius: 50px; font-weight: bold; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--success-border); margin: 20px 0; }
.doc-info { margin-top: 30px; text-align: left; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); font-size: 0.95rem; }
.info-row .label { color: var(--secondary); }
.info-row .value { font-weight: 600; color: var(--dark); text-align: right; }
.signer-list { margin-top: 25px; text-align: left; background: #f7fafc; padding: 15px; border-radius: var(--radius-sm); border: 1px solid #edf2f7; }
.signer-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.signer-item:last-child { border-bottom: none; }
.check-icon { color: var(--success); font-size: 1.1rem; }

.promo-box { background: var(--danger-bg); border: 2px dashed var(--danger-border); padding: 20px; border-radius: var(--radius); margin-top: 30px; }

/* ==========================================================================
   16. SUCCESS / RESULT SCREENS (final_process.php)
   ========================================================================== */
.success-card { text-align: center; padding: 40px; animation: popIn 0.4s ease; }
@keyframes popIn { from { transform: scale(.98); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-icon { font-size: 3.5rem; margin-bottom: 16px; display: block; color: var(--success); }
.success-icon.is-error { color: var(--danger); }
.preview-frame { width: 100%; height: 520px; border: none; border-radius: 14px; overflow: hidden; background: #0b1220; }
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btn-big {
    padding: 12px 20px; border-radius: var(--radius-sm); text-decoration: none;
    display: inline-flex; align-items: center; gap: 8px; font-weight: 700; border: none; cursor: pointer; font-family: inherit;
}
.btn-big.btn-green { background: var(--success); color: #fff; }
.btn-big.btn-blue { background: var(--primary); color: #fff; }
.btn-big.btn-gray { background: #e5e7eb; color: #111827; }
.note { margin-top: 10px; color: var(--secondary); font-size: 0.95rem; }

/* ==========================================================================
   17. LOADING OVERLAY
   ========================================================================== */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.95);
    z-index: 9999; display: none; justify-content: center; align-items: center; flex-direction: column;
}
.spinner { width: 40px; height: 40px; border: 4px solid #e2e8f0; border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
.loading-text { font-weight: 600; color: var(--secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   18. UTILITIES (small helpers — not a full utility framework)
   ========================================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--secondary); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
