/* ============================================
   GLOBAL STYLES & VARIABLES
   ============================================ */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --bg-tertiary: #f0f0f0;
    --text-primary: #222222;
    --text-secondary: #555555;
    --text-tertiary: #888888;
    --border-color: #e0e0e0;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-success: #4CAF50;
    --accent-error: #c62828;
    /* FIX 2: New star color */
    --star-color: #ffc107; 
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --shadow-heavy: rgba(0, 0, 0, 0.15);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* --- Dark Mode Variables --- */
body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #252525;
    --bg-tertiary: #333333;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --border-color: #404040;
    --accent-primary: #7c8ff0;
    --accent-secondary: #8a5bb8;
    /* FIX 2: Star color in dark mode */
    --star-color: #ffc107;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --shadow-heavy: rgba(0, 0, 0, 0.3);
}

/* --- Global Reset & Base Styling --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
        Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top for scroll */
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Main Container --- */
.container {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 10px 40px var(--shadow-medium);
    border: 1px solid var(--border-color);
    max-width: 1100px;
    width: 100%;
    padding: 30px 40px;
    animation: slideIn 0.5s ease-out;
    transition: background-color 0.3s ease;
    margin-bottom: 50px; /* Space for footer */
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Header & Branding --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap; /* Allow controls to wrap on small screens */
}

.header-content {
    text-align: left;
    flex: 1;
    min-width: 250px; /* Ensure content doesn't get too squished */
}

.header-content .main-title {
    font-size: 2.5em;
    color: var(--text-primary);
    margin-bottom: 5px; /* Tighter spacing for 3-line header */
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.header-content p {
    color: var(--text-secondary);
    font-size: 1.15em;
    font-weight: 500;
    margin-bottom: 15px;
}

.version-badge {
    /* This is now the "Benefit" badge */
    display: inline-block;
    background: var(--gradient-primary);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9em; /* Slightly larger for benefit */
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 10px; /* Align with title */
}

.header-link {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}
.header-link:hover {
    color: var(--accent-primary);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}
.theme-toggle:hover {
    border-color: var(--accent-primary);
}
.theme-toggle-icon {
    font-size: 1.2em;
}
.theme-toggle-label {
    font-size: 0.9em;
    font-weight: 600;
}

/* --- Tab Navigation --- */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
}
.tab-button {
    padding: 12px 24px;
    border: none;
    background: none;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.tab-button:hover {
    color: var(--accent-primary);
}
.tab-button.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* --- Tab Content & Input Sections --- */
.tab-content { display: none; }
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.input-section { margin-bottom: 30px; }
.input-label {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}
textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: all 0.3s ease;
    color: var(--text-primary);
    background: var(--bg-secondary);
}
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
textarea::placeholder { color: var(--text-tertiary); }
.info-text {
    font-size: 0.9em;
    color: var(--text-tertiary);
    margin-top: 10px;
    text-align: center;
}


/* --- Advanced Mode --- */
.advanced-mode-section {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
}
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.checkbox-container input[type='checkbox'] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}
.checkbox-label {
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}
.advanced-info {
    font-size: 0.85em;
    color: var(--accent-primary);
    margin-top: 8px;
    font-style: italic;
}
.advanced-options {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.4s ease, margin-top 0.4s ease;
    margin-top: 0;
}
.advanced-options.active {
    max-height: 2000px;
    opacity: 1;
    margin-top: 20px;
}
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.option-group {
    display: flex;
    flex-direction: column;
}
.option-label {
    font-size: 0.95em;
    font-weight: 600;
    margin-bottom: 8px;
}
select {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
option {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}
.conditional-group { display: none; }
.conditional-group.visible {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* --- Buttons --- */
.button-container {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}
#image-mode .button-container {
    margin-top: 20px; /* Spacing fix for image tab */
}

#video-mode .button-container,
#productivity-mode .button-container {
    margin-top: 20px; 
}

button {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
.craft-btn {
    background: var(--gradient-primary);
    color: white;
}
.craft-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.craft-btn:active { transform: translateY(0); }
.craft-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.clear-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.clear-btn:hover { background: var(--border-color); }

/* --- Results, Loading, Error --- */
.result-section { display: none; }
.result-section.active {
    display: block;
    animation: fadeIn 0.5s ease-out;
}
.result-label {
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 12px;
}
.result-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    min-height: 150px;
    line-height: 1.8;
    color: var(--text-primary);
    word-wrap: break-word;
    white-space: pre-wrap; /* For text/JSON */
    max-height: 500px;
    overflow-y: auto;
    font-size: 1em;
    font-family: inherit;
    font-weight: 600; /* Default bold for prompts */
}
/* Specific styling for Productivity (RAPTOR) results */
.result-box.productivity-result {
    white-space: normal; /* Override pre-wrap */
    font-weight: 400; /* Use normal weight for base */
}
.result-box.productivity-result .result-line {
    margin-bottom: 16px;
    line-height: 1.6;
}
.result-box.productivity-result .result-line:last-child {
    margin-bottom: 0;
}
.result-box.productivity-result .result-line strong {
    color: var(--accent-primary);
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.result-box.productivity-result .result-line span {
    color: var(--text-primary);
    white-space: pre-wrap; /* Allow line breaks within value */
    font-weight: 600; /* Make the value bold */
}
.result-box.productivity-result .result-line span br {
    line-height: 1.5;
}
/* --- End RAPTOR styling --- */

.copy-btn {
    width: 100%;
    background: var(--accent-success);
    color: white;
}
.copy-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}
.copy-btn:active { transform: translateY(0); }

.copy-feedback {
    display: none;
    color: var(--accent-success);
    font-size: 0.9em;
    margin-top: 8px;
    text-align: center;
    font-weight: 600;
}
.copy-feedback.show {
    display: block;
    animation: fadeInOut 2s ease-out;
}
@keyframes fadeInOut {
    0% { opacity: 0; } 10% { opacity: 1; }
    90% { opacity: 1; } 100% { opacity: 0; }
}

.loading {
    display: none;
    text-align: center;
    margin: 20px 0;
}
.loading.active { display: block; }
.spinner {
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
.loading p {
    color: var(--accent-primary);
    margin-top: 10px;
    font-weight: 600;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    display: none;
    background: rgba(198, 40, 40, 0.1);
    color: var(--accent-error);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent-error);
}
.error-message.show { display: block; }

/* --- Footer --- */
.footer {
    max-width: 1100px;
    width: 100%;
    padding: 20px 40px;
    margin: 0 auto; /* Center footer */
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9em;
}
.footer p { 
    margin-bottom: 10px; 
    line-height: 1.6;
}
.footer a {
    color: var(--text-secondary);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.footer a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}
.footer-legal {
    font-size: 0.9em;
    opacity: 0.8;
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    /* Vertically center the modal */
    align-items: center; 
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px; /* Add padding for small screens */
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 12px;
    width: 100%; /* Responsive width */
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    
    /* Hide all modals by default */
    display: none; 
    
    /* Sizing and scrolling */
    max-height: 90vh; 
    
    flex-direction: column;
}
/* Show only the *active* modal */
.modal-overlay.active .modal-content.active {
    transform: scale(1);
    opacity: 1;
    display: flex; 
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    /* Center the 'x' icon */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    line-height: 1;
    padding: 0;
    z-index: 10; 
}
.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-title {
    font-size: 1.8em;
    margin-bottom: 15px;
    color: var(--text-primary);
    padding-right: 30px; /* Space for close button */
    flex-shrink: 0; 
}
.modal-body {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 25px;
    flex-shrink: 0; 
}

/* This class makes the content scrollable */
.modal-body-scrollable {
    overflow-y: auto; /* Make this area scroll */
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 0; 
    padding-right: 10px; /* For scrollbar */
}
.modal-body-scrollable h3 {
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 10px;
}
.modal-body-scrollable p, .modal-body-scrollable ul {
    margin-bottom: 15px;
}
.modal-body-scrollable li {
    margin-left: 20px;
    margin-bottom: 8px;
}
/* Fix for feedback modal's intro text */
.modal-body-scrollable .modal-body {
    margin-bottom: 20px;
}

/* --- Modal Buttons (Donation) --- */
.modal-button-container {
    display: flex;
    gap: 15px;
    flex-direction: column;
    flex-shrink: 0; 
    margin-top: 25px; 
}
.modal-button {
    display: block;
    width: 100%;
    padding: 15px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 1em;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}
.modal-button.kofi-button {
    background-color: #29b6f6;
    color: white;
}
.modal-button.kofi-button:hover { background-color: #03a9f4; }
.modal-button.sociabuzz-button {
    background-color: #ffc107;
    color: #333;
}
.modal-button.sociabuzz-button:hover { background-color: #ffca28; }

/* --- Modal Form (Feedback) --- */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
}
.form-group textarea {
    resize: vertical;
    min-height: 80px;
}
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}
.radio-group label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Star Rating CSS */
.star-rating {
    flex-direction: row-reverse; /* To make 5-star first */
    justify-content: flex-end;
}
.star-rating input[type="radio"] {
    display: none; /* Hide the real radio button */
}
.star-rating label {
    font-size: 2em;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s ease;
}
/* The hover/checked logic */
.star-rating:not(:hover) input[type="radio"]:checked ~ label,
.star-rating:hover input[type="radio"]:hover ~ label,
.star-rating input[type="radio"]:checked ~ label,
.star-rating input[type="radio"]:hover ~ label {
    color: var(--star-color); /* Use the new CSS variable */
}

.modal-button.submit-button {
    background: var(--gradient-primary);
    color: white;
    font-size: 1.1em;
}
.modal-button.submit-button:disabled {
    opacity: 0.5;
    cursor: wait;
}
.form-message {
    display: none;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}
.form-message.success {
    background: rgba(76, 175, 80, 0.1);
    color: var(--accent-success);
}
.form-message.error {
    background: rgba(198, 40, 40, 0.1);
    color: var(--accent-error);
}



/* --- Responsive Media Queries --- */
@media (max-width: 768px) {
    body { padding: 10px; }
    .container { padding: 20px; }
    .header {
        flex-direction: column;
        gap: 15px;
    }
    .header-controls {
        width: 100%;
        justify-content: space-between;
    }
    .header-content .main-title { font-size: 2em; }
    .header-content p { font-size: 1.05em; }
    .button-container { flex-direction: column; }
    button { width: 100%; }
    .options-grid { grid-template-columns: 1fr; }
    .tab-button { padding: 10px 16px; font-size: 0.95em; }
    .footer { padding: 20px; }
    .modal-content { padding: 20px; }

   

}





