/* Authentication Modal */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.auth-modal.hidden {
    display: none;
}

.auth-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.auth-modal-content h2 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.auth-modal-content p {
    margin-bottom: 1.5rem;
    color: #666;
}

.auth-modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-modal-content input {
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.2em;
    transition: border-color 0.3s ease;
}

.auth-modal-content input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-modal-content button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.auth-modal-content button:hover {
    transform: translateY(-2px);
}

.auth-modal-content button:active {
    transform: translateY(0);
}

.auth-error {
    color: #dc3545;
    margin-top: 1rem;
    display: none;
    font-size: 0.9rem;
}

.auth-error.show {
    display: block;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.card h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Stat cards */
.stat-card {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stat-card h3 {
    color: white;
}

.stat-number {
    font-size: 3rem;
    font-weight: bold;
    margin: 1rem 0;
}

.stat-label {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Status indicators */
.status-list {
    margin: 1rem 0;
}

.status-item {
    margin-bottom: 0.5rem;
}

.status-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-indicator.online {
    background: #28a745;
}

.status-indicator.offline {
    background: #dc3545;
}

.status-indicator.warning {
    background: #ffc107;
}

/* Controls */
.controls {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.controls h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.control-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

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

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
}

/* Table */
.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.table-header {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.table-header h3 {
    color: #667eea;
    margin: 0;
}

.table-wrapper {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.table tr:hover {
    background: #f8f9fa;
}

/* Failure types */
.failure-type {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.failure-type.gemini_intent_detection {
    background: #fff3cd;
    color: #856404;
}

.failure-type.gemini_json_parsing {
    background: #f8d7da;
    color: #721c24;
}

.failure-type.transaction_parsing {
    background: #d4edda;
    color: #155724;
}

.failure-type.user_registration {
    background: #cce7ff;
    color: #004085;
}

.failure-type.gemini_response_handling {
    background: #e2e3e5;
    color: #383d41;
}

.failure-type.gemini_service_error {
    background: #f5c6cb;
    color: #721c24;
}

/* Utility classes */
.message-preview {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timestamp {
    color: #6c757d;
    font-size: 0.875rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.empty-state h4 {
    margin-bottom: 1rem;
    color: #495057;
}

/* Chart placeholder */
.chart-container {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 1rem 0;
}

.chart-placeholder {
    text-align: center;
    color: #6c757d;
}

.chart-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.chart-note {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Error notifications */
#errorContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.error-notification {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

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

    .control-group {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .header h1 {
        font-size: 2rem;
    }

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

/* Focus styles for accessibility */
.btn:focus,
input:focus,
select:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Dashboard Tabs */
.dashboard-tabs {
    display: flex;
    background: white;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tab-button {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-right: 1px solid #e9ecef;
}

.tab-button:last-child {
    border-right: none;
}

.tab-button:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tab-button:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Analytics-specific cards */
.analytics-card {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.performance-card {
    background: linear-gradient(135deg, #fd7e14 0%, #ffc107 100%);
}

/* Analytics Controls */
.analytics-controls {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-left: 4px solid #28a745;
}

.analytics-controls h3 {
    color: #28a745;
    margin-bottom: 1rem;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 1rem 0;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
    display: none;
}

.chart-container canvas.active {
    display: block;
}

.chart-placeholder {
    text-align: center;
    color: #6c757d;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.chart-placeholder.hidden {
    display: none;
}

/* Analytics specific styles */
.analytics-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.analytics-card .stat-number {
    color: white;
}

.analytics-card .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.performance-card {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.performance-card .stat-number {
    color: white;
}

.performance-card .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

/* Command usage and session items */
.command-item, .session-item, .operation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.command-info, .session-info, .operation-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.command-name, .session-user, .operation-name {
    font-weight: 600;
    color: #495057;
}

.command-percentage, .session-status, .operation-status {
    font-size: 0.875rem;
    font-weight: 500;
}

.command-count, .session-duration, .operation-time {
    color: #6c757d;
    font-size: 0.875rem;
}

.status-success {
    color: #28a745;
}

.status-warning {
    color: #ffc107;
}

.status-error {
    color: #dc3545;
}

.status-neutral {
    color: #6c757d;
}

/* Activity status in tables */
.activity-status {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.activity-status.success {
    background: #d4edda;
    color: #155724;
}

.activity-status.processing {
    background: #fff3cd;
    color: #856404;
}

.activity-status.failed {
    background: #f8d7da;
    color: #721c24;
}

/* Loading states */
.analytics-loading {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

/* Chart improvements */
.chart-container canvas {
    border-radius: 8px;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Command usage and session lists */
.command-item,
.session-item,
.operation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.2s ease;
}

.command-item:hover,
.session-item:hover,
.operation-item:hover {
    background: #e9ecef;
    transform: translateX(4px);
}

.command-name,
.session-info,
.operation-name {
    font-weight: 500;
    color: #495057;
}

.command-count,
.session-duration,
.operation-time {
    font-weight: bold;
    color: #667eea;
}

.command-percentage,
.session-status,
.operation-status {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Status indicators for analytics */
.status-success {
    color: #28a745;
    font-weight: 500;
}

.status-warning {
    color: #ffc107;
    font-weight: 500;
}

.status-error {
    color: #dc3545;
    font-weight: 500;
}

/* Analytics metrics */
.metric-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.metric-title {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #495057;
}

.metric-change {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.metric-change.positive {
    color: #28a745;
}

.metric-change.negative {
    color: #dc3545;
}

.metric-change.neutral {
    color: #6c757d;
}

/* Loading states for analytics */
.analytics-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6c757d;
}

.analytics-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Export and report buttons */
.btn-export {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.btn-export:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.4);
}

.btn-report {
    background: linear-gradient(135deg, #6f42c1 0%, #5a2d91 100%);
    color: white;
}

.btn-report:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(111, 66, 193, 0.4);
}

/* Time range indicators */
.time-range-indicator {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #e9ecef;
    border-radius: 20px;
    font-size: 0.875rem;
    color: #495057;
    margin-left: 0.5rem;
}

.time-range-indicator.active {
    background: #667eea;
    color: white;
}

/* Analytics data tables */
.analytics-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.analytics-table th,
.analytics-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.analytics-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-table tr:hover {
    background: #f8f9fa;
}

/* User activity status */
.activity-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.activity-status.success {
    background: #d4edda;
    color: #155724;
}

.activity-status.processing {
    background: #fff3cd;
    color: #856404;
}

.activity-status.failed {
    background: #f8d7da;
    color: #721c24;
}

/* Responsive design for analytics */
@media (max-width: 768px) {
    .dashboard-tabs {
        flex-direction: column;
    }
    
    .tab-button {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .tab-button:last-child {
        border-bottom: none;
    }
    
    .tab-button.active {
        transform: none;
    }
    
    .command-item,
    .session-item,
    .operation-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .analytics-table {
        font-size: 0.875rem;
    }
    
    .analytics-table th,
    .analytics-table td {
        padding: 0.5rem;
    }
}

/* Dark mode support for analytics (optional) */
@media (prefers-color-scheme: dark) {
    .analytics-controls {
        background: #2d3748;
        color: #e2e8f0;
        border-left-color: #48bb78;
    }
    
    .analytics-controls h3 {
        color: #48bb78;
    }
    
    .command-item,
    .session-item,
    .operation-item {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .metric-card {
        background: #2d3748;
        color: #e2e8f0;
    }
}