/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-black: #000000;
    --primary-white: #ffffff;
    --gray-100: #f5f5f5;
    --gray-200: #e5e5e5;
    --gray-300: #d4d4d4;
    --gray-400: #a3a3a3;
    --gray-600: #525252;
    --gray-800: #262626;
    --success-green: #22c55e;
    --error-red: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e5e5e5 100%);
    color: var(--primary-black);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: 90px;
}

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

/* Header */
.header {
    background: var(--primary-white);
    padding: 20px 0;
    box-shadow: var(--shadow-md);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    border-bottom: 1px solid var(--gray-200);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.brand-name {
    color: var(--primary-black);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Main Container */
.main-container {
    padding: 30px 0 20px 0;
}

.chat-wrapper {
    background: var(--primary-white);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Chat Messages */
.chat-messages {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
    max-height: 60vh;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-content {
    padding: 16px 20px;
    border-radius: 16px;
    max-width: 85%;
    word-wrap: break-word;
}

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

.message.user .message-content {
    background: var(--primary-black);
    color: var(--primary-white);
    border-bottom-right-radius: 4px;
}

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

.message.assistant .message-content {
    background: var(--gray-100);
    color: var(--primary-black);
    border-bottom-left-radius: 4px;
}

/* Plan Display */
.plan-display {
    background: var(--primary-white);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
}

.plan-display h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--primary-black);
    border-bottom: 3px solid var(--primary-black);
    padding-bottom: 8px;
}

.plan-display h3 {
    font-size: 20px;
    margin: 20px 0 12px 0;
    color: var(--gray-800);
}

.plan-display h4 {
    font-size: 16px;
    margin: 16px 0 8px 0;
    color: var(--gray-600);
    font-weight: 600;
}

.plan-display p {
    margin-bottom: 12px;
    line-height: 1.7;
}

.plan-display ul, .plan-display ol {
    margin: 12px 0 12px 24px;
}

.plan-display li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.plan-display strong {
    font-weight: 700 !important;
    color: var(--primary-black);
}

.message-content strong {
    font-weight: 700 !important;
    color: var(--primary-black);
}

.exercise-item {
    background: var(--gray-100);
    padding: 16px;
    border-radius: 8px;
    margin: 12px 0;
    border-left: 4px solid var(--primary-black);
}

.exercise-item strong {
    display: block;
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--primary-black);
}

.exercise-details {
    color: var(--gray-600);
    font-size: 14px;
    margin-top: 8px;
}

.meal-item {
    background: var(--gray-100);
    padding: 16px;
    border-radius: 8px;
    margin: 12px 0;
    border-left: 4px solid var(--primary-black);
}

.meal-item strong {
    display: block;
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--primary-black);
}

.nutrition-info {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 14px;
    color: var(--gray-600);
}

/* Plan Actions */
.plan-actions {
    padding: 20px 30px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.primary-btn {
    background: var(--primary-black);
    color: var(--primary-white);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.prominent-btn {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: var(--primary-white);
    font-size: 17px;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
    animation: pulse 2s ease-in-out infinite;
}

.prominent-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
    }
    50% {
        box-shadow: 0 6px 16px rgba(34, 197, 94, 0.5);
    }
}

.physio-btn {
    background: var(--error-red);
    color: var(--primary-white);
}

.physio-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.secondary-btn {
    background: var(--primary-white);
    color: var(--primary-black);
    border: 2px solid var(--primary-black);
}

.secondary-btn:hover {
    background: var(--primary-black);
    color: var(--primary-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.action-btn:active {
    transform: translateY(0);
}

/* Input Area */
.input-area {
    padding: 20px 30px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    background: var(--primary-white);
}

#userInput {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
}

#userInput:focus {
    border-color: var(--primary-black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.send-btn {
    background: var(--primary-black);
    color: var(--primary-white);
    border: none;
    border-radius: 12px;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Loading Indicator */
.loading-indicator {
    padding: 20px;
    display: flex;
    justify-content: flex-start;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: var(--gray-100);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: typing 1.4s infinite;
}

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Plan Generation Animation */
.plan-generation-loading {
    display: flex;
    justify-content: flex-start;
}

.plan-generation-animation {
    background: var(--gray-100);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 280px;
}

.workout-animation {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60px;
}

.dumbbell {
    display: flex;
    align-items: center;
    animation: dumbbellCurl 1.5s ease-in-out infinite;
}

.dumbbell-left,
.dumbbell-right {
    width: 20px;
    height: 20px;
    background: var(--primary-black);
    border-radius: 4px;
    position: relative;
}

.dumbbell-left::before,
.dumbbell-right::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: var(--gray-600);
    border-radius: 3px;
}

.dumbbell-left::before {
    left: -14px;
}

.dumbbell-right::before {
    right: -14px;
}

.dumbbell-bar {
    width: 40px;
    height: 8px;
    background: var(--gray-600);
    margin: 0 2px;
    border-radius: 4px;
}

@keyframes dumbbellCurl {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(-5deg);
    }
    50% {
        transform: translateY(-20px) rotate(-10deg);
    }
    75% {
        transform: translateY(-15px) rotate(-5deg);
    }
}

.generation-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-black);
    text-align: center;
    line-height: 1.4;
}

.progress-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.progress-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: dotPulse 1.4s infinite;
}

.progress-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.progress-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--primary-white);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--primary-black);
}

.modal-close:hover {
    background: var(--gray-200);
    transform: rotate(90deg);
}

#modalBody {
    padding: 40px;
}

/* Form Styles */
.form-container {
    padding: 20px 0;
}

.form-container h2 {
    font-size: 28px;
    margin-bottom: 24px;
    color: var(--primary-black);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--gray-800);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary-black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-black);
    color: var(--primary-white);
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 24px;
}

.form-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.form-submit-btn:active {
    transform: translateY(0);
}

.form-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.success-message {
    background: var(--success-green);
    color: var(--primary-white);
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.error-message {
    background: var(--error-red);
    color: var(--primary-white);
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        padding-top: 80px;
    }

    .brand-name {
        font-size: 22px;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .main-container {
        padding: 0;
        height: calc(100vh - 80px);
        height: calc(100dvh - 80px);
    }

    .chat-wrapper {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    .chat-messages {
        padding: 20px;
        max-height: none;
        flex: 1;
        overflow-y: auto;
        padding-bottom: 200px;
    }

    .message-content {
        max-width: 90%;
        padding: 12px 16px;
    }

    .plan-actions {
        flex-direction: column;
        position: fixed;
        bottom: 70px;
        left: 0;
        right: 0;
        background: var(--primary-white);
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        padding: 8px 15px;
        gap: 8px;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
        font-size: 14px;
        padding: 10px 16px;
        white-space: normal;
        text-align: center;
        line-height: 1.3;
    }

    .prominent-btn {
        font-size: 15px;
    }

    .input-area {
        padding: 12px 15px;
        flex-shrink: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 101;
        background: var(--primary-white);
    }

    #userInput {
        font-size: 16px;
        padding: 12px 16px;
    }

    .send-btn {
        padding: 12px 16px;
    }

    #modalBody {
        padding: 30px 20px;
    }

    .form-container h2 {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .chat-wrapper {
        border-radius: 12px;
    }

    .brand-name {
        font-size: 18px;
    }

    .logo {
        width: 35px;
        height: 35px;
    }
}

/* Option Buttons */
.option-buttons-wrapper {
    background: transparent !important;
    padding: 0 !important;
    max-width: 100% !important;
}

.option-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
}

.option-btn {
    padding: 16px 20px;
    background: var(--primary-white);
    color: var(--primary-black);
    border: 2px solid var(--primary-black);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: var(--shadow-sm);
    width: 100%;
}

.option-btn:hover:not(:disabled) {
    background: var(--primary-black);
    color: var(--primary-white);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-btn:active:not(:disabled) {
    transform: translateY(0);
}

.option-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .option-btn {
        padding: 14px 18px;
        font-size: 15px;
    }
}

/* YouTube Exercise Links */
.youtube-link {
    margin: 8px 0 12px 0;
    padding: 8px 12px;
    background: var(--gray-100);
    border-radius: 6px;
    display: inline-block;
}

.youtube-link a {
    color: var(--primary-black);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.youtube-link a:hover {
    color: #FF0000;
    transform: translateX(3px);
}

.youtube-link svg {
    flex-shrink: 0;
}

/* Print Styles for PDF */
@media print {
    body {
        background: white;
    }

    .header,
    .input-area,
    .plan-actions {
        display: none;
    }

    .chat-messages {
        max-height: none;
    }

    .message.user {
        display: none;
    }

    .exercise-diagram {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
