:root {
    --primary-color: #f7941d;
    --primary-color-dark: #d15503;
    --primary-color-light:rgb(252, 223, 205);
    --secondary-color: #455a64;
    --secondary-color-dark: #37474f;
    --secondary-color-light:rgb(221, 238, 247);
    --error-color: #d32f2f;
    --success-color: #2e7d32;

    --text-color: #24292e;
    --light-bg: #f5f5f5;

    --border-color: #e1e4e8;
    --border-radius-sm: 0.24rem;
    --border-radius-md: 0.5rem;
    --border-radius-lg: 1rem;
    --content-inner-padding: 1.2rem;

    --base-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --transition: 0.2s ease-out;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Open Sans', sans-serif;
    color: var(--text-color);
    background-color: var(--light-bg);
}
/* Header */

.header {
    background-color: var(--secondary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--base-shadow);
    position: relative;
    width: 100%;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hamburger-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);;
    cursor: pointer;
    z-index: 1001;
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 2px;
    background-color: #fff;
    transition: all 0.3s ease;
}

.hamburger-menu:hover, 
.hamburger-menu.active {
    background-color: rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }
}

/* Overlay Menu */

.menu-wrapper {
    position: relative;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    display: none;
    width: 280px;
    padding: 8px 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.menu-dropdown.active {
    display: block;
}

.menu-section {
    padding: 0.5rem 0;
}

.menu-section + .menu-section {
    border-top: 1px solid #eee;
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.menu-section h3 {
    padding: 8px 16px;
    color: #666;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
}

.menu-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-section li {
    margin: 0;
    padding: 0;
}

.menu-section a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
}

.menu-section a:hover {
    background-color: #f5f5f5;
}

.menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

.menu-logout {
    margin-top: auto;  /* Push to bottom of dropdown */
}

.user-email {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-secondary);
    opacity: 0.8;
}

.menu-logout .menu-icon {
    font-size: 1.1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
}

.user-info #userEmail {
    font-size: .8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#userEmail {
    color: #666;
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: #c82333;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #666;
    transition: all 0.3s ease;
    flex-shrink: 0;
    cursor: help;
}

.health-dot.healthy {
    background-color: #2ecc71;
    box-shadow: 0 0 4px rgba(46, 204, 113, 0.5);
}

.health-dot.unhealthy {
    background-color: #e74c3c;
    box-shadow: 0 0 4px rgba(231, 76, 60, 0.5);
}

/* Layout */

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

#loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-size: 1.2rem;
    color: #666;
}

#main-content {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
}

/* Form */

.form-wrapper {
    background: white;
    border-radius: var(--border-radius-md);
    box-shadow: var(--base-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

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

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.half {
    flex: 1;
    min-width: 0;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--secondary-color);
}

label[required]::after {
    content: " *";
    color: var(--error-color);
}

select, input, textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 1rem;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(247, 148, 29, 0.2);
}

select {
    height: 38px;
    padding: 0.375rem 0.75rem;
    font-size: 0.9rem;
}

textarea {
    width: 100%;
    min-height: 350px;
    padding: var(--content-inner-padding);
    resize: vertical;
}

/* Placeholder styling */
::placeholder {
    color: #999;
    opacity: 1;
}

/* Selection styling */
::selection {
    background-color: var(--primary-color);
    color: white;
}

.selection-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.brand-lang-wrapper {
    flex:1;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.brand-select {
    flex: 1;
}

.language-select {
    width: 120px; /* Fixed width */
}

.template-select {
    flex: 1;
}

.url-input-wrapper {
    display: flex;
    gap: 1rem;
}

.url-input-wrapper input {
    flex: 1;
}

.invalid-url {
    border-color: #ff4444;
    background-color: #fff0f0;
}

.valid-url {
    border-color: #44aa44;
    background-color: #f0fff0;
}

textarea#rewriteInstructions {
    min-height: 80px;
}

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .form-wrapper, 
    .chat-container {
        padding: 1.5rem;
    }

    .selection-group {
        flex-direction: column;
    }
}

/* Shared */

.button {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 50px;
    padding: 0.5rem 1rem;
    border: none;
    background-color: #000;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    color: #fff;
    font-weight: 600;
    transition: var(--transition);
    transition-property: background-color;
    cursor: pointer;
}

.button i {
    font-size: 0.9em;
}

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

.button--primary {
    background-color: var(--primary-color);
}

.button--primary:hover {
    background-color: var(--primary-color-dark);
}

.button--secondary {
    background-color: var(--secondary-color);
}

.button--secondary:hover {
    background-color: var(--secondary-color-dark);
}

.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    border-bottom-color: transparent;
    border-radius: 50%;
    color: #fff;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.generated-text-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-bg);
    padding: var(--content-inner-padding);
    border-radius: var(--border-radius-md);
    max-height: 60vh;
    overflow-y: auto;
}

.generated-text-content pre {
    margin: 0;
}

.error {
    border-color: var(--error-color);
}

.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.success {
    border-color: var(--success-color);
}

.success-message {
    color: var(--success-color);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

[data-tooltip] {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    margin-left: 4px;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background: var(--secondary-color);
    color: white;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
}

/* Scrap section */

.action-links {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin: 0.5rem 0;
}

.text-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
}

.text-link:not(:last-child):after {
    content: '|';
    display: inline-block; /* for text-decoration to be effective */
    margin-left: 1.2rem;
    color:  var(--border-color);
    text-decoration: none;
}

.preview-content {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    padding: 1.5rem;
    margin-top: 1rem;
    width: 60%;
    max-width: 800px;
    max-height: 70vh;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow-y: auto;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}


/* Output section */

.output-section {
    display: none;
    transition: all 0.3s ease-in-out;
    scroll-margin-top: 2rem;
}

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

.output-controls {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#output {
    min-height: 225px;
}

.warning-message.inline {
    display: block;
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius-sm);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Chat */

.chat-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: 400px;
    margin-top: 24px;
    isolation: isolate;
}

.chat-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1rem;
}

.tab-list {
    display: flex;
    gap: 0.25rem;
    margin-bottom: -1px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.tab-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.chat-tab {
    height: 35px;
    padding: 0.3rem 1rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
}

.chat-tab.active {
    position: relative;
    height: 40px;
    padding: 0.5rem 1rem;
    background: #fff;
    color: var(--text-color);
    border-color: var(--border-color);
    border-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    z-index: 1;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 16px;
    height: auto;
    min-height: 300px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: white;
}

.chat-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: auto;
    min-height: 200px;
}

.chat-input-wrapper {
    display: flex;
    gap: 0;
    align-items: stretch; /* Ensure children stretch to same height */
}

.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--border-radius-sm) 0 0 4px;
    font-size: 14px;
    resize: none;
    height: 36px; /* Fixed height */
    min-height: 36px;
    max-height: 36px;
}

.chat-history-row {
    background-color: #f9f9f9;
}

.chat-history-content {
    padding: 15px;
    background: #f8f9fa;
    margin: 10px 0;
    border-radius: var(--border-radius-sm);
}

.chat-history-content h4 {
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}

.chat-history-content pre {
    background-color: #f4f4f4;
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
}

.new-chat-btn {
    padding: 0.5rem;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    background: var(--secondary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.new-chat-btn:hover {
    background: #37474f;
}


.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: auto;
    min-height: 100px;
    padding: var(--content-inner-padding);
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius-md);
    overflow-y: auto;
}

.chat-message {
    max-width: 80%;
    margin: 5px 0;
    padding: 10px;
    border-radius: var(--border-radius-lg);
    border-bottom: 1px solid #e9ecef;
    word-wrap: break-word;

}

.chat-message:last-child {
    border-bottom: none;
}

.chat-message .message-header {
    font-weight: bold;
    margin-bottom: 4px;
    color: #495057;
}

.user-message {
    background-color: var(--primary-color-light);
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}

.ai-message {
    background-color: var(--secondary-color-light);
    margin-right: auto;
    border-bottom-left-radius: 0.25rem;
}

.assistant-message {
    background: var(--secondary-color-light);
    margin-right: 20px;
}

.message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.no-chat-messages {
    padding: 12px;
    color: #6c757d;
    font-style: italic;
    text-align: center;
}

.send-btn {
    flex-shrink: 0;
    height: 36px;
    width: 36px;
    padding: 0;
    border: 1px solid var(--primary-color);
    border-radius: 0 4px 4px 0;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn i {
    font-size: 14px;
    transform: rotate(45deg);
}

.send-btn:disabled {
    background: var(--border-color);
    border-color: var(--border-color);
    cursor: not-allowed;
}

/* Modal */

.modal {
    position: fixed;
    left: 0;
    top: 0;
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    z-index: 1000;
}

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

.modal-close-button {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    transition: var(--transition);
    transition-property: color;
    background: var(--secondary-color);
    border-radius: 50%;
}


.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    padding: 2rem;
    background-color: #fefefe;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    /* overflow-y: auto; */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

/* Auth modal */

.auth-modal {
    max-width: 400px;
    text-align: center;
}

.auth-modal h2 {
    margin-bottom: 1rem;
    color: #333;
}

.auth-modal p {
    margin-bottom: 2rem;
    color: #666;
}

#googleSignIn {
    display: flex;
    justify-content: center;
    margin: 0 auto;
}

/* Microsoft Sign-In Button */
.ms-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #FFFFFF;
    color: #5E5E5E;
    border: 1px solid #8C8C8C;
    border-radius: 4px;
    padding: 12px 24px;
    font-family: 'Segoe UI', 'Open Sans', sans-serif;
    font-size: 15px;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ms-button:hover {
    background-color: #F5F5F5;
    border-color: #8C8C8C;
}

.ms-button:active {
    background-color: #EBEBEB;
    border-color: #767676;
}

.ms-button i {
    font-size: 18px;
    color: #5E5E5E;
}