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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    line-height: 1.5;
    color: #1f2937;
    background: #fafbfc;
    min-height: 100vh;
}

/* Main container */
.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Header */
.header {
    background: var(--color-background-primary);
    border-bottom: 1px solid var(--color-border-light);
    padding: var(--space-lg) var(--space-xl);
    text-align: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.header-logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.header-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.header-brand {
    font-size: var(--font-size-h4);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    letter-spacing: var(--letter-spacing-normal);
    margin: 0;
}

/* Header Stats */
.header-stats {
    font-size: var(--font-size-body-small);
    font-family: var(--font-family-body);
    color: var(--color-text-muted);
    display: flex;
    gap: var(--space-md);
    align-items: center;
    flex-wrap: wrap;
}

/* Controls - Enhanced with design system */
.controls {
    padding: var(--space-lg);
    background: var(--color-background-primary);
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: var(--space-lg);
}

@media (max-width: 1200px) {
    .controls {
        padding: var(--space-md);
    }
}

.controls-row {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.controls-compact {
    justify-content: space-between;
    align-items: flex-start;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    flex: 1;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-wrap: wrap;
}

.action-group {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

/* Responsive layout adjustments */
@media (max-width: 1200px) {
    .header-content {
        justify-content: center;
        flex-direction: column;
        gap: var(--space-md);
    }

    .controls-compact {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }

    .controls-left,
    .controls-right {
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .search-box {
        min-width: 200px;
    }

    .controls-left {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }

    .filter-group {
        justify-content: space-between;
    }

    .controls-right {
        flex-direction: column;
        gap: var(--space-md);
    }

    .action-group {
        justify-content: space-between;
        flex-wrap: wrap;
    }
}

/* Form elements - Enhanced with design system */
.search-box {
    min-width: 280px;
    flex: 1;
    max-width: 500px;
}

.filter-select {
    width: 155px;
    max-width: 155px;
}

.sort-select {
    width: 180px;
    max-width: 180px;
}

#perPageSelect {
    width: 110px;
    max-width: 110px;
}

/* Button enhancements */
.btn-icon {
    font-size: 0.875rem;
    line-height: 1;
}

/* Legacy button overrides - design system handles most styling */

/* Table action buttons - subtle variants */
.btn-danger {
    background: var(--color-background-secondary);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-light);
    padding: var(--space-xs) var(--space-sm);
    font-size: 14px;
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-danger:hover {
    background: var(--color-background-primary);
    color: #dc2626;
    border-color: var(--color-border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-edit {
    background: var(--color-background-secondary);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-light);
    padding: var(--space-xs) var(--space-sm);
    font-size: 14px;
    margin-right: var(--space-xs);
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit:hover {
    background: var(--color-background-primary);
    color: var(--color-text-primary);
    border-color: var(--color-border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-password {
    background: var(--color-background-secondary);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-light);
    padding: var(--space-xs) var(--space-sm);
    font-size: 14px;
    margin-right: var(--space-xs);
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-password:hover {
    background: var(--color-background-primary);
    color: #2563eb;
    border-color: var(--color-border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Table - Enhanced with design system */
.table-container {
    background: var(--color-background-primary);
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    position: relative;
    overflow: hidden;
}

.questions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-body-small);
    font-family: var(--font-family-body);
    table-layout: fixed;
}

.questions-table th,
.questions-table td {
    padding: var(--space-lg) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

.questions-table th {
    background: var(--color-background-secondary);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
    font-size: var(--font-size-tag);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    border-bottom: 1px solid var(--color-border-medium);
}

.questions-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 2.5rem;
    transition: all var(--transition-fast);
    user-select: none;
}

.questions-table th.sortable:hover {
    background: var(--color-secondary-hover);
    color: var(--color-text-primary);
}

.questions-table th.sortable.active {
    background: var(--color-secondary-hover);
    color: var(--color-text-primary);
}

.sort-indicator {
    position: absolute;
    right: var(--space-lg);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--font-size-body-small);
    color: var(--color-text-muted);
    transition: all var(--transition-normal);
    opacity: 0.6;
}

.sort-indicator::after {
    content: '↕';
    font-size: var(--space-lg);
}

.sort-indicator.asc {
    opacity: 1;
    color: var(--color-text-primary);
}

.sort-indicator.asc::after {
    content: '↑';
    font-size: 1.125rem;
}

.sort-indicator.desc {
    opacity: 1;
    color: var(--color-text-primary);
}

.sort-indicator.desc::after {
    content: '↓';
    font-size: 1.125rem;
}

.questions-table tbody tr {
    transition: all var(--transition-fast);
    min-height: 60px;
}

.questions-table tbody tr:hover {
    background: var(--color-background-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.question-text {
    word-wrap: break-word;
    word-break: break-word;
    line-height: var(--line-height-normal);
    font-weight: var(--font-weight-regular);
    font-family: var(--font-family-body);
    color: var(--color-text-primary);
    hyphens: auto;
}

/* Responsive column width management */
.questions-table th:nth-child(1) { width: 60px; }   /* ID */
.questions-table th:nth-child(2) { width: 8%; }   /* Category */
.questions-table th:nth-child(3) { width: 10%; }   /* Style */
.questions-table th:nth-child(4) { width: 10%; }   /* Intent */
.questions-table th:nth-child(5) { width: 35%; }   /* Question Text - main content */
.questions-table th:nth-child(6) { width: 80px; }  /* Active */
.questions-table th:nth-child(7) { width: 90px; }  /* Created */
.questions-table th:nth-child(8) { width: 90px; }  /* Updated */
.questions-table th:nth-child(9) { width: 140px; } /* Actions */

/* Responsive column hiding */
.hide-on-small {
    display: table-cell;
}

.hide-on-medium {
    display: table-cell;
}

.hide-on-large {
    display: table-cell;
}

/* Modals - Enhanced with design system */
.modal {
    display: none;
    position: fixed;
    z-index: var(--z-modal-backdrop);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    padding: var(--space-3xl);
    overflow-y: auto;
}

.modal-content {
    background: var(--color-background-primary);
    margin: var(--space-3xl) auto;
    padding: var(--space-4xl);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border-light);
}

.close {
    color: var(--color-text-muted);
    float: right;
    font-size: var(--font-size-h5);
    font-weight: var(--font-weight-regular);
    cursor: pointer;
    line-height: 1;
    transition: all var(--transition-fast);
    width: var(--space-3xl);
    height: var(--space-3xl);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.close:hover {
    color: var(--color-text-primary);
    background: var(--color-secondary-hover);
    transform: scale(1.1);
}

/* Forms - Enhanced with design system */
.form-group {
    margin-bottom: var(--space-2xl);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
    font-size: var(--font-size-body-small);
    font-family: var(--font-family-body);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-lg);
    border: 1px solid var(--color-border-medium);
    border-radius: var(--radius-md);
    font-size: var(--font-size-body-small);
    font-family: var(--font-family-body);
    background: var(--color-background-primary);
    transition: all var(--transition-fast);
    font-weight: var(--font-weight-regular);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    line-height: var(--line-height-normal);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: var(--space-sm);
    accent-color: var(--color-primary);
}

/* Pagination - Enhanced with design system */
.pagination {
    padding: var(--space-3xl);
    text-align: center;
    background: var(--color-background-secondary);
    border-top: 1px solid var(--color-border-light);
}

.pagination button {
    margin: 0 var(--space-xs);
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--color-border-medium);
    background: var(--color-background-primary);
    cursor: pointer;
    border-radius: var(--radius-md);
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-family-body);
    transition: all var(--transition-fast);
    min-width: 2.5rem;
}

.pagination button:hover {
    background: var(--color-secondary-hover);
    border-color: var(--color-text-muted);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pagination button.active {
    background: var(--color-primary);
    color: var(--color-secondary);
    border-color: var(--color-primary);
}

.pagination span {
    margin: 0 var(--space-sm);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-regular);
    font-family: var(--font-family-body);
}

/* Status messages - Enhanced with design system */
.status {
    padding: var(--space-lg) var(--space-xl);
    margin: var(--space-2xl) 0;
    border-radius: var(--radius-md);
    display: none;
    font-size: var(--font-size-body-small);
    font-weight: var(--font-weight-medium);
    font-family: var(--font-family-body);
    border: 1px solid;
}

.status.success {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.status.error {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Large tablet breakpoint - hide some columns */
@media (max-width: 1200px) {
    .hide-on-large {
        display: none !important;
    }
    
    .questions-table th:nth-child(3), /* Style */
    .questions-table td:nth-child(3) {
        display: none;
    }
    
    .questions-table th:nth-child(4), /* Intent */
    .questions-table td:nth-child(4) {
        display: none;
    }
    
    /* Adjust remaining column widths */
    .questions-table th:nth-child(1) { width: 60px; }   /* ID */
    .questions-table th:nth-child(2) { width: 14%; }   /* Category */
    .questions-table th:nth-child(5) { width: 45%; }   /* Question Text */
    .questions-table th:nth-child(6) { width: 60px; }  /* Active */
    .questions-table th:nth-child(7) { width: 100px; } /* Created */
    .questions-table th:nth-child(8) { width: 100px; } /* Updated */
    .questions-table th:nth-child(9) { width: 140px; } /* Actions */
}

/* Medium tablet breakpoint - hide more columns */
@media (max-width: 1000px) {
    .hide-on-medium {
        display: none !important;
    }
    
    .questions-table th:nth-child(7), /* Created */
    .questions-table td:nth-child(7) {
        display: none;
    }
    
    .questions-table th:nth-child(8), /* Updated */
    .questions-table td:nth-child(8) {
        display: none;
    }
    
    /* Adjust remaining column widths */
    .questions-table th:nth-child(1) { width: 50px; }   /* ID */
    .questions-table th:nth-child(2) { width: 18%; }   /* Category */
    .questions-table th:nth-child(5) { width: 50%; }   /* Question Text */
    .questions-table th:nth-child(6) { width: 60px; }  /* Active */
    .questions-table th:nth-child(9) { width: 120px; } /* Actions */
}

/* Small tablet breakpoint - hide even more columns */
@media (max-width: 800px) {
    .hide-on-small {
        display: none !important;
    }
    
    .questions-table th:nth-child(2), /* Category */
    .questions-table td:nth-child(2) {
        display: none;
    }
    
    /* Adjust remaining column widths for minimal view */
    .questions-table th:nth-child(1) { width: 50px; }   /* ID */
    .questions-table th:nth-child(5) { width: calc(100% - 170px); }   /* Question Text - takes remaining space */
    .questions-table th:nth-child(6) { width: 60px; }  /* Active */
    .questions-table th:nth-child(9) { width: 120px; } /* Actions */
}

/* Mobile responsiveness - switch to card layout */
@media (max-width: 769px) {
    body {
        background: white;
    }
    
    .container {
        min-height: 100vh;
        box-shadow: none;
    }
    
    .header {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-logo {
        height: 40px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .stats {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .controls {
        padding: 1.5rem 1rem;
        gap: 1.5rem;
    }
    
    .controls-row {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .filter-group {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .action-group {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .search-box {
        min-width: unset;
        width: 100%;
        max-width: none;
    }
    
    .filter-select, .sort-select {
        width: 100%;
        min-width: unset;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Mobile table - hide desktop table */
    .questions-table {
        display: none;
    }
    
    .hide-on-small {
        display: none !important;
    }
    
    /* Mobile card layout */
    .mobile-questions-list {
        display: block;
        padding: 0;
    }
    
    .question-card {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .question-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 1rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .question-id-table {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }
    
    .question-id {
        background: #111827;
        color: white;
        padding: 0.375rem 0.75rem;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 600;
        min-width: 2.5rem;
        text-align: center;
    }
    
    .question-table-type {
        background: #f3f4f6;
        color: #6b7280;
        padding: 0.375rem 0.75rem;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 500;
    }
    
    .question-status {
        display: flex;
        align-items: center;
    }
    
    .status-badge {
        padding: 0.375rem 0.75rem;
        border-radius: 4px;
        font-size: 0.75rem;
        font-weight: 600;
    }
    
    .status-badge.status-cancelled {
        background: #fee2e2;
        color: #dc2626;
    }
    
    .status-badge.active {
        background: #f0fdf4;
        color: #15803d;
    }
    
    .status-badge.inactive {
        background: #fef2f2;
        color: #dc2626;
    }
    
    .question-text-mobile {
        font-size: 1rem;
        line-height: 1.5;
        color: #111827;
        margin-bottom: 1.5rem;
        font-weight: 400;
    }
    
    .question-text-mobile-prominent {
        font-size: 1.25rem;
        line-height: 1.6;
        color: #111827;
        margin-bottom: 1.5rem;
        font-weight: 500;
        text-align: left;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .question-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    /* For screens with enough width, show 3 columns to better accommodate 5 items */
    @media (min-width: 600px) and (max-width: 768px) {
        .question-meta {
            grid-template-columns: 1fr 1fr 1fr;
            gap: 0.75rem;
        }
        
        .meta-item {
            padding: 0.5rem;
        }
        
        .meta-label {
            font-size: 0.6875rem;
        }
        
        .meta-value {
            font-size: 0.8125rem;
        }
    }
    
    .question-meta-simple {
        margin-bottom: 1.5rem;
    }
    
    .meta-item {
        background: #fafbfc;
        padding: 0.75rem;
        border-radius: 6px;
    }
    
    .meta-item-simple {
        background: #fafbfc;
        padding: 0.75rem;
        border-radius: 6px;
        text-align: center;
    }
    
    .meta-label {
        font-weight: 600;
        margin-bottom: 0.25rem;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #6b7280;
    }
    
    .meta-value {
        color: #111827;
        font-weight: 400;
        font-size: 0.875rem;
    }
    
    .question-actions {
        display: flex;
        gap: 0.75rem;
    }
    
    .question-actions .btn-edit,
    .question-actions .btn-danger {
        flex: 1;
        margin: 0;
        padding: 1rem;
        font-size: 1rem;
        justify-content: center;
    }
    
    /* Modal adjustments */
    .modal {
        padding: 0;
    }
    
    .modal-content {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
        max-width: 100%;
        width: 100%;
        padding: 1.5rem;
        overflow-y: auto;
    }
    
    .close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: #f9fafb;
        border-radius: 4px;
        width: 2.5rem;
        height: 2.5rem;
    }
    
    /* Form adjustments */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Pagination */
    .pagination {
        padding: 1.5rem 1rem;
    }
    
    .pagination button {
        padding: 0.75rem;
        margin: 0 0.125rem;
        min-width: 2.75rem;
    }
}

@media (max-width: 480px) {
    .question-meta {
        grid-template-columns: 1fr;
    }
    
    /* Adjust meta grid for 5 items - stack all on very small screens */
    .question-meta {
        gap: 0.75rem;
    }
    
    .question-meta-simple {
        margin-bottom: 1rem;
    }
    
    .question-actions {
        flex-direction: column;
    }
    
    .question-card {
        margin: 0.75rem;
        padding: 1.25rem;
    }
}

/* Show table on larger screens, hide mobile cards */
@media (min-width: 770px) {
    .mobile-questions-list {
        display: none;
    }
    
    .questions-table {
        display: table;
    }
}

/* Additional responsive font sizing */
@media (max-width: 1200px) {
    .questions-table {
        font-size: 0.8125rem;
    }
    
    .questions-table th,
    .questions-table td {
        padding: 0.875rem 0.625rem;
    }
}

@media (max-width: 1000px) {
    .questions-table {
        font-size: 0.75rem;
    }
    
    .questions-table th,
    .questions-table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Focus styles */
.btn:focus,
.search-box:focus,
.filter-select:focus,
.sort-select:focus {
    outline: 2px solid #111827;
    outline-offset: 2px;
}

/* Form button layout */
.form-group:last-child {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-group:last-child .btn {
    flex: 1;
    min-width: 120px;
}

/* Login and user management styles */
.login-links {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.link-button {
    background: none;
    border: none;
    color: #111827;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.875rem;
    padding: 0;
    font-family: inherit;
    transition: color 0.15s ease;
    font-weight: 400;
}

.link-button:hover {
    color: #6b7280;
    text-decoration: none;
}

.forgot-password-info {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
}

/* Table action buttons */
.questions-table td:last-child {
    white-space: nowrap;
}

.questions-table .btn-edit + .btn-danger {
    margin-left: 0;
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* User management modal */
.modal-content[style*="max-width: 800px"] {
    max-width: 90vw !important;
}

/* Enhanced visual hierarchy */
.questions-table th {
    border-bottom: 2px solid #e5e7eb;
}

#forgotPasswordView h2,
#loginView h2 {
    color: #111827;
    margin-bottom: 1.5rem;
    font-weight: 400;
}

/* Reset Request Modal Styling */
.reset-request-info {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.reset-request-info p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #374151;
}

.reset-request-info strong {
    color: #111827;
    font-weight: 600;
}

/* Form styling for small elements */
small {
    display: block;
    margin-top: 0.25rem;
}

/* Enhanced modal sizing for larger content */
.modal-content[style*="max-width: 1000px"] {
    max-width: 95vw !important;
}

@media (min-width: 1200px) {
    .modal-content[style*="max-width: 1000px"] {
        max-width: 1000px !important;
    }
}

/* Analytics Dashboard Styles */
.btn-analytics {
    background: #3b82f6;
    color: white;
    border: 1px solid #3b82f6;
}

.btn-analytics:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.analytics-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 6px;
}

.analytics-controls-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.export-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.export-controls label {
    font-weight: 500;
    color: #374151;
    margin-right: 0.5rem;
    font-size: 0.875rem;
}

.analytics-loading {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
    font-size: 1.1rem;
}

.analytics-error {
    text-align: center;
    padding: 3rem;
    color: #dc2626;
}

.analytics-error p {
    margin-bottom: 1rem;
}

.analytics-dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.analytics-summary h3,
.analytics-section h3 {
    margin-bottom: 1rem;
    color: #111827;
    font-size: 1.25rem;
    font-weight: 600;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.summary-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.summary-content {
    flex: 1;
    text-align: left;
}

.summary-sparkline {
    flex-shrink: 0;
    width: 80px;
    height: 30px;
    opacity: 0.8;
}

.summary-sparkline canvas {
    width: 100% !important;
    height: 100% !important;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
}

.summary-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.analytics-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
}

.top-questions,
.category-stats,
.daily-activity {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.question-stat,
.category-stat,
.daily-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.question-text,
.category-name,
.daily-date {
    font-weight: 500;
    color: #111827;
    flex: 1;
    margin-right: 1rem;
}

.question-text {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.question-metrics,
.category-metrics,
.daily-metrics {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.question-metrics span,
.category-metrics span,
.daily-metrics span {
    background: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    font-weight: 500;
}

/* Mobile responsiveness for analytics */
@media (max-width: 768px) {
    .analytics-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .analytics-controls .form-group {
        margin-bottom: 0;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .summary-card {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .summary-content {
        text-align: center;
    }
    
    .summary-sparkline {
        align-self: center;
    }
    
    .question-stat,
    .category-stat,
    .daily-stat {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .question-text,
    .category-name,
    .daily-date {
        max-width: 100%;
        margin-right: 0;
    }
    
    .question-metrics,
    .category-metrics,
    .daily-metrics {
        align-self: stretch;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }
    
    .summary-card {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .summary-content {
        text-align: center;
    }
    
    .summary-sparkline {
        align-self: center;
    }
    
    .question-metrics,
    .category-metrics,
    .daily-metrics {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Events Analytics Styles */
.event-types,
.article-events,
.navigation-events,
.behavior-events,
.daily-events,
.recent-events {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.event-type-stat,
.article-stat,
.navigation-stat,
.behavior-stat,
.daily-event-stat {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    transition: all 0.15s ease;
}

.event-type-stat:hover,
.article-stat:hover,
.navigation-stat:hover,
.behavior-stat:hover,
.daily-event-stat:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.event-type-name,
.article-title,
.navigation-action,
.behavior-type {
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.event-type-metrics,
.article-metrics,
.navigation-details,
.behavior-metrics,
.daily-event-metrics {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: #6b7280;
}

.event-type-metrics span,
.article-metrics span,
.navigation-details span,
.behavior-metrics span,
.daily-event-metrics span {
    background: #e5e7eb;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.recent-event {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.875rem;
    margin-bottom: 0.5rem;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.event-type {
    font-weight: 600;
    color: #111827;
    font-size: 0.875rem;
}

.event-time {
    font-size: 0.75rem;
    color: #6b7280;
}

.event-details {
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.4;
}

.event-detail {
    background: #e5e7eb;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
    display: inline-block;
}

/* Events Analytics Responsive */
@media (max-width: 768px) {
    .event-type-metrics,
    .article-metrics,
    .navigation-details,
    .behavior-metrics,
    .daily-event-metrics {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .event-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .event-details {
        line-height: 1.6;
    }
    
    .event-detail {
        margin-right: 0.25rem;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    .event-type-metrics span,
    .article-metrics span,
    .navigation-details span,
    .behavior-metrics span,
    .daily-event-metrics span {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .recent-event {
        padding: 0.75rem;
    }
    
    .event-detail {
        font-size: 0.7rem;
        padding: 0.1rem 0.3rem;
    }
}

/* Chart Styles */
.chart-container {
    position: relative;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

/* Pie chart specific styles */
#categoryBreakdownChart {
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Horizontal bar chart specific styles */
#topQuestionsChart {
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Adjust chart container for horizontal bar charts */
.analytics-section .chart-container {
    display: block;
}

.analytics-section:has(#topQuestionsChart) .chart-container {
    display: flex;
    justify-content: stretch;
    align-items: stretch;
}

.chart-fallback {
    padding: 20px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.chart-fallback .daily-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.chart-fallback .daily-stat:last-child {
    border-bottom: none;
}

.chart-fallback .daily-date {
    font-weight: 500;
    color: #374151;
}

.chart-fallback .daily-metrics {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: #6b7280;
}

@media (max-width: 768px) {
    .chart-container {
        padding: 15px;
        margin: 0 -15px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .chart-fallback {
        margin: 0 -15px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* Section Header and Toggle Controls */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.section-header h3 {
    margin: 0;
    color: #111827;
    font-size: 1.25rem;
    font-weight: 600;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: #f3f4f6;
    padding: 0.25rem;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toggle-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.toggle-btn.active {
    background: white;
    color: #111827;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #d1d5db;
}

.toggle-btn .btn-icon {
    font-size: 1rem;
}

/* Analytics Tables */
.analytics-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    font-size: 0.875rem;
}

.analytics-table thead {
    background: #f9fafb;
}

.analytics-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
}

.analytics-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    color: #111827;
}

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

.analytics-table tbody tr:last-child td {
    border-bottom: none;
}

/* Special table cell styling */
.question-cell,
.category-cell,
.event-type-cell,
.behavior-cell {
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.question-cell {
    max-width: 250px;
}

/* View containers */
.chart-view,
.table-view {
    width: 100%;
}

.table-view .table-container {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

/* Mobile responsiveness for toggles and tables */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .view-toggle {
        align-self: stretch;
        justify-content: center;
    }
    
    .toggle-btn {
        flex: 1;
        justify-content: center;
        padding: 0.75rem 0.5rem;
    }
    
    .analytics-table {
        font-size: 0.8rem;
    }
    
    .analytics-table th,
    .analytics-table td {
        padding: 0.5rem 0.75rem;
    }
    
    .question-cell,
    .category-cell,
    .event-type-cell,
    .behavior-cell {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .toggle-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
    
    .toggle-btn .btn-icon {
        font-size: 0.875rem;
    }
    
    .analytics-table {
        font-size: 0.75rem;
    }
    
    .analytics-table th,
    .analytics-table td {
        padding: 0.5rem;
    }
    
    .question-cell,
    .category-cell,
    .event-type-cell,
    .behavior-cell {
        max-width: 120px;
    }
}

/* Performance Dashboard Styles */
.performance-settings {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.setting-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.setting-group input[type="number"] {
    width: 100px;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.setting-group small {
    color: #6b7280;
    font-size: 0.8rem;
    margin-left: 1.5rem;
}

.memory-info,
.browser-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.memory-stat,
.browser-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.memory-label,
.browser-label {
    font-weight: 500;
    color: #374151;
}

.memory-value,
.browser-value {
    color: #6b7280;
    font-family: monospace;
    font-size: 0.875rem;
}

.browser-value {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

/* Mobile responsiveness for performance dashboard */
@media (max-width: 768px) {
    .setting-group {
        gap: 0.75rem;
    }
    
    .setting-group label {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .setting-group small {
        margin-left: 0;
    }
    
    .memory-stat,
    .browser-stat {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .browser-value {
        max-width: 100%;
        text-align: left;
    }
}

@media (max-width: 480px) {
    .performance-settings {
        gap: 1rem;
    }
    
    .setting-group input[type="number"] {
        width: 80px;
    }
}

/* Category usage specific styles */
.category-usage-stat {
    padding: 15px;
    margin: 10px 0;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.category-usage-stat .category-name {
    font-weight: 600;
    font-size: 1.1em;
    color: #1f2937;
    margin-bottom: 8px;
}

.category-usage-stat .category-metrics {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 0.9em;
    color: #6b7280;
}

.category-usage-stat .category-metrics span {
    background-color: #e0f2fe;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* Category trends specific styles */
.trend-stat {
    padding: 12px;
    margin: 8px 0;
    background-color: #fefefe;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.trend-stat .trend-date {
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-size: 0.95em;
}

.trend-stat .trend-categories {
    font-size: 0.85em;
    color: #6b7280;
    line-height: 1.4;
}

.trend-stat .trend-categories span {
    margin-right: 10px;
    white-space: nowrap;
}

/* Mobile responsiveness for category analytics */
@media (max-width: 768px) {
    .category-usage-stat {
        padding: 12px;
        margin: 8px 0;
    }
    
    .category-usage-stat .category-metrics {
        gap: 10px;
        font-size: 0.85em;
    }
    
    .trend-stat {
        padding: 10px;
        margin: 6px 0;
    }
    
    .trend-stat .trend-categories span {
        margin-right: 8px;
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    .category-usage-stat .category-metrics {
        flex-direction: column;
        gap: 6px;
    }
    
    .category-usage-stat .category-metrics span {
        align-self: flex-start;
        font-size: 0.8em;
    }
    
    .trend-stat .trend-categories {
        font-size: 0.8em;
    }
    
    .trend-stat .trend-categories span {
        display: block;
        margin-bottom: 4px;
        margin-right: 0;
    }
}
