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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.nav-brand h1 a {
    color: #2c5aa0;
    text-decoration: none;
    font-size: 1.8rem;
    font-weight: bold;
}

.nav-brand h1 a .logo {
    height: 40px;
    width: auto;
}

.tagline {
    color: #6c757d;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: #333;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.nav-link:hover {
    background-color: #f8f9fa;
}

.nav-dropdown {
    position: relative;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 4px;
    z-index: 1;
}

.nav-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {
    background-color: #f8f9fa;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #2c5aa0;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn:hover {
    background: #1e3f73;
}

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

.btn-secondary:hover {
    background: #5a6268;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-primary {
    background: #F91B5D;
}

.btn-primary:hover {
    background: #d9185a;
}

.btn-full {
    width: 100%;
}

/* Messages */
.messages {
    margin-bottom: 1rem;
}

.message {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    position: relative;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message-close {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
}

/* Home page */
.hero-section {
    background: linear-gradient(135deg, #2c5aa0 0%, #1e3f73 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.3rem;
    margin-bottom: 3rem;
    opacity: 0.9;
}

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

.feature {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 8px;
}

.feature h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.info-section {
    padding: 4rem 0;
    background: white;
}

.info-section h2 {
    text-align: center;
    margin-bottom: 3rem;
    font-size: 2.5rem;
    color: #2c5aa0;
}

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

.step {
    text-align: center;
    padding: 2rem;
}

.step-number {
    display: inline-block;
    width: 60px;
    height: 60px;
    background: #2c5aa0;
    color: white;
    border-radius: 50%;
    line-height: 60px;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.step h3 {
    margin-bottom: 1rem;
    color: #2c5aa0;
}

/* Dashboard */
.dashboard {
    padding: 2rem 0;
}

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

.dashboard-actions {
    display: flex;
    gap: 1rem;
}

.dashboard-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

.sidebar {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    height: fit-content;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-section h3 {
    margin-bottom: 1rem;
    color: #2c5aa0;
    font-size: 1.1rem;
}

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

.chat-item {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background: #e9ecef;
}

.chat-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.chat-date {
    font-size: 0.85rem;
    color: #6c757d;
}

.empty-state {
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.xero-status {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-dot.connected {
    background: #28a745;
}

.status-dot.disconnected {
    background: #dc3545;
}

.xero-summary {
    font-size: 0.9rem;
}

.summary-item {
    padding: 0.25rem 0;
    border-bottom: 1px solid #e9ecef;
}

.summary-item:last-child {
    border-bottom: none;
}

.main-area {
    background: white;
    border-radius: 8px;
    padding: 2rem;
}

.welcome-area h2 {
    color: #2c5aa0;
    margin-bottom: 1rem;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.suggestion-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #2c5aa0;
}

.suggestion-card h3 {
    margin-bottom: 0.5rem;
    color: #2c5aa0;
}

.quick-actions {
    text-align: center;
    margin-top: 2rem;
}

.quick-chat {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 8px;
}

.chat-preview {
    background: white;
    padding: 1.5rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.last-message {
    margin: 1rem 0;
    color: #6c757d;
}

/* Chat interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.chat-sidebar {
    background: white;
    border-radius: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-sidebar .chat-header {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-sessions {
    padding: 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.chat-session {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    color: #333;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s;
    position: relative;
}

.session-content {
    flex: 1;
    text-decoration: none;
    color: inherit;
    display: block;
}

.chat-session:hover {
    background: #f8f9fa;
}

.chat-session.active {
    background: #e3f2fd;
    border-left: 4px solid #2c5aa0;
}

.session-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.session-date {
    font-size: 0.85rem;
    color: #6c757d;
}

.session-actions {
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    gap: 0.25rem;
}

.chat-session:hover .session-actions {
    opacity: 1;
}

.delete-session-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 2px;
    color: #6c757d;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.delete-session-btn:hover {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.sidebar-footer {
    padding: 0.5rem;
    border-top: 1px solid #e9ecef;
    margin-top: auto;
}

.btn-full-width {
    width: 100%;
    justify-content: center;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.chat-main {
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-main .chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-info {
    color: #6c757d;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Debug toggle styles */
.debug-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    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: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2c5aa0;
}

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

.toggle-label {
    font-size: 0.9rem;
    color: #6c757d;
    user-select: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
    min-height: 0;
}

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    max-width: 100%;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: #2c5aa0;
    color: white;
}

.message-assistant .message-avatar {
    background: #28a745;
    color: white;
}

.message-content {
    flex: 1;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-text {
    margin-bottom: 0.5rem;
}

.tool-calls, .tool-responses {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.9rem;
}

.tool-calls pre, .tool-responses pre {
    margin-top: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.empty-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.welcome-message {
    text-align: center;
    max-width: 600px;
    padding: 2rem;
}

.welcome-message h3 {
    color: #2c5aa0;
    margin-bottom: 1rem;
}

.welcome-message ul {
    text-align: left;
    margin: 1rem 0;
}

.welcome-message li {
    margin-bottom: 0.5rem;
    font-style: italic;
    color: #6c757d;
}

.chat-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    background: white;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #6c757d;
    font-style: italic;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6c757d;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

.input-group {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.input-group textarea {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.75rem;
    font-family: inherit;
    resize: none;
    min-height: 80px;
    max-height: 120px;
}

.input-group button {
    align-self: stretch;
}

/* Forms */
.auth-page, .setup-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

.auth-form, .setup-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.setup-content {
    max-width: 800px;
}

.auth-header, .setup-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1, .setup-header h1 {
    color: #2c5aa0;
    margin-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group input, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #6c757d;
    font-size: 0.875rem;
}

.form-errors {
    margin-bottom: 1rem;
}

.error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

/* Setup page specific */
.setup-steps {
    margin: 2rem 0;
}

.setup-steps .step {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e9ecef;
}

.setup-steps .step:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.setup-steps .step-number {
    width: 40px;
    height: 40px;
    background: #2c5aa0;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content h3 {
    color: #2c5aa0;
    margin-bottom: 1rem;
}

.setup-form {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.status-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.status-details p {
    margin-bottom: 0.5rem;
}

.setup-help {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e9ecef;
}

.help-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.help-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 4px;
    border-left: 4px solid #2c5aa0;
}

.help-card h4 {
    color: #2c5aa0;
    margin-bottom: 0.5rem;
}

/* Footer */
.footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .dashboard-content,
    .chat-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: 2;
    }
    
    .chat-main {
        order: 1;
        height: 60vh;
    }
    
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .setup-steps .step {
        flex-direction: column;
        text-align: center;
    }
}

/* Markdown content styling */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin: 1rem 0 0.5rem 0;
    color: #2c5aa0;
    font-weight: 600;
}

.message-text h1 { font-size: 1.5rem; }
.message-text h2 { font-size: 1.3rem; }
.message-text h3 { font-size: 1.1rem; }

.message-text p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.message-text code {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    padding: 0.125rem 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    color: #e83e8c;
}

.message-text pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

.message-text pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.message-text ul,
.message-text ol {
    margin: 0.5rem 0;
    padding-left: 2rem;
}

.message-text li {
    margin: 0.25rem 0;
    line-height: 1.5;
}

.message-text blockquote {
    border-left: 4px solid #2c5aa0;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #6c757d;
    font-style: italic;
}

.message-text a {
    color: #2c5aa0;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.message-text th,
.message-text td {
    border: 1px solid #dee2e6;
    padding: 0.5rem;
    text-align: left;
}

.message-text th {
    background: #f8f9fa;
    font-weight: 600;
}

.message-text strong {
    font-weight: 600;
    color: #333;
}

.message-text em {
    font-style: italic;
    color: #495057;
}

/* About page styling */
.about-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
}

.about-page h1 {
    color: #2c5aa0;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.about-section {
    margin-bottom: 3rem;
}

.about-section h2 {
    color: #2c5aa0;
    font-size: 1.8rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}

.about-section h3 {
    color: #333;
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.about-section p {
    margin-bottom: 1.5rem;
    line-height: 1.7;
    color: #333;
}

.about-section ul {
    margin: 1.5rem 0;
    padding-left: 1.5rem;
}

.about-section li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.team-member {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #2c5aa0;
}

.team-member h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #2c5aa0;
}

.team-member p:last-child {
    margin-bottom: 0;
}

.about-section a {
    color: #2c5aa0;
    text-decoration: none;
}


.about-section a:hover {
    text-decoration: underline;
}