/* ==========================================================================
   STYLE.CSS - GIAO DIỆN HỆ THỐNG GHI CHÚ BẢO MẬT (INTERNAL NOTE SYSTEM)
   Phong cách: Premium Dark-Mode Glassmorphism (Kính mờ hiện đại)
   ========================================================================== */

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

:root {
    --bg-main: #090d16;
    --bg-card: rgba(17, 24, 39, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(59, 130, 246, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --primary-hover: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glow-blue: 0 0 15px rgba(59, 130, 246, 0.35);
}

/* Reset cơ bản */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 0% 0%, rgba(17, 24, 39, 0.8) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(59, 130, 246, 0.08) 0, transparent 50%),
        radial-gradient(at 50% 100%, rgba(139, 92, 246, 0.05) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   MÀN HÌNH ĐĂNG NHẬP / 2FA (LOGIN CARD & SETUP 2FA)
   -------------------------------------------------------------------------- */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 440px;
    padding: 40px;
    box-shadow: var(--shadow);
    transition: border 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.5s ease;
}

.auth-card:hover {
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45), 0 0 20px rgba(59, 130, 246, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: var(--primary-gradient);
    margin-bottom: 15px;
    box-shadow: var(--glow-blue);
}

.auth-logo svg {
    width: 32px;
    height: 32px;
    fill: #ffffff;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Các trường nhập liệu (Inputs) */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-container {
    position: relative;
}

.form-input {
    width: 100%;
    background: rgba(10, 15, 30, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--glow-blue);
    background: rgba(10, 15, 30, 0.8);
}

/* Định dạng đặc biệt cho mã OTP */
.otp-input-container {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 25px 0;
}

.otp-box {
    width: 48px;
    height: 52px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    border-radius: 10px;
    background: rgba(10, 15, 30, 0.7);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.otp-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--glow-blue);
}

/* Nút bấm */
.btn {
    width: 100%;
    background: var(--primary-gradient);
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--glow-blue);
}

.btn:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

/* Thông báo phản hồi */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid transparent;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: #a7f3d0;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: #fca5a5;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: #fde68a;
}

/* Trình bày thiết lập 2FA */
.setup-2fa-section {
    text-align: center;
}

.qr-container {
    background: #ffffff;
    padding: 15px;
    border-radius: 12px;
    display: inline-block;
    margin: 20px 0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.secret-key-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 15px;
    font-family: monospace;
    font-size: 16px;
    letter-spacing: 2px;
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary);
}

.copy-icon-btn {
    cursor: pointer;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.copy-icon-btn:hover {
    color: var(--primary);
}

/* --------------------------------------------------------------------------
   TRANG QUẢN TRỊ CHÍNH (DASHBOARD LAYOUT)
   -------------------------------------------------------------------------- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Thanh điều hướng bên cạnh (Sidebar) */
.sidebar {
    width: 260px;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glow-blue);
}

.sidebar-logo-icon svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

.sidebar-logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sidebar-menu-item a svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.sidebar-menu-item a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-menu-item a:hover svg {
    transform: translateX(2px);
}

.sidebar-menu-item.active a {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: var(--glow-blue);
}

.sidebar-menu-item.active a svg {
    fill: #ffffff;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.user-info-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary);
    font-size: 14px;
}

.user-details {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Phần nội dung chính (Main Content Area) */
.main-content {
    margin-left: 0;
    flex-grow: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Bảng điều khiển */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.dashboard-title h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.dashboard-title p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Bộ đếm thời gian phiên hoạt động (Timer) */
.session-timer-badge {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: #fde68a;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.1);
    cursor: pointer;
    transition: all 0.2s;
}

.session-timer-badge:hover {
    background: rgba(245, 158, 11, 0.2);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.25);
    transform: scale(1.02);
}

.session-timer-badge.critical {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
    color: #fca5a5;
    animation: pulse 1s infinite alternate;
}

/* Bảng thống kê tổng quan (Stats) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-data h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-data p {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-primary);
}

/* Khu vực Tạo ghi chú & Danh sách ghi chú */
.content-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.8fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

.panel-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.panel-title svg {
    width: 20px;
    height: 20px;
    fill: var(--primary);
}

/* Trường nhập nội dung ghi chú (Textarea) */
.note-textarea {
    width: 100%;
    min-height: 150px;
    background: rgba(10, 15, 30, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    font-size: 15px;
    color: var(--text-primary);
    resize: vertical;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1.5;
    margin-bottom: 20px;
}

.note-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--glow-blue);
    background: rgba(10, 15, 30, 0.8);
}

/* Bảng hiển thị dữ liệu */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th {
    background: rgba(17, 24, 39, 0.9);
    padding: 14px 16px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Thẻ trạng thái & badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
    border: 1px solid var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fde68a;
    border: 1px solid var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #bfdbfe;
    border: 1px solid var(--primary);
}

/* Kiểu liên kết slug */
.slug-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-family: monospace;
    font-size: 15px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.slug-link:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.views-count-btn {
    cursor: pointer;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--primary);
    font-weight: 600;
    transition: all 0.2s;
}

.views-count-btn:hover {
    background: rgba(59, 130, 246, 0.18);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

/* --------------------------------------------------------------------------
   HỘP THOẠI MODAL (POPUP GLASSMORPHISM)
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
}

/* --------------------------------------------------------------------------
   GIAO DIỆN XEM GHI CHÚ CHỈ ĐỌC (PUBLIC READ-ONLY PAGE)
   -------------------------------------------------------------------------- */
.note-view-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    padding: 40px 20px;
}

.note-view-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 700px;
    padding: 40px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.note-view-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
}

.note-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.note-badge-sec {
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.note-content-area {
    background: rgba(10, 15, 30, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 24px;
    font-size: 16px;
    line-height: 1.6;
    color: #e5e7eb;
    white-space: pre-wrap; /* Giữ nguyên định dạng xuống dòng của note */
    user-select: text;    /* Cho phép bôi đen copy nội dung */
    min-height: 120px;
}

.note-view-footer {
    margin-top: 25px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 15px;
}

/* --------------------------------------------------------------------------
   HIỆU ỨNG CHUYỂN ĐỘNG (ANIMATIONS) & ĐỒNG BỘ
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    from {
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
    }
    to {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.35);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 20px;
    box-shadow: var(--shadow);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary);
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast.toast-error {
    border-left-color: var(--error);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive cho thiết bị di động */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 20px 10px;
        align-items: center;
    }
    
    .sidebar-logo-text,
    .sidebar-menu-item-text,
    .user-details,
    .sidebar-footer {
        display: none;
    }
    
    .sidebar-logo {
        margin-bottom: 30px;
        padding-left: 0;
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .sidebar-menu-item a {
        padding: 12px;
        justify-content: center;
    }
}
