/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 100;
}

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

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-header .version {
    font-size: 0.7rem;
    background: rgba(255,255,255,0.1);
    padding: 2px 8px;
    border-radius: 12px;
}

.sidebar-nav {
    list-style: none;
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
}

.nav-item.active {
    background: rgba(255,255,255,0.1);
    border-left-color: #4CAF50;
}

.nav-item .icon {
    font-size: 1.2rem;
    width: 24px;
}

.nav-item .label {
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.green {
    background: #4CAF50;
}

.dot.red {
    background: #f44336;
}

.btn-logout {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    width: 100%;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Main Header */
.main-header {
    background: #fff;
    padding: 16px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-bell {
    position: relative;
    cursor: pointer;
}

.bell-icon {
    font-size: 1.3rem;
}

.badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #f44336;
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    font-size: 1.5rem;
}

.user-role {
    font-size: 0.85rem;
    font-weight: 500;
    background: #e8f0fe;
    padding: 4px 12px;
    border-radius: 12px;
    color: #1a73e8;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 24px 30px;
    overflow-y: auto;
    flex: 1;
}

.tab-content.active {
    display: block;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    background: #e8f0fe;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.stat-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1a1a2e;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chart-card h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: #333;
}

.question-list {
    max-height: 300px;
    overflow-y: auto;
}

.question-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.question-text {
    font-size: 0.9rem;
    color: #333;
    flex: 1;
}

.question-meta {
    font-size: 0.75rem;
    color: #666;
    display: flex;
    gap: 12px;
    align-items: center;
}

.score-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.7rem;
}

.score-high {
    background: #c8e6c9;
    color: #2e7d32;
}

.score-medium {
    background: #fff3e0;
    color: #e65100;
}

.score-low {
    background: #ffcdd2;
    color: #c62828;
}

/* Upload */
.upload-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.upload-area {
    background: #fff;
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-area.dragover {
    border-color: #4CAF50;
    background: #e8f5e9;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 8px;
}

.upload-area p {
    color: #666;
    margin-bottom: 16px;
}

.file-list {
    margin-top: 16px;
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    margin: 4px 0;
}

.file-name {
    font-size: 0.9rem;
}

.file-size {
    font-size: 0.75rem;
    color: #666;
}

.file-remove {
    cursor: pointer;
    color: #f44336;
    font-weight: bold;
}

.upload-metadata {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.upload-metadata h3 {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #4CAF50;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkbox-group label {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-primary {
    background: #1a73e8;
    color: #fff;
}

.btn-primary:hover {
    background: #1557b0;
}

.btn-success {
    background: #4CAF50;
    color: #fff;
}

.btn-success:hover {
    background: #388E3C;
}

.btn-danger {
    background: #f44336;
    color: #fff;
}

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

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #bdbdbd;
}

.btn-block {
    width: 100%;
}

.upload-progress {
    grid-column: 1 / -1;
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.5s ease;
    border-radius: 4px;
}

.task-status {
    margin-top: 12px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

/* Documents */
.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.documents-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 250px;
}

.documents-list {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    min-height: 200px;
}

.doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.doc-item:last-child {
    border-bottom: none;
}

.doc-info {
    flex: 1;
}

.doc-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.doc-meta {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

.doc-meta span {
    margin-right: 12px;
}

.doc-actions {
    display: flex;
    gap: 8px;
}

.doc-actions .btn {
    padding: 4px 12px;
    font-size: 0.75rem;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

.pagination button.active {
    background: #1a73e8;
    color: #fff;
    border-color: #1a73e8;
}

/* API Keys */
.apikeys-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.apikeys-form {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.apikeys-form h4 {
    margin-bottom: 16px;
}

.apikeys-form .form-group {
    margin-bottom: 12px;
}

.apikeys-list {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
}

.apikey-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.apikey-item:last-child {
    border-bottom: none;
}

.apikey-info {
    flex: 1;
}

.apikey-role {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: #ffcdd2;
    color: #c62828;
}

.role-employee {
    background: #fff3e0;
    color: #e65100;
}

.role-public {
    background: #c8e6c9;
    color: #2e7d32;
}

.apikey-key {
    font-family: monospace;
    font-size: 0.85rem;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
}

.apikey-actions .btn {
    padding: 4px 12px;
    font-size: 0.75rem;
}

/* Feedback */
.feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.feedback-filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.feedback-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-mini {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-mini .label {
    display: block;
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-mini .value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

.feedback-list {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.feedback-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.feedback-item:last-child {
    border-bottom: none;
}

.feedback-question {
    font-weight: 500;
    margin-bottom: 4px;
}

.feedback-score {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.8rem;
}

.feedback-comment {
    color: #666;
    font-size: 0.9rem;
    margin-top: 4px;
}

.feedback-meta {
    font-size: 0.75rem;
    color: #999;
    margin-top: 4px;
}

/* Cache */
.cache-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cache-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.cache-actions {
    display: flex;
    gap: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #323232;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s;
    z-index: 1000;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: #4CAF50;
}

.toast.error {
    background: #f44336;
}

.toast.warning {
    background: #ff9800;
}

/* Loading */
.loading-text {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        height: 100%;
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .menu-toggle {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
    
    .upload-container {
        grid-template-columns: 1fr;
    }
    
    .documents-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .documents-actions {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .feedback-header {
        flex-direction: column;
        align-items: stretch;
    }
}

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

::-webkit-scrollbar-track {
    background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}