* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    background: white;
    border-radius: 10px;
    padding: 20px 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-header h1 {
    color: #2d3748;
    font-size: 28px;
    font-weight: 700;
}

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

.date-filter, .user-filter {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-filter label, .user-filter label {
    font-weight: 600;
    color: #4a5568;
}

select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    color: #2d3748;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.refresh-btn {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.refresh-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

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

.metric-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.metric-card h3 {
    font-size: 14px;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 5px;
}

.metric-change {
    font-size: 14px;
    font-weight: 600;
}

.metric-change.positive {
    color: #48bb78;
}

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

.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
    gap: 20px;
}

.chart-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chart-container h3 {
    font-size: 18px;
    color: #2d3748;
    margin-bottom: 15px;
    font-weight: 600;
}

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

.user-details-section, .recent-sessions-section, .event-timeline-section, .function-metrics-section {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.user-details-section h2, .recent-sessions-section h2, .event-timeline-section h2, .function-metrics-section h2 {
    font-size: 22px;
    color: #2d3748;
    margin-bottom: 20px;
    font-weight: 600;
}

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

.data-table thead {
    background: #f7fafc;
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    font-size: 14px;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    color: #2d3748;
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: #f7fafc;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.action-btn {
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.3s;
}

.action-btn:hover {
    background: #5a67d8;
}

.status-active {
    display: inline-block;
    padding: 4px 8px;
    background: #48bb78;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-completed {
    display: inline-block;
    padding: 4px 8px;
    background: #cbd5e0;
    color: #2d3748;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.event-timeline {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.event-item {
    padding: 15px;
    border-left: 3px solid #667eea;
    margin-left: 20px;
    margin-bottom: 20px;
    background: #f7fafc;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.event-item:before {
    content: '';
    position: absolute;
    left: -8px;
    top: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
}

.event-time {
    font-size: 12px;
    color: #718096;
    margin-bottom: 5px;
}

.event-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 5px;
}

.event-description {
    color: #4a5568;
    font-size: 14px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 10px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #000;
}

.session-info, .user-info {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.session-info p, .user-info p {
    margin-bottom: 8px;
    color: #2d3748;
}

.conversation-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
}

.user-message {
    background: #e6fffa;
    border-left: 3px solid #38b2ac;
}

.agent-message {
    background: #f0fff4;
    border-left: 3px solid #48bb78;
}

.message .timestamp {
    font-size: 11px;
    color: #718096;
    display: block;
    margin-top: 5px;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.mini-table th {
    background: #f7fafc;
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
}

.mini-table td {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    color: #2d3748;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 50%;
    border-top-color: #667eea;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .dashboard-container {
        padding: 10px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .dashboard-header h1 {
        font-size: 22px;
        width: 100%;
    }

    .header-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .date-filter, .user-filter {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .date-filter select,
    .user-filter select {
        width: 100%;
    }

    .search-bar {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .search-bar input {
        width: 100%;
    }

    .search-btn {
        width: 100%;
    }

    .export-controls {
        width: 100%;
    }

    .export-btn,
    .refresh-btn {
        width: 100%;
        padding: 12px 16px;
    }

    .charts-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .chart-container {
        padding: 15px;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chart-container canvas {
        max-height: 250px;
    }

    .chart-container .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chart-container .data-table {
        min-width: 500px;
    }

    .metrics-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .metric-card {
        padding: 15px;
    }

    .metric-value {
        font-size: 24px;
    }

    .metric-card h3 {
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    /* Table responsiveness - horizontal scroll */
    .user-table-container,
    .sessions-table-container,
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        font-size: 12px;
        min-width: 600px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    .user-details-section,
    .recent-sessions-section,
    .event-timeline-section,
    .search-results-section,
    .function-metrics-section {
        padding: 15px;
    }

    .user-details-section h2,
    .recent-sessions-section h2,
    .event-timeline-section h2,
    .function-metrics-section h2 {
        font-size: 18px;
    }

    .action-btn {
        padding: 8px 10px;
        font-size: 11px;
    }

    .event-timeline {
        max-height: 300px;
    }

    .event-item {
        padding: 12px;
        margin-left: 10px;
    }
}

/* Additional mobile breakpoint for very small screens */
@media (max-width: 480px) {
    .dashboard-header h1 {
        font-size: 18px;
    }

    .metrics-summary {
        grid-template-columns: 1fr;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-value {
        font-size: 20px;
    }

    .chart-container h3 {
        font-size: 16px;
    }

    .dashboard-content {
        gap: 15px;
    }

    .chart-container {
        padding: 12px;
    }

    .chart-container .data-table {
        min-width: 450px;
        font-size: 11px;
    }

    .data-table {
        font-size: 11px;
        min-width: 500px;
    }

    .data-table th,
    .data-table td {
        padding: 6px 4px;
    }

    .modal-content {
        width: 98%;
        padding: 15px;
        margin: 5% auto;
    }

    .close {
        font-size: 24px;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .metrics-summary {
        grid-template-columns: repeat(3, 1fr);
    }

    .modal-content {
        max-height: 90vh;
    }
}

/* Tablet breakpoint */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-container {
        padding: 15px;
    }

    .charts-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .metrics-summary {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Improve touch targets on all screen sizes */
@media (hover: none) and (pointer: coarse) {
    .action-btn,
    .search-btn,
    .export-btn,
    .refresh-btn {
        min-height: 44px;
        min-width: 44px;
    }

    select {
        min-height: 44px;
    }

    .search-bar input {
        min-height: 44px;
    }
}

/* Search functionality */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-bar input {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    width: 100%;
    max-width: 250px;
    font-size: 14px;
}

.search-btn {
    padding: 8px 12px;
    background: #4a5568;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.search-results-section {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-result-item {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.result-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.result-time {
    color: #718096;
    font-size: 12px;
}

.result-content {
    color: #4a5568;
    margin-bottom: 10px;
}

/* Export functionality */
.export-controls {
    position: relative;
}

.export-btn {
    padding: 8px 16px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 5px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.export-menu button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

.export-menu button:hover {
    background: #f7fafc;
}

.hidden {
    display: none !important;
}

/* User journey visualization */
.user-journey-section {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.journey-timeline {
    position: relative;
    padding-left: 40px;
}

.journey-node {
    position: relative;
    margin-bottom: 30px;
}

.journey-connector {
    position: absolute;
    left: -30px;
    top: 0;
    bottom: -30px;
    width: 2px;
    background: #cbd5e0;
}

.journey-connector.first {
    top: 20px;
}

.journey-connector::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 18px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #667eea;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.journey-content {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.journey-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.journey-time {
    color: #718096;
    font-size: 12px;
}

.journey-metrics {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #4a5568;
}

.journey-events {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.journey-event {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 12px;
}

.event-type {
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 3px;
    color: #4a5568;
}

.event-data {
    color: #718096;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

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

/* Image Gallery Styles */
.user-images-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.images-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.image-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background: white;
}

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

.gallery-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.image-info {
    padding: 12px;
    background: #f7fafc;
}

.image-info p {
    margin: 4px 0;
    font-size: 0.9em;
}

.image-user {
    color: #2d3748;
    font-size: 1em !important;
}

.image-filename {
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-date {
    color: #718096;
    font-size: 0.85em !important;
}

.image-size {
    color: #a0aec0;
    font-size: 0.85em !important;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-controls label {
    font-weight: 500;
    color: #4a5568;
}

.filter-controls select {
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background: white;
    font-size: 0.95em;
    cursor: pointer;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    justify-content: center;
    align-items: center;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: #cbd5e0;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.lightbox-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 8px;
    color: #2d3748;
    min-width: 300px;
}

.lightbox-info p {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
}

.lightbox-info strong {
    color: #1a202c;
    margin-right: 10px;
}

.lightbox-controls {
    display: flex;
    gap: 15px;
}

.lightbox-btn {
    padding: 12px 24px;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background 0.2s;
}

.lightbox-btn:hover {
    background: #3182ce;
}

.lightbox-btn:active {
    transform: scale(0.98);
}

.no-data {
    text-align: center;
    color: #a0aec0;
    padding: 40px;
    font-size: 1.1em;
}

/* Responsive Design for Images */
@media (max-width: 768px) {
    .images-gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .gallery-image {
        height: 150px;
    }

    .lightbox-content {
        max-width: 95%;
    }

    .lightbox-close {
        top: 10px;
        right: 20px;
        font-size: 30px;
    }

    .lightbox-controls {
        flex-direction: column;
        width: 100%;
    }

    .lightbox-btn {
        width: 100%;
    }
}

/* User Images Grid in Modal */
.user-images-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 15px 0;
}

.user-image-thumb {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-image-thumb:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .user-images-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* Session Images Grid */
.session-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
}

.session-image-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.session-image-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .session-images-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
}