/* Unlimits Coach - Minimalist Apple-Inspired Chat UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --user-bubble: #007AFF;
    --ai-bubble: #E5E5EA;
    --user-text: #FFFFFF;
    --ai-text: #1D1D1F;
    --border: rgba(0, 0, 0, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius: 18px;
    --radius-sm: 12px;
    --spacing: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-md);
}

/* Header */
.app-header {
    padding: 24px var(--spacing);
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.app-header .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing);
    padding-bottom: calc(var(--spacing) + 80px);
    background: var(--bg-primary);
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Welcome Message */
.welcome-message {
    margin-top: 20px;
}

/* Messages */
.message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    justify-content: flex-end;
}

.message.ai-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--radius);
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
}

.user-message .message-content {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: var(--ai-bubble);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0;
    font-size: 15px;
    line-height: 1.4;
}

.message-content p:not(:last-child) {
    margin-bottom: 8px;
}

.message-content strong {
    font-weight: 600;
}

/* Nudge Section */
.nudge-section {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(0, 122, 255, 0.1);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--user-bubble);
}

.nudge-section strong {
    font-size: 16px;
    color: var(--user-bubble);
}

/* Visualization Section */
.visualization-section {
    margin-top: 16px;
}

.visualization-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.phases {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.phase {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
}

.phase strong {
    color: var(--user-bubble);
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.viz-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    font-style: italic;
}

/* Loading Message */
.loading-message .message-content {
    opacity: 0.7;
}

.loading-message .message-content::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Error Message */
.error-message .message-content {
    background: #FF3B30;
    color: white;
}

/* Input Container */
.input-container {
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: var(--spacing);
    z-index: 10;
}

.chat-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    transition: all 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--user-bubble);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.message-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--user-bubble);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.send-button:hover:not(:disabled) {
    background: #0051D5;
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button svg {
    width: 20px;
    height: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
    }

    .app-header {
        padding: 20px var(--spacing);
    }

    .app-header h1 {
        font-size: 24px;
    }

    .message-content {
        max-width: 85%;
    }

    .input-container {
        padding: 12px;
    }

    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 22px;
    }

    .message-content {
        max-width: 90%;
        padding: 10px 14px;
    }

    .message-content p {
        font-size: 14px;
    }
}

/* Safe area for mobile devices */
@supports (padding: max(0px)) {
    .input-container {
        padding-bottom: max(var(--spacing), env(safe-area-inset-bottom));
    }
}
