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

:root {
    /* Coffee-desk-demo inspired color scheme */
    /* Primary: hsl(26, 38%, 44%) - warm coffee brown */
    --coffee-primary: hsl(26, 38%, 44%);
    --coffee-primary-foreground: hsl(210, 40%, 98%);
    --coffee-primary-hover: hsl(26, 38%, 50%);
    
    /* Background colors */
    --coffee-background: hsl(0, 0%, 100%);
    --coffee-foreground: hsl(222.2, 84%, 4.9%);
    
    /* Card colors */
    --coffee-card: hsl(0, 0%, 100%);
    --coffee-card-foreground: hsl(222.2, 84%, 4.9%);
    
    /* Secondary colors */
    --coffee-secondary: hsl(210, 40%, 96%);
    --coffee-secondary-foreground: hsl(222.2, 84%, 4.9%);
    
    /* Muted colors */
    --coffee-muted: hsl(210, 40%, 96%);
    --coffee-muted-foreground: hsl(215.4, 16.3%, 46.9%);
    
    /* Accent colors */
    --coffee-accent: hsl(210, 40%, 96%);
    --coffee-accent-foreground: hsl(222.2, 84%, 4.9%);
    
    /* Border and input */
    --coffee-border: hsl(214.3, 31.8%, 91.4%);
    --coffee-input: hsl(214.3, 31.8%, 91.4%);
    --coffee-ring: hsl(26, 38%, 44%);
    
    /* Sidebar colors */
    --coffee-sidebar-bg: hsl(0, 0%, 98%);
    --coffee-sidebar-foreground: hsl(222.2, 84%, 4.9%);
    --coffee-sidebar-accent: hsl(210, 40%, 96%);
    --coffee-sidebar-accent-foreground: hsl(222.2, 84%, 4.9%);
    --coffee-sidebar-border: hsl(214.3, 31.8%, 91.4%);
    
    /* Status colors */
    --coffee-success: hsl(142, 71%, 45%);
    --coffee-error: hsl(0, 84.2%, 60.2%);
    
    /* Border radius */
    --coffee-radius: 0.5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--coffee-background);
    color: var(--coffee-foreground);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styles - matching coffee-desk-demo */
.sidebar {
    width: 16rem;
    background: var(--coffee-sidebar-bg);
    border-right: 1px solid var(--coffee-sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--coffee-sidebar-border);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-image {
    height: 2.5rem;
    width: auto;
    object-fit: contain;
}

/* User Section */
.user-section {
    padding: 1rem;
    border-bottom: 1px solid var(--coffee-sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--coffee-sidebar-accent);
    border-radius: calc(var(--coffee-radius) - 2px);
    transition: background-color 0.2s;
}

.user-info:hover {
    background: var(--coffee-accent);
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--coffee-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: var(--coffee-muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--coffee-border);
    color: var(--coffee-foreground);
    padding: 0.5rem;
    border-radius: calc(var(--coffee-radius) - 2px);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: var(--coffee-accent);
    border-color: var(--coffee-border);
}

/* Integrations Section */
.integrations-section {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--coffee-muted-foreground);
    margin-bottom: 0.75rem;
}

.integration-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.integration-card {
    background: var(--coffee-card);
    border: 1px solid var(--coffee-border);
    border-radius: var(--coffee-radius);
    padding: 0.75rem;
    transition: all 0.2s;
}

.integration-card:hover {
    background: var(--coffee-accent);
    border-color: var(--coffee-border);
}

.integration-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.integration-icon {
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.integration-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.integration-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--coffee-foreground);
}

.integration-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--coffee-muted);
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background-color: var(--coffee-primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.integration-status-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 70px;
    text-align: center;
}

.integration-status-badge.connected {
    background: var(--coffee-success);
    color: white;
}

.integration-status-badge.disconnected {
    background: var(--coffee-muted);
    color: var(--coffee-muted-foreground);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--coffee-background);
    overflow: hidden;
}

.chat-header {
    background: var(--coffee-background);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--coffee-border);
}

.header-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--coffee-foreground);
    margin-bottom: 0.25rem;
}

.header-content p {
    font-size: 0.875rem;
    color: var(--coffee-muted-foreground);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--coffee-background);
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-in-out;
    max-width: 85%;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
}

.ai-message .message-avatar {
    background: var(--coffee-muted);
    color: var(--coffee-foreground);
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: var(--coffee-radius);
    line-height: 1.6;
    border: 1px solid var(--coffee-border);
}

.user-message .message-content {
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
    border-color: var(--coffee-primary);
}

.ai-message .message-content {
    background: var(--coffee-card);
    color: var(--coffee-card-foreground);
    border-color: var(--coffee-border);
}

.message-content p {
    margin: 0;
    word-wrap: break-word;
}

.chat-input-container {
    padding: 1.5rem 2rem;
    background: var(--coffee-background);
    border-top: 1px solid var(--coffee-border);
}

.chat-form {
    width: 100%;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: var(--coffee-background);
    border-radius: var(--coffee-radius);
    padding: 0.5rem;
    border: 1px solid var(--coffee-input);
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--coffee-ring);
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--coffee-ring);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    color: var(--coffee-foreground);
}

#messageInput::placeholder {
    color: var(--coffee-muted-foreground);
}

#sendButton {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: calc(var(--coffee-radius) - 2px);
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    background: var(--coffee-primary-hover);
}

#sendButton:disabled {
    background: var(--coffee-muted);
    color: var(--coffee-muted-foreground);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    background: var(--coffee-card);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--coffee-radius);
    width: 90%;
    max-width: 32rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease-out;
    overflow: hidden;
    border: 1px solid var(--coffee-border);
}

.modal-header {
    background: var(--coffee-background);
    color: var(--coffee-foreground);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--coffee-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--coffee-muted-foreground);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: calc(var(--coffee-radius) - 2px);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--coffee-accent);
    color: var(--coffee-foreground);
}

.modal-body {
    padding: 1.5rem;
    background: var(--coffee-card);
}

.modal-body p {
    margin: 0 0 1.5rem 0;
    color: var(--coffee-card-foreground);
    line-height: 1.6;
    font-size: 0.875rem;
}

.auth-link-container {
    margin: 1.5rem 0;
    text-align: center;
}

.auth-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: calc(var(--coffee-radius) - 2px);
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.auth-link:hover {
    background: var(--coffee-primary-hover);
}

.auth-icon {
    font-size: 1rem;
}

.auth-arrow {
    font-size: 0.875rem;
    opacity: 0.8;
}

.auth-steps {
    margin: 1.5rem 0;
}

.step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: var(--coffee-accent);
    border-radius: calc(var(--coffee-radius) - 2px);
    border-left: 3px solid var(--coffee-primary);
}

.step-number {
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.step-text {
    color: var(--coffee-foreground);
    font-size: 0.875rem;
}

.modal-footer {
    padding: 1.5rem;
    background: var(--coffee-background);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    border-top: 1px solid var(--coffee-border);
}

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--coffee-border);
    border-radius: calc(var(--coffee-radius) - 2px);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-family: inherit;
}

.btn-primary {
    background: var(--coffee-primary);
    color: var(--coffee-primary-foreground);
    border-color: var(--coffee-primary);
}

.btn-primary:hover {
    background: var(--coffee-primary-hover);
}

.btn-secondary {
    background: var(--coffee-background);
    color: var(--coffee-foreground);
    border-color: var(--coffee-border);
}

.btn-secondary:hover {
    background: var(--coffee-accent);
}

/* Loading animation */
.typing-indicator {
    display: flex;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    background: var(--coffee-card);
    border-radius: var(--coffee-radius);
    width: fit-content;
    border: 1px solid var(--coffee-border);
}

.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--coffee-primary);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar,
.integrations-section::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.integrations-section::-webkit-scrollbar-track {
    background: var(--coffee-background);
}

.chat-messages::-webkit-scrollbar-thumb,
.integrations-section::-webkit-scrollbar-thumb {
    background: var(--coffee-muted);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.integrations-section::-webkit-scrollbar-thumb:hover {
    background: var(--coffee-muted-foreground);
}

/* Email Display Styles */
.email-display {
    margin-top: 0.5rem;
}

.email-content {
    background: var(--coffee-accent);
    border: 1px solid var(--coffee-border);
    border-radius: var(--coffee-radius);
    padding: 1rem;
}

.email-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 1000px) {
    .email-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
        gap: 1rem;
    }
}

.email-item {
    background: var(--coffee-card);
    border: 1px solid var(--coffee-border);
    border-radius: calc(var(--coffee-radius) - 2px);
    padding: 1rem;
    transition: all 0.2s;
}

.email-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-color: var(--coffee-primary);
}

.email-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.email-subject {
    color: var(--coffee-foreground);
    font-size: 1rem;
    font-weight: 600;
}

.email-sender {
    color: var(--coffee-muted-foreground);
    font-size: 0.875rem;
}

.email-date {
    color: var(--coffee-muted-foreground);
    font-size: 0.75rem;
    font-style: italic;
}

.email-preview {
    color: var(--coffee-foreground);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Calendar Event Display Styles */
.calendar-display {
    margin-top: 0.5rem;
}

.calendar-content {
    background: var(--coffee-accent);
    border: 1px solid var(--coffee-border);
    border-radius: var(--coffee-radius);
    padding: 1rem;
}

.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 1000px) {
    .calendar-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
        gap: 1rem;
    }
}

.calendar-item {
    background: var(--coffee-card);
    border: 1px solid var(--coffee-border);
    border-radius: calc(var(--coffee-radius) - 2px);
    padding: 1rem;
    transition: all 0.2s;
}

.calendar-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-color: var(--coffee-primary);
}

.calendar-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.calendar-title {
    color: var(--coffee-foreground);
    font-size: 1rem;
    font-weight: 600;
}

.calendar-organizer {
    color: var(--coffee-muted-foreground);
    font-size: 0.875rem;
}

.calendar-time {
    color: var(--coffee-muted-foreground);
    font-size: 0.75rem;
    font-style: italic;
}

.calendar-description {
    color: var(--coffee-foreground);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.calendar-conference {
    background: var(--coffee-accent);
    border: 1px solid var(--coffee-border);
    border-radius: calc(var(--coffee-radius) - 2px);
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.calendar-conference-title {
    color: var(--coffee-primary);
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
}

.calendar-conference-link {
    color: var(--coffee-primary);
    text-decoration: none;
    font-size: 0.8125rem;
}

.calendar-conference-link:hover {
    text-decoration: underline;
}

.calendar-location {
    color: var(--coffee-muted-foreground);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.calendar-link {
    margin-top: 0.75rem;
}

.calendar-link a {
    color: var(--coffee-primary);
    text-decoration: none;
    font-size: 0.8125rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.calendar-link a:hover {
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .main-content {
        flex: 1;
    }
    
    .message {
        max-width: 95%;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .header-content h2 {
        font-size: 1.25rem;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .chat-input-container {
        padding: 1rem;
    }
}
