/* Add CSS Variables for theming */
:root {
    /* Light theme */
    --bg-color-light: #f5f5f5;
    --column-bg-light: #ffffff;
    --item-bg-light: #f0f0f0;
    --text-color-light: #333333;
    --border-color-light: #cccccc;
    --user-bg-light: #e3f2fd;     /* Light blue */
    --assistant-bg-light: #f5f5f5; /* Light grey */
    
    /* Dark theme */
    --bg-color-dark: #1a1a1a;
    --column-bg-dark: #1e1e1e;
    --item-bg-dark: #2d2d2d;
    --text-color-dark: #ffffff;
    --border-color-dark: #333333;
    --user-bg-dark: #1e3a5f;      /* Dark blue */
    --assistant-bg-dark: #383838;  /* Dark grey */
}

/* Theme-aware styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s;
    overflow: hidden;
    height: 100vh;
}

body.dark-mode {
    background-color: var(--bg-color-dark);
    color: var(--text-color-dark);
}

body:not(.dark-mode) {
    background-color: var(--bg-color-light);
    color: var(--text-color-light);
}

.main-container {
    display: flex;
    gap: 20px;
    height: 100vh;
    padding: 10px;
    box-sizing: border-box;
}

.sidebar {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.columns-container {
    flex: 1;
    display: flex;
    gap: 20px;
    height: 100%;
}

.content {
    display: none;
}

.mic-button {
    width: 120px;
    height: 120px;
}

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

.status {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

.status {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
    padding: 8px 16px;
    border-radius: 20px;
    background-color: #e0e0e0;
}

.mic-button {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: #47aca9;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.current-industry {
    width: 150px;
    padding: 8px;
    margin-top: 10px;
    text-align: center;
    font-size: 14px;
    color: var(--text-color-dark);
    background-color: var(--item-bg-dark);
    border-radius: 5px;
    transition: all 0.3s;
}

body:not(.dark-mode) .current-industry {
    color: var(--text-color-light);
    background-color: var(--item-bg-light);
}

.current-industry span {
    font-weight: bold;
}

.industry-button {
    width: 150px;
    padding: 10px;
    border-radius: 5px;
    background-color: #4a9eff;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.3s, transform 0.2s;
}

.industry-button:hover {
    background-color: #3d8be0;
    transform: scale(1.05);
}

.industry-button:active {
    transform: scale(0.95);
}

.mic-button:hover {
    background-color: #3d918e;
    transform: scale(1.05);
}

.mic-button:active {
    transform: scale(0.95);
}

.conversation {
    max-width: 800px;
    margin: 0 auto;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.conversation h2 {
    margin-top: 0;
    color: #333;
    text-align: center;
}

#messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.message {
    margin: 10px 0;
    padding: 10px;
    border-radius: 5px;
}

.message.user {
    background-color: #e3f2fd;
    margin-left: 20px;
}

.message.assistant {
    background-color: #f5f5f5;
    margin-right: 20px;
}

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

#messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

.column {
    flex: 1;
    border: 1px solid var(--border-color-dark);
    border-radius: 5px;
    padding: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--column-bg-dark);
    transition: all 0.3s;
    max-height: calc(100vh - 60px);
    box-sizing: border-box;
}

body:not(.dark-mode) .column {
    border-color: var(--border-color-light);
    background-color: var(--column-bg-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.column h2 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-color-dark);
    transition: color 0.3s;
}

body:not(.dark-mode) .column h2 {
    color: var(--text-color-light);
}

#conversationMessages, #logMessages {
    overflow-y: scroll;
    flex-grow: 1;
    scrollbar-gutter: stable;
    padding: 5px;
    height: calc(100% - 40px);
}

.log-message {
    font-family: monospace;
    font-size: 0.9em;
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
    white-space: pre-wrap;
}

.timeline {
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#timelineMessages {
    overflow-y: auto;
    flex-grow: 1;
}

.timeline-item, .timeline-spacer {
    margin: 4px 0;
    min-height: 20px;
}

.timeline-item.message {
    background-color: var(--item-bg-dark);
    color: var(--text-color-dark);
    border-left: 3px solid #47aca9;
    padding: 8px 12px;
    transition: all 0.3s;
}

body:not(.dark-mode) .timeline-item.message {
    background-color: var(--item-bg-light);
    color: var(--text-color-light);
}

.timeline-item.log-message {
    font-family: monospace;
    font-size: 0.9em;
    padding: 8px 12px;
    border-left: 3px solid #888;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
    background-color: var(--item-bg-dark);
    color: var(--text-color-dark);
    transition: all 0.3s;
}

body:not(.dark-mode) .timeline-item.log-message {
    background-color: var(--item-bg-light);
    color: var(--text-color-light);
}

.timeline-spacer {
    background-color: transparent;
    border: none;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    margin-right: 8px;
}

.toggle-label {
    color: var(--text-color-dark);
    font-size: 14px;
    transition: color 0.3s;
}

body:not(.dark-mode) .toggle-label {
    color: var(--text-color-light);
}

.sample-data {
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    background-color: var(--column-bg-dark);
    border: 1px solid var(--border-color-dark);
    border-radius: 5px;
    transition: all 0.3s;
}

body:not(.dark-mode) .sample-data {
    background-color: var(--column-bg-light);
    border-color: var(--border-color-light);
}

.sample-data h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    text-align: center;
    color: var(--text-color-dark);
}

body:not(.dark-mode) .sample-data h3 {
    color: var(--text-color-light);
}

.sample-data-content {
    font-size: 12px;
    overflow-y: auto;
    max-height: 300px;
}

.customer-card {
    padding: 8px;
    margin-bottom: 10px;
    background-color: var(--item-bg-dark);
    border-radius: 4px;
    color: var(--text-color-dark);
    cursor: pointer;
    transition: transform 0.2s;
}

body:not(.dark-mode) .customer-card {
    background-color: var(--item-bg-light);
    color: var(--text-color-light);
}

.customer-info {
    margin-bottom: 8px;
}

.customer-info div {
    margin: 2px 0;
}

.customer-appointments, .customer-orders {
    margin-top: 8px;
    padding: 6px 0 6px 8px;
    border-left: 2px solid var(--border-color-dark);
}

.customer-appointments div, .customer-orders div {
    margin: 2px 0;
    font-size: 11px;
}

body:not(.dark-mode) .customer-appointments,
body:not(.dark-mode) .customer-orders {
    border-left-color: var(--border-color-light);
}

/* Update message styles */
.timeline-item.message.user {
    background-color: var(--user-bg-dark);
    border-left: 3px solid #4a9eff;
}

.timeline-item.message.assistant {
    background-color: var(--assistant-bg-dark);
    border-left: 3px solid #47aca9;
}

body:not(.dark-mode) .timeline-item.message.user {
    background-color: var(--user-bg-light);
}

body:not(.dark-mode) .timeline-item.message.assistant {
    background-color: var(--assistant-bg-light);
}

.customer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expand-icon {
    transition: transform 0.3s;
}

.customer-card.collapsed .expand-icon {
    transform: rotate(-90deg);
}

.customer-details {
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    max-height: 500px;
    opacity: 1;
}

.customer-card.collapsed .customer-details {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.customer-contact {
    margin: 8px 0;
    padding-top: 8px;
    border-top: 1px solid var(--border-color-dark);
}

body:not(.dark-mode) .customer-contact {
    border-top-color: var(--border-color-light);
}

.customer-card:hover {
    transform: translateX(2px);
}

/* Update the media query to handle both sidebar and columns */
@media (orientation: portrait) {
    .main-container {
        gap: 10px;
    }

    .sidebar {
        width: 180px;
        min-width: 180px;
    }

    .columns-container {
        min-width: 0; /* Allow container to shrink */
        overflow: hidden; /* Prevent horizontal scroll */
    }

    .columns-container .column {
        width: calc((100% - 10px) / 2); /* Split remaining space evenly, accounting for gap */
        min-width: 0;
    }
}

.audio-controls {
    margin: 10px 0;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 5px;
}

.device-select {
    margin: 5px 0;
}

.device-select label {
    display: block;
    margin-bottom: 3px;
    color: var(--text-primary);
}

.device-select select {
    width: 100%;
    padding: 5px;
    border-radius: 3px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Add dark mode specific styles */
body.dark-mode .device-select select {
    background-color: var(--item-bg-dark);
    color: var(--text-color-dark);
    border-color: var(--border-color-dark);
}

body.dark-mode .device-select select option {
    background-color: var(--item-bg-dark);
    color: var(--text-color-dark);
}

/* Industry Selection Popup Styles */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: var(--column-bg-dark);
    border-radius: 8px;
    padding: 20px;
    width: 300px;
    max-width: 90%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: var(--text-color-dark);
    transition: all 0.3s;
}

body:not(.dark-mode) .popup-content {
    background-color: var(--column-bg-light);
    color: var(--text-color-light);
}

.popup-content h3 {
    margin-top: 0;
    text-align: center;
    margin-bottom: 15px;
}

.industry-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.industry-item {
    padding: 10px 15px;
    margin-bottom: 5px;
    background-color: var(--item-bg-dark);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

body:not(.dark-mode) .industry-item {
    background-color: var(--item-bg-light);
}

.industry-item:hover {
    transform: translateX(5px);
}

.industry-item.selected {
    border-left: 3px solid #4a9eff;
    font-weight: bold;
}

.popup-buttons {
    display: flex;
    justify-content: center;
}

.popup-button {
    padding: 8px 15px;
    border-radius: 4px;
    background-color: #4a9eff;
    border: none;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.popup-button:hover {
    background-color: #3d8be0;
    transform: scale(1.05);
}

.popup-button:active {
    transform: scale(0.95);
}