/* Base responsive settings */
:root {
    --max-width: 800px;  /* Changed to approximate A4 width */
    --content-padding: 1rem;
    --font-size-base: 16px;
    --line-height-base: 1.5;
    
    /* Colors */
    --text-color: #F0E6E3;
    --background-color: #062F4F;
    --link-color: #882601;
    --link-hover-color: #003366;
    --border-color: #ddd;
    
    /* Spacing */
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
}

/* Base styles */
html {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;  /* Ensure full height */
    box-sizing: border-box;  /* Include padding in width calculations */
}

/* Layout */
header {
    padding: var(--content-padding);
    max-width: var(--max-width);
    margin: 0 auto;
    box-sizing: border-box;
}

main {
    padding: 0 var(--content-padding);  /* Remove vertical padding, keep horizontal */
    max-width: var(--max-width);
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
    overflow: visible;  /* Allow bubbles to extend outside if needed */
}

/* Clear all floats at the end of main */
main::after {
    content: "";
    display: table;
    clear: both;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    line-height: 1.0;
}

/* Specific h1 adjustments */
h1 {
    font-size: 2.5rem;
    margin-top: 1rem;    /* Halved from 2rem */
    margin-bottom: 0;    /* Removed bottom margin completely */
}
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

/* Markdown content styles */
p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

/* Lists */
ul, ol {
    margin: var(--spacing-md) 0;
    padding-left: var(--spacing-lg);
}

li {
    margin-bottom: var(--spacing-sm);
}

/* Blockquotes */
blockquote {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-md) var(--spacing-lg);
    border-left: 4px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.02);
}

/* Code blocks */
pre, code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

pre {
    padding: var(--spacing-md);
    overflow-x: auto;
}

code {
    padding: 0.2em 0.4em;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
}

th, td {
    padding: var(--spacing-sm);
    border: 1px solid var(--border-color);
}

th {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Horizontal rule */
hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: var(--spacing-lg) 0;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
}

/* Common bubble styles */
.bubble {
    position: relative;
    border-radius: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin: 2rem 0;
}

.bubble p {
    margin: 0;
    line-height: 1.6;
}

.bubble p + p {
    margin-top: 1rem;
}

/* Base chat bubble styles */
.chat-bubble-left,
.chat-bubble-right {
    position: relative;
    border-radius: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin: 1rem 0;  /* Halved from 2rem to 1rem */
    max-width: 80%;
    box-sizing: border-box;
}

/* Reduce space between h3 and content in bubbles */
.chat-bubble-left h3,
.chat-bubble-right h3 {
    margin-top: 0;
    margin-bottom: 1rem;  /* Halved from the default 2rem */
}

/* Left bubble specific */
.chat-bubble-left {
    float: left;
    margin-right: 15%;
    border-bottom-left-radius: 0.25rem;
}

/* Right bubble specific */
.chat-bubble-right {
    float: right;
    margin-left: 15%;
    border-bottom-right-radius: 0.25rem;
}

/* Common paragraph styles for chat bubbles */
.chat-bubble-left p,
.chat-bubble-right p {
    margin: 0;
    line-height: 1.6;
}

/* Add space between paragraphs within the same bubble */
.chat-bubble-left p + p,
.chat-bubble-right p + p {
    margin-top: 1rem;
}

/* Footer bubble style */
.footer-bubble {
    position: relative;
    border-radius: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    background-color: #6c757d;
    color: #F0E6E3;
    box-sizing: border-box;
    clear: both;
    width: 100%;
    margin: 2rem 0;
}

.footer-bubble p {
    margin: 0;
    line-height: 1.6;
    max-width: var(--max-width);
    margin-left: auto;
    margin-right: auto;
}

/* Navigation bubbles */
.nav-bubbles {
    padding: 1rem;
    text-align: center;
    background: #3D2C3C;
}

.nav-bubble {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin: 0.25rem;
    background-color: #A3C1AD;
    color: #882601;
    text-decoration: none;
    border-radius: 2rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nav-bubble:hover {
    background-color: #5C8192;
    text-decoration: none;
}

.nav-bubble-active {
    background-color: #7A361F;
    color: white;
}

.nav-bubble-active:hover {
    background-color: #5C8192;
    color: white;
}

/* Single bubble layout style */
.content-bubble {
    position: relative;
    border-radius: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin: 1rem 0;
    background-color: #3D2C3C;
    color: #F0E6E3;
    box-sizing: border-box;
    width: 100%;
}

.content-bubble h1 {
    margin-top: 0;
    margin-bottom: 0.5rem;  /* Half line space below h1 */
}

.content-bubble p {
    margin: 0;
    line-height: 1.6;
}

.content-bubble p + p {
    margin-top: 1rem;
}

/* Contact form styles */
.content-bubble textarea:not(.g-recaptcha-response) {
    width: calc(100% - 4rem) !important;
    margin: 1rem 2rem;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    min-height: 22.5em;  /* Approximately 15 lines */
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    box-sizing: border-box;
    resize: vertical;  /* Allow only vertical resizing */
    background-color:#EBD5BC
}

/* Ensure reCAPTCHA hidden textarea stays hidden and takes no space */
textarea.g-recaptcha-response,
.content-bubble textarea.g-recaptcha-response,
textarea[name="g-recaptcha-response"] {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    min-height: 0 !important;
    height: 0 !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
}

/* Style the reCAPTCHA container div */
.content-bubble .g-recaptcha {
    margin: 1rem 2rem !important;
    min-height: 0 !important;
}

/* Override any inherited styles on reCAPTCHA iframe and div */
.content-bubble .g-recaptcha > div {
    min-height: 0 !important;
}

.content-bubble button {
    display: block;
    margin: 1rem 2rem;
    padding: 0.5rem 2rem;
    border-radius: 0.5rem;
    border: none;
    background-color: #B3BFB5;
    color: #F0E6E3;
    cursor: pointer;
}

.content-bubble form button[type="submit"]:hover {
    background-color: #5C8192;
}


/* chatgpt's bubble style */
.chatgpt-bubble {
    background-color: #4A7C94;
    color: #F0E6E3;
}

/* my's bubble style */
.my-bubble {
    background-color: #766771;
    color: #F0E6E3;
}


/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .chat-bubble-left,
    .chat-bubble-right {
        max-width: 90%;
        padding: 1rem;
        margin: 0.5rem 0;  /* Halved from 1rem to 0.5rem */
    }

    .chat-bubble-left {
        margin-right: 5%;
    }

    .chat-bubble-right {
        margin-left: 5%;
    }

    .footer-bubble {
        padding: 1rem;
        margin: 1rem 0;
    }

    .nav-bubbles {
        padding: 0.5rem;
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-bubble {
        padding: 0.25rem 0.75rem;
    }

    .content-bubble {
        padding: 1rem;
        margin: 0.5rem 0;
    }
}

/* Print styles */
@media print {
    body {
        color: #000;
        background: #fff;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
}