/* ===========================
   DFR CHAT - Main Stylesheet
   Professional Dental Clinic Communication App
   =========================== */

:root {
    --primary: #0066FF;
    --primary-dark: #0052CC;
    --primary-light: #E6F0FF;
    --secondary: #6C63FF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    --bg: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-sidebar: #0F172A;
    --bg-sidebar-hover: #1E293B;
    --bg-sidebar-active: #1E40AF;

    --text: #1E293B;
    --text-secondary: #64748B;
    --text-light: #94A3B8;
    --text-white: #F8FAFC;

    --border: #E2E8F0;
    --border-light: #F1F5F9;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --sidebar-width: 260px;
    --topbar-height: 64px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* RESET & BASE */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* LOADING SCREEN */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0F172A 0%, #1E40AF 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-logo {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 36px;
    animation: pulse 2s infinite;
}

.loading-content h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.loading-content p {
    opacity: 0.7;
    font-size: 0.95rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    margin: 24px auto 0;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* SCREEN */
.screen {
    min-height: 100vh;
}

/* ============================
   LOGIN SCREEN
   ============================ */
.login-container {
    display: flex;
    min-height: 100vh;
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #0F172A 0%, #1E40AF 50%, #0066FF 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.login-left::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
    top: -150px;
    right: -150px;
}

.login-left::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    bottom: -100px;
    left: -100px;
}

.login-branding {
    color: white;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.brand-icon {
    width: 70px;
    height: 70px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.2);
}

.login-branding h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 3px;
    margin-bottom: 12px;
}

.login-branding > p {
    font-size: 1.1rem;
    opacity: 0.8;
    line-height: 1.7;
    margin-bottom: 32px;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    opacity: 0.9;
}

.brand-feature i {
    color: var(--success);
    font-size: 1.1rem;
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: white;
    max-width: 560px;
}

.login-form-container {
    width: 100%;
    max-width: 400px;
}

.login-form-container h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.admin-setup-link {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.admin-setup-link p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.admin-setup-link a {
    color: var(--primary);
    font-weight: 600;
}

.admin-setup-link a:hover {
    text-decoration: underline;
}

/* ============================
   FORM ELEMENTS
   ============================ */
.form-group {
    margin-bottom: 18px;
    flex: 1;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group label i {
    margin-right: 4px;
    width: 16px;
    text-align: center;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    background: white;
    transition: all 0.2s ease;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.flex-end {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 44px;
}

.toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
}

.toggle-pass:hover {
    color: var(--text-secondary);
}

/* ============================
   BUTTONS
   ============================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    border-color: var(--text-light);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.85rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 2px;
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: var(--primary);
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
}

.sidebar-user {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.user-role-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8);
    width: fit-content;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255,255,255,0.65);
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    color: white;
    background: var(--bg-sidebar-hover);
}

.nav-item.active {
    color: white;
    background: var(--bg-sidebar-active);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: white;
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 8px 0;
}

.sidebar-footer .nav-item:hover {
    color: var(--danger);
}

/* ============================
   MAIN CONTENT
   ============================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* TOPBAR */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
}

.topbar-left h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.notification-bell {
    position: relative;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.notification-bell:hover {
    background: var(--bg);
}

.notification-bell i {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.topbar-user:hover {
    background: var(--bg);
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
}

.topbar-user span {
    font-weight: 600;
    font-size: 0.9rem;
}

.topbar-user i.fa-chevron-down {
    font-size: 0.7rem;
    color: var(--text-light);
}

.user-dropdown {
    position: absolute;
    top: 56px;
    right: 24px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 180px;
    z-index: 60;
    overflow: hidden;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 0.9rem;
    color: var(--text);
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bg);
}

.user-dropdown a i {
    width: 18px;
    text-align: center;
    color: var(--text-secondary);
}

/* CONTENT AREA */
.content-area {
    padding: 24px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ============================
   STATS CARDS
   ============================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-primary .stat-icon {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-warning .stat-icon {
    background: #FEF3C7;
    color: var(--warning);
}

.stat-success .stat-icon {
    background: #D1FAE5;
    color: var(--success);
}

.stat-danger .stat-icon {
    background: #FEE2E2;
    color: var(--danger);
}

.stat-info .stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* ============================
   CARDS
   ============================ */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-link {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-link:hover {
    text-decoration: underline;
}

.card-body {
    padding: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============================
   MESSAGES LIST
   ============================ */
.messages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-item {
    background: white;
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.message-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.message-item.unread {
    border-left: 4px solid var(--primary);
    background: var(--primary-light);
}

.message-item.unread .msg-title {
    font-weight: 700;
}

.message-item.priority-urgente {
    border-left: 4px solid var(--warning);
}

.message-item.priority-critica {
    border-left: 4px solid var(--danger);
}

.message-item.unread.priority-urgente {
    background: #FFFBEB;
}

.message-item.unread.priority-critica {
    background: #FEF2F2;
}

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    color: white;
}

.msg-body {
    flex: 1;
    min-width: 0;
}

.msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.msg-sender {
    font-weight: 600;
    font-size: 0.9rem;
}

.msg-time {
    font-size: 0.75rem;
    color: var(--text-light);
    white-space: nowrap;
}

.msg-title {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-tags {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.msg-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.msg-tag.tag-status-ativa { background: #D1FAE5; color: #065F46; }
.msg-tag.tag-status-alterada { background: #FEF3C7; color: #92400E; }
.msg-tag.tag-status-expirada { background: #E2E8F0; color: #475569; }
.msg-tag.tag-status-cancelada { background: #FEE2E2; color: #991B1B; }
.msg-tag.tag-priority-urgente { background: #FEF3C7; color: #92400E; }
.msg-tag.tag-priority-critica { background: #FEE2E2; color: #991B1B; }
.msg-tag.tag-attachment { background: #EDE9FE; color: #5B21B6; }
.msg-tag.tag-next { background: #E0F2FE; color: #0369A1; }

.msg-meta {
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 4px;
    min-width: 80px;
    align-items: flex-end;
}

.msg-read-status {
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-read-status.read {
    color: var(--success);
}

.msg-read-status.unread {
    color: var(--warning);
}

/* ============================
   MESSAGE DETAIL
   ============================ */
.message-detail {
    max-width: 800px;
}

.message-detail .card {
    margin-bottom: 16px;
}

.msg-detail-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-light);
}

.msg-detail-header .msg-tags {
    margin-bottom: 12px;
}

.msg-detail-header h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.msg-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.msg-detail-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.msg-detail-meta i {
    color: var(--text-light);
}

.msg-detail-body {
    padding: 24px;
    line-height: 1.8;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

.msg-detail-attachments {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--bg);
}

.msg-detail-attachments h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.attachment-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.attachment-item:hover {
    background: var(--primary-light);
}

.attachment-item i {
    color: var(--primary);
}

.msg-detail-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.read-log {
    padding: 20px;
}

.read-log h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.read-log h4 i { color: var(--primary); }

.read-log-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.read-log-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.read-log-item i {
    color: var(--success);
}

.read-log-item .log-time {
    margin-left: auto;
    color: var(--text-light);
    font-size: 0.8rem;
}

/* ============================
   PAGE TOOLBAR
   ============================ */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-tabs {
    display: flex;
    gap: 4px;
    background: white;
    border-radius: var(--radius);
    padding: 4px;
    border: 1px solid var(--border);
}

.tab-btn {
    padding: 8px 18px;
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.tab-badge {
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    min-width: 16px;
    text-align: center;
}

.tab-btn.active .tab-badge {
    background: rgba(255,255,255,0.3);
}

/* ============================
   TABLE
   ============================ */
.table-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
}

.data-table tr:hover td {
    background: var(--bg);
}

.data-table .empty-td {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: #D1FAE5;
    color: #065F46;
}

.status-inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.action-btns {
    display: flex;
    gap: 6px;
}

/* ============================
   SEARCH FILTERS
   ============================ */
.search-filters .form-row {
    margin-bottom: 12px;
}

.search-filters .form-group {
    margin-bottom: 0;
}

/* ============================
   PROFILE
   ============================ */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
}

.profile-info h3 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.profile-details {
    margin-bottom: 20px;
}

.detail-row {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row label {
    width: 140px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-row span {
    font-size: 0.95rem;
}

/* ============================
   FILE UPLOAD
   ============================ */
.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.file-upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-prompt {
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}

.file-upload-prompt:hover {
    background: var(--bg);
}

.file-upload-prompt i {
    font-size: 2rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.file-upload-prompt p {
    font-weight: 600;
    color: var(--text-secondary);
}

.file-upload-prompt small {
    color: var(--text-light);
    font-size: 0.8rem;
}

.file-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 12px 12px;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.file-preview i {
    color: var(--primary);
}

.file-preview .file-remove {
    cursor: pointer;
    color: var(--danger);
    font-size: 0.85rem;
    padding: 2px;
}

.file-preview .file-remove:hover {
    color: #DC2626;
}

/* ============================
   MODAL
   ============================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-sm {
    max-width: 420px;
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header h3 i {
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.6;
}

/* ============================
   EMPTY STATE
   ============================ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ============================
   TOAST NOTIFICATIONS
   ============================ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-width: 300px;
    max-width: 420px;
    animation: slideIn 0.3s ease;
    font-size: 0.9rem;
}

.toast.toast-success {
    border-left: 4px solid var(--success);
}

.toast.toast-error {
    border-left: 4px solid var(--danger);
}

.toast.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast.toast-info {
    border-left: 4px solid var(--info);
}

.toast i {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.toast-success i { color: var(--success); }
.toast.toast-error i { color: var(--danger); }
.toast.toast-warning i { color: var(--warning); }
.toast.toast-info i { color: var(--info); }

.toast.fade-out {
    animation: slideOut 0.3s ease forwards;
}

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

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

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    html { font-size: 13px; }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-close {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

    /* Login */
    .login-container {
        flex-direction: column;
    }

    .login-left {
        display: none;
    }

    .login-right {
        max-width: 100%;
        min-height: 100vh;
        padding: 24px;
    }

    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Table responsive */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 600px;
    }

    /* Topbar user name hidden on mobile */
    .topbar-user span {
        display: none;
    }

    .topbar-user i.fa-chevron-down {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .message-item {
        padding: 12px 14px;
    }

    .msg-meta {
        min-width: 60px;
    }

    .msg-detail-meta {
        flex-direction: column;
        gap: 8px;
    }

    /* Toast */
    .toast-container {
        top: auto;
        bottom: 16px;
        right: 16px;
        left: 16px;
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    /* Modal */
    .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .modal {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 85vh;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-number {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .toolbar-tabs {
        width: 100%;
    }

    .tab-btn {
        flex: 1;
        justify-content: center;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .page-toolbar .btn {
        width: 100%;
    }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Print */
@media print {
    .sidebar, .topbar, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; }
}
