/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background-color: #5c6bc0;
    color: white;
    padding: 0 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.app-title {
    font-size: 24px;
    font-weight: 500;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 8px;
}

.connection-status.online {
    background-color: rgba(76, 175, 80, 0.2);
    color: #4caf50;
}

.connection-status.offline {
    background-color: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.connection-status i {
    font-size: 16px;
    margin-right: 4px;
}

/* Main Layout */
.app-main {
    display: flex;
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: #fff;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: #f5f7fa;
}

.nav-item.active {
    background-color: #e8eaf6;
    color: #5c6bc0;
    font-weight: 500;
}

.nav-item i {
    margin-right: 16px;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.page-header h2 {
    font-size: 28px;
    font-weight: 400;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-select, .search-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-input {
    width: 200px;
    transition: width 0.3s ease;
}

.search-input:focus {
    width: 250px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn i {
    margin-right: 8px;
}

.btn-primary {
    background-color: #5c6bc0;
    color: white;
}

.btn-primary:hover {
    background-color: #3f51b5;
}

.btn-secondary {
    background-color: #f5f7fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e0e0e0;
}

.btn-text {
    background: none;
    color: #5c6bc0;
    padding: 4px 8px;
}

.btn-text:hover {
    background-color: rgba(92, 107, 192, 0.1);
}

#logout-btn {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

#logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Pagination */
.pagination-info {
    margin-bottom: 16px;
    font-size: 14px;
    color: #666;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}

/* Table */
.table-container {
    overflow-x: auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background-color: #f5f7fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background-color: #f9f9f9;
}

.loading-cell {
    text-align: center;
    padding: 24px;
    color: #666;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #5c6bc0;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.error-message {
    color: #f44336;
    background-color: #ffebee;
    padding: 12px;
    border-radius: 4px;
    margin: 10px 0;
}

.last-refresh {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.tier-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.super-admin-badge {
    background-color: #ffd700;
    color: #333;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.super-admin-badge i {
    font-size: 16px;
}

.filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.hidden-toggle {
    width: 16px;
    height: 16px;
}

.page-input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.page-input:focus {
    outline: none;
    border-color: #5c6bc0;
}

/* User table enhancements */
.data-table tr.has-files {
    background-color: #f0f8ff;
}

.data-table tr.has-files:hover {
    background-color: #e6f3ff;
}

.data-table tr.hidden-user {
    background-color: #fff3cd;
    font-style: italic;
}

.data-table tr.hidden-user:hover {
    background-color: #ffeaa7;
}

.data-table .has-files td:nth-child(7) i {
    color: #28a745;
    font-size: 18px;
}

.data-table .hidden-user td:first-child::after {
    content: " (Hidden)";
    font-size: 10px;
    color: #856404;
    margin-left: 4px;
}

.tier-free {
    background-color: #e3f2fd;
    color: #1976d2;
}

.tier-paid {
    background-color: #e8f5e9;
    color: #388e3c;
}

/* Analytics Cards */
.analytics-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.analytics-card {
    background-color: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

.card-header i {
    color: #5c6bc0;
    font-size: 24px;
}

.card-value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.card-change {
    font-size: 14px;
    color: #666;
}

/* Chart Container */
.chart-container {
    background-color: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chart-container h3 {
    margin-bottom: 24px;
    font-size: 20px;
    font-weight: 500;
}

.platform-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.platform-stat {
    display: flex;
    align-items: center;
    gap: 16px;
}

.platform-label {
    width: 80px;
    font-weight: 500;
}

.platform-bar {
    flex: 1;
    height: 20px;
    background-color: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background-color: #5c6bc0;
    border-radius: 10px;
}

.platform-value {
    width: 50px;
    text-align: right;
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 24px;
}

/* User Details */
.user-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.detail-group {
    margin-bottom: 16px;
}

.detail-label {
    font-weight: 500;
    margin-bottom: 4px;
    color: #666;
}

.detail-value {
    font-size: 16px;
}

.activity-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 24px;
}

.activity-tab {
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.activity-tab.active {
    border-bottom-color: #5c6bc0;
    color: #5c6bc0;
    font-weight: 500;
}

.activity-content {
    display: none;
}

.activity-content.active {
    display: block;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    padding: 16px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.activity-type {
    font-weight: 500;
}

.activity-time {
    color: #666;
    font-size: 14px;
}

.activity-details {
    color: #333;
}

/* Conversation Messages */
.conversation-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
}

.message.user {
    background-color: #e3f2fd;
    align-self: flex-end;
}

.message.bot {
    background-color: #f1f1f1;
    align-self: flex-start;
}

.message-role {
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 14px;
}

.message-content {
    white-space: pre-wrap;
}

.message-time {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: #333;
    color: white;
    padding: 16px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Help Modal Styles */
.shortcuts-list {
    margin-bottom: 24px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-key {
    background-color: #f5f7fa;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: 500;
    margin-right: 16px;
    min-width: 120px;
    text-align: center;
}

.shortcut-desc {
    flex: 1;
}

.help-tips h3 {
    margin-bottom: 12px;
    color: #5c6bc0;
}

.help-tips ul {
    list-style-type: none;
    padding-left: 0;
}

.help-tips li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
}

.help-tips li:before {
    content: "•";
    color: #5c6bc0;
    font-weight: bold;
    position: absolute;
    left: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-main {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .filters {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .search-input {
        width: 100%;
    }
    
    .analytics-cards {
        grid-template-columns: 1fr;
    }
    
    .user-details-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .search-input {
        width: 100%;
    }
    
    .search-input:focus {
        width: 100%;
    }
}

/* Improved table responsiveness */
@media (max-width: 1024px) {
    .data-table {
        font-size: 14px;
    }
    
    .data-table th, .data-table td {
        padding: 8px 12px;
    }
}

/* Dark mode disabled - removed to fix visibility issues */

/* Essay Download Styles */
.download-link {
    display: inline-flex;
    align-items: center;
    color: #5c6bc0;
    text-decoration: none;
    margin-top: 8px;
    font-weight: 500;
}

.download-link:hover {
    text-decoration: underline;
}

.download-link i {
    margin-right: 4px;
    font-size: 18px;
}

.download-essay-btn {
    display: inline-flex;
    align-items: center;
    color: #5c6bc0;
    margin-top: 8px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
}

.download-essay-btn:hover {
    background-color: rgba(92, 107, 192, 0.1);
}

.download-essay-btn:disabled {
    color: #999;
    cursor: not-allowed;
}

.status-success {
    color: #4caf50;
    font-weight: 500;
}

.status-failed {
    color: #f44336;
    font-weight: 500;
}