:root {
    /* Color Palette */
    --col-dark-blue: rgb(29, 79, 145);
    --col-light-green: rgb(197, 232, 108);
    --col-teal: rgb(66, 152, 181);
    --col-gray: rgb(190, 198, 196);
    
    --col-bg: #f4f4f4;
    --col-white: #ffffff;
    --col-text: #333333;
    
    /* Font */
    --font-main: 'Montserrat', sans-serif;
}

body {
    font-family: var(--font-main);
    margin: 0;
    padding: 20px;
    background-color: var(--col-bg);
    color: var(--col-text);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#app {
    display: flex;
    flex-direction: column; 
    width: 100%;
    max-width: 1200px;
    background-color: var(--col-white);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    min-height: 85vh; 
    position: relative;
}

/* --- Header & User Status --- */

.user-status {
    position: absolute;
    top: 20px;
    right: 20px; /* Moved to right */
    left: auto;  /* Reset left */
    font-size: 0.9rem;
    color: var(--col-dark-blue);
    background-color: rgba(66, 152, 181, 0.1); /* Light Teal background */
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
}

.logout-link {
    color: var(--col-teal);
    text-decoration: none;
    font-weight: 600;
}

.logout-link:hover {
    text-decoration: underline;
}

.app-header {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--col-gray);
    margin-bottom: 25px;
}

.app-header img {
    height: 60px; 
    vertical-align: middle;
}

/* --- Layout --- */

.app-body {
    display: flex;
    gap: 30px;
    flex-grow: 1; 
}

.main-content {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar {
    flex: 2;
    border-left: 1px solid var(--col-gray);
    padding-left: 25px;
}

/* --- Typography --- */

h3, h4 {
    color: var(--col-dark-blue);
    margin-bottom: 15px;
    font-weight: 600;
}

/* --- Forms & Inputs --- */

.heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group-row {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.select-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--col-dark-blue);
    font-size: 0.9rem;
}

select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--col-gray);
    font-family: var(--font-main);
    background-color: #fafafa;
}

.textarea-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

textarea.adaptive-textarea {
    width: 100%;
    min-height: 80px; /* Start smaller, grow with content */
    padding: 12px;
    border: 1px solid var(--col-gray);
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 1rem;
    line-height: 1.5;
    resize: none; /* User cannot resize manually */
    overflow-y: hidden; /* Hide scrollbar for adaptive effect */
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--col-teal);
    box-shadow: 0 0 0 3px rgba(66, 152, 181, 0.1);
}

.output-display {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 1px solid var(--col-gray);
    border-radius: 6px;
    background-color: #fafafa;
    white-space: pre-wrap; 
    font-size: 1rem;
    line-height: 1.6;
}

/* --- Buttons --- */

button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
}

button:active {
    transform: translateY(1px);
}

.btn-primary {
    background-color: var(--col-dark-blue);
    color: white;
}

.btn-primary:hover {
    background-color: #153c70; /* Slightly darker */
}

.btn-secondary {
    background-color: var(--col-teal);
    color: white;
}

.btn-secondary:hover {
    background-color: #337d96;
}

.btn-clear {
    background-color: transparent;
    color: #c62828; /* Red text for warning action */
    border: 1px solid #c62828;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-clear:hover {
    background-color: #ffebee;
}

button:disabled {
    background-color: var(--col-gray);
    cursor: not-allowed;
    color: #666;
    border: none;
}

/* --- Error Highlights --- */

.error-highlight {
    background-color: var(--col-light-green); /* Using the brand green for highlight base */
    border-bottom: 2px solid #e65100; /* Orange/Red underline for visibility */
    cursor: pointer;
    border-radius: 2px;
    padding: 0 2px;
}

.error-highlight.correction-applied {
    cursor: default;
    background-color: transparent;
    border-bottom: none;
}

.error-highlight.correction-applied .corrected-text-segment {
    font-weight: 600;
    color: #2e7d32;
    background-color: #e8f5e9;
    padding: 0 4px;
    border-radius: 4px;
}

.active-hover-text, .active-hover-list-item {
    background-color: var(--col-light-green) !important;
    outline: 2px solid var(--col-teal);
}

/* --- Sidebar Items --- */

.sidebar details {
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--col-teal);
    border-radius: 6px;
    background-color: rgba(66, 152, 181, 0.05);
    font-size: 0.9rem;
}

.sidebar summary {
    font-weight: 700;
    color: var(--col-teal);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
}

.error-list-item {
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--col-gray);
    border-radius: 6px;
    background-color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.error-list-item h4 {
    color: #d32f2f;
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.sidebar-button {
    margin-top: 10px;
    padding: 6px 12px;
    font-size: 0.8rem;
    width: 100%;
}

.btn-success { background-color: #2e7d32; color: white; }
.btn-warning { background-color: #f57c00; color: white; }

.status-applied {
    color: #2e7d32; 
    font-weight: bold; 
    margin-top: 8px;
    font-size: 0.85rem;
}

.api-error-message { color: #d32f2f; margin-top: 10px; }
.loading-message { margin-top: 10px; color: var(--col-teal); font-weight: bold;}
.feedback-log { margin-top: 20px; font-size: 0.8em; color: #666; }

/* --- Footer & Credits --- */

.app-footer {
    width: 100%;
    max-width: 1200px; 
    margin-top: 15px;
    padding: 0 10px 20px 10px;
    
    display: flex;
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap; 
    
    font-size: 0.75rem; 
    color: var(--col-dark-blue); 
    opacity: 0.7; 
}

.app-footer strong {
    font-weight: 600;
    color: var(--col-teal); 
}

@media (max-width: 768px) {
    .app-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}