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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececf1;
    --text-primary: #353740;
    --text-secondary: #6e6e80;
    --border-color: #e5e5e6;
    --accent: #10a37f;
    --accent-hover: #0d8c6f;
    --error: #ef4444;
    --priority-p1: #ef4444;
    --priority-p2: #f59e0b;
    --priority-p3: #3b82f6;
    --priority-p4: #6b7280;
    --priority-p5: #9ca3af;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-primary);
}

/* Header */
.app-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.header-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ui-version {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Messages */
.message {
    display: flex;
    gap: 1rem;
    max-width: 100%;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    word-wrap: break-word;
    line-height: 1.7;
}

.message.user .message-content {
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.message-content p {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

/* Daily Grid View styling */
.daily-grid-view {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

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

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

.priority-header {
    font-weight: 700;
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.priority-header.p1 {
    color: var(--priority-p1);
    border-bottom-color: var(--priority-p1);
}

.priority-header.p2 {
    color: var(--priority-p2);
    border-bottom-color: var(--priority-p2);
}

.priority-header.p3 {
    color: var(--priority-p3);
    border-bottom-color: var(--priority-p3);
}

.priority-header.p4 {
    color: var(--priority-p4);
    border-bottom-color: var(--priority-p4);
}

.priority-header.p5 {
    color: var(--priority-p5);
    border-bottom-color: var(--priority-p5);
}

.task-list {
    list-style: none;
    padding: 0;
}

.task-item {
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
    line-height: 1.6;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.task-item strong {
    font-weight: 600;
    color: var(--text-primary);
}

.task-item-empty {
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
    line-height: 1.6;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Completion confirmation */
.completion-confirmation {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 0.5rem;
}

.completion-confirmation h3 {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.completion-confirmation ul {
    list-style: none;
    padding-left: 0;
}

.completion-confirmation li {
    padding: 0.25rem 0;
    color: var(--text-primary);
}

/* Input container */
.input-container {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.user-input {
    flex: 1;
    padding: 0.875rem 1.125rem;
    border: 1.5px solid var(--border-color);
    border-radius: 0.625rem;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    max-height: 200px;
    min-height: 48px;
    line-height: 1.6;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.user-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(16, 163, 127, 0.12);
}

.user-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.send-button {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: 0.625rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s, transform 0.1s;
}

.send-button:active:not(:disabled) {
    transform: scale(0.96);
}

.send-button:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading indicator */
.loading {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: loading-bounce 1.4s infinite ease-in-out;
}

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

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

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

/* Error messages */
.error-message {
    padding: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    color: var(--error);
    margin-top: 1rem;
}

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

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Empty state improvements */
.messages:empty::before {
    content: '';
}

/* Better spacing for first/last messages */
.messages > .message:first-child {
    margin-top: 0;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .app-header {
        padding: 1rem;
    }
    
    .app-header h1 {
        font-size: 1.25rem;
    }
    
    .messages {
        padding: 1.5rem 1rem;
        gap: 1.5rem;
    }
    
    .message-content {
        max-width: 92%;
        padding: 0.875rem 1rem;
    }
    
    .input-container {
        padding: 1rem;
    }
    
    .task-item {
        padding: 0.875rem;
    }
    
    .priority-section {
        margin-bottom: 1.5rem;
    }
}
