/* ============================================================
   Enterprise QMS — Premium Custom Stylesheet
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
    --primary: #2563EB;
    --primary-light: #DBEAFE;
    --primary-hover: #1D4ED8;
    --secondary: #0F172A;
    --accent: #06B6D4;
    --accent-hover: #0891B2;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
}

/* ── Base Typography ────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ── Custom Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dark ::-webkit-scrollbar-thumb { background: #334155; }
.dark ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.animate-fade-in-up { animation: fadeInUp 0.4s ease-out forwards; }
.animate-fade-in { animation: fadeIn 0.3s ease-out forwards; }
.animate-slide-in-right { animation: slideInRight 0.35s ease-out forwards; }

/* Staggered children animation */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

/* ── Skeleton Loader ────────────────────────────────────────── */
.skeleton {
    position: relative;
    overflow: hidden;
    background: #e2e8f0;
    border-radius: var(--radius-sm);
}
.dark .skeleton { background: #1e293b; }
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.18) 50%, transparent 100%);
    animation: shimmer 1.6s infinite;
}
.dark .skeleton::after {
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.05) 50%, transparent 100%);
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
    will-change: transform;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-link {
    transition: background 0.15s ease, color 0.15s ease, padding 0.15s ease;
}
.sidebar-link:hover {
    background: rgba(37,99,235,0.08);
}
.dark .sidebar-link:hover {
    background: rgba(59,130,246,0.10);
}
.sidebar-link.active {
    background: rgba(37,99,235,0.12);
    color: var(--primary);
    font-weight: 700;
}
.dark .sidebar-link.active {
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
}

/* ── Cards / Panels ─────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.dark .card {
    background: #1e293b;
    border-color: rgba(51,65,85,0.8);
}
.card:hover { box-shadow: var(--shadow-md); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(37,99,235,0.35); transform: translateY(-1px); }
.btn-secondary {
    background: #f1f5f9; color: #334155;
    border: 1px solid #e2e8f0;
}
.dark .btn-secondary { background: #334155; color: #e2e8f0; border-color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.dark .btn-secondary:hover { background: #475569; }
.btn-danger { background: #ef4444; color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,0.25); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-success { background: #10b981; color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
.btn-success:hover { background: #059669; transform: translateY(-1px); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.9rem; }
.btn-icon { padding: 0.5rem; border-radius: 0.625rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ── Form Inputs ────────────────────────────────────────────── */
.form-input,
.form-select,
.form-textarea {
    display: block; width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    border: 1.5px solid #e2e8f0;
    background: #f8fafc;
    color: #1e293b;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    outline: none;
}
.dark .form-input,
.dark .form-select,
.dark .form-textarea {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
    background: #fff;
}
.dark .form-input:focus,
.dark .form-select:focus,
.dark .form-textarea:focus {
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
    background: #1e293b;
}
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
}
.dark .form-label { color: #d1d5db; }

/* ── Table Styles ───────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.dark .data-table th { background: rgba(30,41,59,0.8); border-color: #334155; color: #94a3b8; }
.data-table td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.dark .data-table td { color: #e2e8f0; border-color: rgba(51,65,85,0.5); }
.data-table tbody tr {
    transition: background 0.12s ease;
}
.data-table tbody tr:hover { background: #f8fafc; }
.dark .data-table tbody tr:hover { background: rgba(30,41,59,0.5); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── QR Code display ────────────────────────────────────────── */
#qr-code-container canvas,
#qr-code-container img {
    border-radius: 8px;
    padding: 8px;
    background: #fff;
}

/* ── Drag & Drop (Sortable) ─────────────────────────────────── */
.sortable-ghost {
    opacity: 0.3;
    background: #dbeafe !important;
    border: 2px dashed #3b82f6 !important;
}
.dark .sortable-ghost {
    background: rgba(30,58,138,0.4) !important;
    border-color: #60a5fa !important;
}
.sortable-chosen { cursor: grabbing; }
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }

/* ── Rating Stars ───────────────────────────────────────────── */
.star-rating input[type="radio"] { display: none; }
.star-rating label {
    cursor: pointer;
    font-size: 1.75rem;
    color: #d1d5db;
    transition: color 0.12s ease, transform 0.12s ease;
    display: inline-block;
}
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label { color: #f59e0b; }
.star-rating label:hover { transform: scale(1.15); }

/* ── NPS Buttons ────────────────────────────────────────────── */
.nps-btn {
    width: 2.5rem; height: 2.5rem;
    border-radius: 0.5rem;
    border: 1.5px solid #e2e8f0;
    font-weight: 700;
    font-size: 0.875rem;
    transition: all 0.12s ease;
    cursor: pointer;
}
.nps-btn:hover { transform: translateY(-2px); border-color: var(--primary); color: var(--primary); }
.nps-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Toast Notifications ────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    background: #1e293b;
    color: #f8fafc;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    min-width: 280px;
    max-width: 380px;
    pointer-events: all;
    animation: slideInRight 0.35s ease-out forwards;
    border-left: 4px solid;
}
.toast-success { border-left-color: #10b981; }
.toast-danger  { border-left-color: #ef4444; }
.toast-warning { border-left-color: #f59e0b; }
.toast-info    { border-left-color: #3b82f6; }
.toast-exit { animation: fadeIn 0.2s reverse ease-in forwards; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tab-btn {
    padding: 0.625rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.625rem;
    color: #64748b;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none; background: none;
}
.tab-btn:hover { color: #1e293b; background: #f1f5f9; }
.dark .tab-btn:hover { color: #f1f5f9; background: #334155; }
.tab-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.dark .tab-btn.active { background: #1e293b; color: #60a5fa; }

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-track {
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
}
.dark .progress-track { background: #334155; }
.progress-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* ── Questionnaire Form Public ──────────────────────────────── */
.question-card {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid #e2e8f0;
    padding: 1.75rem;
    margin-bottom: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dark .question-card { background: #1e293b; border-color: #334155; }
.question-card.focused {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ── Active/Pulse Indicator ─────────────────────────────────── */
.pulse-dot::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 1.5s ease-in-out infinite;
    margin-right: 6px;
}

/* ── Modal Overlay ──────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s ease;
}
.modal-panel {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInUp 0.25s ease;
}
.dark .modal-panel { background: #1e293b; border: 1px solid #334155; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid;
}

/* ── Sidebar mini label ─────────────────────────────────────── */
.sidebar-section-label {
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0 0.75rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}
