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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bg-base: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.95);
    --border: #cbd5e1;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --success-hover: #059669;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, #e0e7ff 0%, #e2e8f0 100%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 10px;
}

/* Typography */
h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    text-align: center;
}

p.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
}

/* Layouts */
.app-container {
    width: 100%;
    max-width: 480px;
    background: var(--card-bg);
    padding: 24px 20px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05), 0 4px 10px rgba(0, 0, 0, 0.03);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease-in-out;
    margin-top: env(safe-area-inset-top);
}

.view {
    display: none;
    animation: fadeIn 0.4s ease-in-out forwards;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Sections cho hệ thống phức tạp */
.form-section {
    background: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.form-section h3 {
    font-size: 0.95rem;
    color: #0369a1;
    margin-bottom: 16px;
    border-bottom: 2px solid #e0f2fe;
    padding-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

input, select {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    color: var(--text-main);
    background-color: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input::placeholder {
    color: #94a3b8;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
    margin-top: 10px;
}

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

.btn-success {
    background-color: var(--success);
    color: white;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
    margin-bottom: 24px;
}

.btn-success:hover, .btn-success:active {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 12px;
    margin-top: 16px;
}

.btn-danger:hover, .btn-danger:active {
    background-color: #fef2f2;
}

/* Image Capture Area */
.capture-area {
    margin-bottom: 24px;
    text-align: center;
}

.preview-container {
    display: none;
    position: relative;
    width: 100%;
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.preview-container img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform 0.3s ease;
}

.preview-container img:hover {
    transform: scale(1.02);
}

.remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

/* Utility */
.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    text-align: center;
    margin-top: 12px;
    display: none;
    font-weight: 500;
}

#displayUserInfo {
    text-align: center;
    margin-bottom: 20px;
    padding: 8px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 500;
}

/* Modal for Image Preview */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    overflow: auto;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeInModal 0.3s ease forwards;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    cursor: zoom-out;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    z-index: 10000;
}

/* Offline Banner */
.offline-banner {
    display: none;
    background-color: #fbbf24;
    color: #92400e;
    text-align: center;
    padding: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    margin-bottom: 16px;
}

.offline-mode .offline-banner {
    display: block;
}

/* Scroll To Top Button */
#scrollTopBtn {
    display: none;
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 99;
    font-size: 22px;
    font-weight: bold;
    border: none;
    outline: none;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: background-color 0.3s, transform 0.2s;
}

#scrollTopBtn:hover {
    background-color: #1d4ed8;
    transform: scale(1.1);
}

/* GIAO DIEN OCR */
.ocr-btn { background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 0 5px; margin-left: 8px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1)); }
.ocr-locked { position: relative; pointer-events: none; opacity: 0.6; }
.ocr-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.8); display: flex; align-items: center; justify-content: center; font-weight: bold; color: #0284c7; z-index: 10; border-radius: 8px; font-size: 1.1rem; }
.ocr-success input { background-color: #dcfce7 !important; border-color: #22c55e !important; color: #166534 !important; font-weight: bold; transition: all 0.5s ease; }

/* ================= TOAST NOTIFICATIONS ================= */
#toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: 90%; max-width: 400px; }
.toast-msg { background: rgba(15, 23, 42, 0.95); color: white; padding: 14px 20px; border-radius: 8px; box-shadow: 0 8px 16px rgba(0,0,0,0.3); font-weight: 500; font-size: 0.95rem; animation: toastSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; display: flex; align-items: center; gap: 8px; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.1); }
.toast-success { border-left: 5px solid #22c55e; }
.toast-error { border-left: 5px solid #ef4444; }
.toast-info { border-left: 5px solid #3b82f6; }
.toast-fadeout { animation: toastFadeOut 0.4s ease forwards; }
@keyframes toastSlideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastFadeOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-30px); opacity: 0; } }

/* ================= NOTIF PANEL & CONFIRM MODAL ================= */
.notif-panel { position: fixed; top: 0; right: -320px; width: 320px; max-width: 80vw; height: 100vh; background: #fff; box-shadow: -4px 0 15px rgba(0,0,0,0.1); z-index: 10000; transition: right 0.3s ease; display: flex; flex-direction: column; }
.notif-panel.active { right: 0; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.notif-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.notif-item { padding: 12px; border-radius: 8px; font-size: 0.9rem; line-height: 1.4; border-left: 4px solid #3b82f6; background: #f1f5f9; color: #0f172a; font-weight: 500; }
.notif-item.success { border-left-color: #22c55e; background: #f0fdf4; }
.notif-item.error { border-left-color: #ef4444; background: #fef2f2; }
.notif-time { font-size: 0.75rem; color: #64748b; margin-top: 5px; text-align: right; }
.confirm-content { background: #fff; padding: 24px; border-radius: 12px; width: 90%; max-width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.btn-cancel { padding: 10px 16px; border: 1px solid #cbd5e1; background: white; color: #475569; border-radius: 8px; cursor: pointer; font-weight: 500; }
.btn-confirm { padding: 10px 16px; border: none; background: #2563eb; color: white; border-radius: 8px; cursor: pointer; font-weight: 500; }
.btn-confirm:hover { background: #1d4ed8; }
