/* ============================================
   DASHBOARD.css - User Dashboard, Stats, Templates, History, Admin Panel
   ============================================
   Contains:
   - Dashboard container and header
   - Dashboard welcome section
   - Stats cards
   - Dashboard cards
   - Templates grid and items
   - History list and items
   - Empty states
   - Dashboard tabs
   - Account settings
   - Form groups and settings messages
   - Danger zone
   - Delete account modal
   - Admin panel styles
   - Admin messages list
   - Admin stats and users
   - Analytics dashboard
   - Collapsible settings sections
   - Notification badges
   ============================================ */

/* Dashboard Styles */
.dashboard { background: white; border-radius: 16px; padding: 1.5rem; margin-bottom: 1.5rem; border: 1px solid #e5e7eb; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.dashboard-welcome h2 { font-size: 1.5rem; color: #374151; margin-bottom: 0.25rem; }
.dashboard-welcome p { color: #6b7280; font-size: 0.9rem; }
.dashboard-stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-card { display: flex; align-items: center; gap: 0.75rem; background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); padding: 1rem 1.25rem; border-radius: 12px; border: 1px solid #c4b5fd; min-width: 140px; }
.stat-icon { font-size: 2rem; }
.stat-info { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #7c3aed; }
.stat-label { font-size: 0.75rem; color: #6d28d9; }
.dashboard-card { background: #f9fafb; border-radius: 12px; padding: 1.25rem; border: 1px solid #e5e7eb; }
.dashboard-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.dashboard-card-header h3 { font-size: 1rem; color: #374151; }

.templates-grid { display: flex; flex-direction: column; gap: 0.75rem; max-height: 300px; overflow-y: auto; }
.template-item { display: flex; justify-content: space-between; align-items: center; background: white; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.template-info { flex: 1; }
.template-name { font-weight: 600; color: #374151; font-size: 0.9rem; }
.template-fields { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; }
.template-actions { display: flex; gap: 0.5rem; }
.template-actions button { padding: 0.35rem 0.75rem; font-size: 0.75rem; border-radius: 6px; cursor: pointer; }

.history-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 300px; overflow-y: auto; }
.history-item { background: white; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.history-date { font-size: 0.75rem; color: #9ca3af; }
.history-pdfs { font-size: 0.8rem; color: #374151; }
.history-fields { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; }
.history-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

.empty-state { text-align: center; color: #9ca3af; font-size: 0.85rem; padding: 1.5rem; background: white; border-radius: 8px; border: 1px dashed #d1d5db; }

/* Dashboard Tabs */
.dashboard-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 2px solid #e5e7eb; padding-bottom: 0.5rem; }
.tab-btn { padding: 0.5rem 1rem; background: none; border: none; cursor: pointer; font-size: 0.875rem; color: #6b7280; border-radius: 6px; transition: all 0.2s; }
.tab-btn:hover { background: #f5f3ff; color: #7c3aed; }
.tab-btn.active { background: #7c3aed; color: white; }

@media (max-width: 900px) {
    .dashboard-content { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; gap: 1rem; }
    .dashboard-stats { width: 100%; justify-content: space-between; }
    .stat-card { flex: 1; min-width: auto; }
}

@media (max-width: 600px) {
    .stat-card { flex-direction: column; text-align: center; gap: 0.5rem; padding: 0.75rem; }
    .dashboard-stats { flex-wrap: wrap; }
}

/* Account Settings Styles */
.account-settings { display: flex; flex-direction: column; gap: 1.5rem; }
.settings-section { background: white; padding: 1.25rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.settings-section h4 { font-size: 0.95rem; color: #374151; margin-bottom: 1rem; font-weight: 600; }
.settings-section p { font-size: 0.85rem; color: #6b7280; margin-bottom: 1rem; line-height: 1.5; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: #374151; margin-bottom: 0.35rem; }
.form-group input { width: 100%; padding: 0.6rem 0.85rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.875rem; transition: border-color 0.2s; }
.form-group input:focus { outline: none; border-color: #7c3aed; }
.form-group small { display: block; margin-top: 0.25rem; font-size: 0.75rem; color: #9ca3af; }

.settings-message { margin-top: 1rem; padding: 0.75rem; border-radius: 6px; font-size: 0.85rem; display: none; }
.settings-message.success { display: block; background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.settings-message.error { display: block; background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.danger-zone { border-color: #fca5a5; background: #fef2f2; }
.danger-zone h4 { color: #dc2626; }

.btn-danger { background: #ef4444; color: white; border: none; padding: 0.6rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: background 0.2s; }
.btn-danger:hover { background: #dc2626; }

.dashboard-content { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

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

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

/* Delete Account Modal */
.delete-modal { background: white; border-radius: 16px; overflow: hidden; }
.delete-modal-header { text-align: center; padding: 1.5rem 1rem; background: #f3e8ff; }
.delete-modal-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.delete-modal-header h2 { color: #7c3aed; font-size: 1.25rem; margin: 0; }
.delete-modal-body { padding: 1.5rem; text-align: center; }
.delete-modal-footer { display: flex; gap: 0.75rem; padding: 1rem 1.5rem; background: #f9fafb; border-top: 1px solid #e5e7eb; }
.delete-modal-footer .btn { flex: 1; padding: 0.6rem 1rem; border-radius: 8px; font-weight: 500; cursor: pointer; }

/* Admin Panel Styles */
.admin-messages-list { max-height: 500px; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.admin-message-item { background: white; border-radius: 8px; padding: 1rem; border: 1px solid #e5e7eb; border-left: 4px solid #9ca3af; }
.admin-message-item.new { border-left-color: #7c3aed; background: #f5f3ff; }
.admin-message-item.read { border-left-color: #3b82f6; }
.admin-message-item.responded { border-left-color: #10b981; }
.admin-message-item.closed { border-left-color: #6b7280; opacity: 0.7; }
.admin-message-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.admin-message-from { font-weight: 600; color: #374151; font-size: 0.9rem; }
.admin-message-date { font-size: 0.75rem; color: #9ca3af; }
.admin-message-subject { font-size: 0.85rem; color: #6b7280; margin-bottom: 0.5rem; }
.admin-message-body { font-size: 0.85rem; color: #374151; padding: 0.75rem; background: #f9fafb; border-radius: 6px; margin-bottom: 0.75rem; }
.admin-message-status { margin-bottom: 0.5rem; }
.admin-message-actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-message-actions select { padding: 0.4rem 0.75rem; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.8rem; }
.status-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.7rem; font-weight: 500; text-transform: uppercase; }
.status-badge.new { background: #ede9fe; color: #5b21b6; }
.status-badge.read { background: #dbeafe; color: #1e40af; }
.status-badge.responded { background: #d1fae5; color: #065f46; }
.status-badge.closed { background: #e5e7eb; color: #374151; }

/* Admin Dashboard Styles */
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.admin-stat-card { background: white; border-radius: 12px; padding: 1.5rem; text-align: center; border: 1px solid #e5e7eb; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.admin-stat-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.admin-stat-value { font-size: 2rem; font-weight: 700; color: #7c3aed; }
.admin-stat-label { font-size: 0.9rem; color: #6b7280; margin-top: 0.25rem; }
.admin-stat-sub { font-size: 0.75rem; color: #10b981; margin-top: 0.25rem; }

.admin-users-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 500px; overflow-y: auto; }
.admin-user-item { display: flex; justify-content: space-between; align-items: center; background: white; padding: 1rem; border-radius: 8px; border: 1px solid #e5e7eb; }
.admin-user-info { display: flex; flex-direction: column; gap: 0.25rem; }
.admin-user-email { font-weight: 600; color: #374151; }
.admin-user-name { font-size: 0.85rem; color: #6b7280; }
.admin-user-date { font-size: 0.75rem; color: #9ca3af; }
.admin-user-actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; }
.admin-badge.admin { background: #7c3aed; color: white; }
.admin-badge.user { background: #e5e7eb; color: #6b7280; }
.admin-tab-content { min-height: 200px; }

/* Collapsible Settings Sections */
.settings-section.collapsible { overflow: hidden; }
.collapsible-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 0.75rem 1rem; background: white; border-radius: 8px; transition: background 0.2s; user-select: none; }
.collapsible-header:hover { background: #f9fafb; }
.collapsible-header h4 { margin: 0; font-size: 0.95rem; color: #374151; display: flex; align-items: center; gap: 0.5rem; }
.collapse-icon { color: #9ca3af; font-size: 0.75rem; transition: transform 0.3s; }
.collapsible-header.active .collapse-icon { transform: rotate(180deg); }
.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; padding: 0 1rem; }
.collapsible-content.open { max-height: 500px; padding: 1rem; }

/* Danger zone for collapsible */
.settings-section.collapsible.danger-zone .collapsible-header { background: #fef2f2; }
.settings-section.collapsible.danger-zone .collapsible-header h4 { color: #dc2626; }

/* Analytics Dashboard Styles */
.admin-analytics-content { padding: 0.5rem; }
.analytics-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.analytics-stat-card { background: white; border-radius: 10px; padding: 1rem; text-align: center; border: 1px solid #e5e7eb; box-shadow: 0 2px 6px rgba(0,0,0,0.04); }
.analytics-stat-icon { font-size: 1.75rem; margin-bottom: 0.25rem; }
.analytics-stat-value { font-size: 1.5rem; font-weight: 700; color: #6d28d9; }
.analytics-stat-label { font-size: 0.8rem; color: #6b7280; margin-top: 0.1rem; }
.analytics-stat-sub { font-size: 0.7rem; color: #10b981; margin-top: 0.15rem; }

.analytics-chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; background: white; border-radius: 10px; padding: 1rem; border: 1px solid #e5e7eb; margin-top: 0.5rem; }
.chart-bar { flex: 1; background: linear-gradient(to top, #7c3aed, #a78bfa); border-radius: 4px 4px 0 0; min-height: 8px; position: relative; transition: height 0.3s; cursor: pointer; }
.chart-bar:hover { background: linear-gradient(to top, #6d28d9, #7c3aed); }
.chart-label { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 0.6rem; color: #9ca3af; white-space: nowrap; }

.analytics-events-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; background: white; border-radius: 10px; padding: 1rem; border: 1px solid #e5e7eb; margin-top: 0.5rem; }
.analytics-event-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.75rem; background: #f9fafb; border-radius: 6px; }
.event-type-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px; font-size: 0.7rem; font-weight: 500; text-transform: uppercase; }
.event-type-badge.page_view { background: #e0e7ff; color: #3730a3; }
.event-type-badge.signup { background: #d1fae5; color: #065f46; }
.event-type-badge.login { background: #dbeafe; color: #1e40af; }
.event-type-badge.pdf_upload { background: #fef3c7; color: #92400e; }
.event-type-badge.extraction { background: #fce7f3; color: #9d174d; }
.event-type-badge.download { background: #cffafe; color: #0e7490; }
.event-type-badge.contact { background: #ede9fe; color: #5b21b6; }
.event-date { font-size: 0.75rem; color: #9ca3af; }

/* User-deleted message styling for admin view */
.admin-message-item.user-deleted {
    opacity: 0.8;
    border-left: 4px solid #f97316 !important;
    background: #fffbeb;
}
.admin-message-item.user-deleted .admin-message-body {
    background: #fef3c7;
}
.admin-deleted-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #fed7aa;
    color: #c2410c;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Notification badge for tabs */
.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* User notification badge in header */
.user-notification-badge {
    color: #fbbf24;
    font-size: 0.65rem;
    animation: glow-pulse 1.5s ease-in-out infinite;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.8);
}

@keyframes glow-pulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(251, 191, 36, 0.8); }
    50% { opacity: 0.7; text-shadow: 0 0 12px rgba(251, 191, 36, 1); }
}
