:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338ca;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-lg: 1rem;
    --radius-md: 0.5rem;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: all 0.2s ease-in-out;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #111827;
        --card-bg: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --border-color: #374151;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
    .icon-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 1rem;
    transition: var(--transition);
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

textarea {
    width: 100%;
    min-height: 150px;
    border: none;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    background: transparent;
    overflow-y: hidden; /* Hide scrollbar for auto-grow */
    box-sizing: border-box;
}

textarea::placeholder {
    color: #9ca3af;
}

.floating-actions {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
}

.floating-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
    opacity: 0.7;
    padding: 0;
    border: none;
    cursor: pointer;
}

.floating-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    color: var(--text-primary);
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    .floating-btn {
        background-color: rgba(255, 255, 255, 0.1);
    }
    .floating-btn:hover {
        background-color: rgba(255, 255, 255, 0.2);
    }
}

.floating-btn svg {
    width: 16px;
    height: 16px;
}

/* Actions Group */
.actions-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    width: 100%;
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: #e0e7ff;
    color: var(--primary-color);
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    white-space: nowrap;
}

.action-btn:hover {
    background: #c7d2fe;
    transform: translateY(-1px);
}

.action-btn:nth-child(2) {
    background: #fce7f3;
    color: #db2777;
}

.action-btn:nth-child(2):hover {
    background: #fbcfe8;
}

.action-btn:nth-child(3) {
    background: #d1fae5;
    color: #059669;
}

.action-btn:nth-child(3):hover {
    background: #a7f3d0;
}

@media (prefers-color-scheme: dark) {
    .action-btn {
        background: rgba(79, 70, 229, 0.2);
        color: #818cf8;
    }
    .action-btn:hover {
        background: rgba(79, 70, 229, 0.3);
    }

    .action-btn:nth-child(2) {
        background: rgba(219, 39, 119, 0.2);
        color: #f472b6;
    }
    .action-btn:nth-child(2):hover {
        background: rgba(219, 39, 119, 0.3);
    }

    .action-btn:nth-child(3) {
        background: rgba(5, 150, 105, 0.2);
        color: #34d399;
    }
    .action-btn:nth-child(3):hover {
        background: rgba(5, 150, 105, 0.3);
    }
}

.settings-trigger {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.settings-trigger:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .settings-trigger:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

.icon svg {
    width: 18px;
    height: 18px;
}

/* Output Section */
.output-section {
    position: relative;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.output-content-editable {
    width: 100%;
    min-height: 180px;
    border: none;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    background: transparent;
    overflow-y: hidden;
    box-sizing: border-box;
}

.output-content-editable::placeholder {
    color: #9ca3af;
}

/* Empty State */
.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Loading Indicator */
.loading-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    z-index: 10;
    border-radius: var(--radius-lg);
}

@media (prefers-color-scheme: dark) {
    .loading-indicator {
        background: rgba(31, 41, 55, 0.8);
    }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

@media (prefers-color-scheme: dark) {
    .spinner {
        border-color: rgba(255, 255, 255, 0.1);
        border-top-color: var(--primary-color);
    }
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    background: var(--card-bg);
    padding: 0;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease;
    max-height: 80vh;
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal.show .modal-content {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

@media (prefers-color-scheme: dark) {
    .form-group input,
    .form-group select {
        background-color: #374151;
        color: var(--text-primary);
    }
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0; /* Don't shrink footer */
    background-color: var(--card-bg); /* Ensure background is opaque */
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.primary-btn,
.secondary-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    border: none;
}

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

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

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

.secondary-btn:hover {
    background-color: var(--bg-color);
}

@media (prefers-color-scheme: dark) {
    .secondary-btn {
        background-color: var(--card-bg);
        color: var(--text-primary);
    }
    .secondary-btn:hover {
        background-color: #374151;
    }
}

.version {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    color: var(--text-secondary);
    opacity: 0.3;
    font-size: 0.8rem;
    pointer-events: none;
}

.usage-count {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    color: var(--text-secondary);
    opacity: 0.3;
    font-size: 0.8rem;
    pointer-events: none;
}

/* Choice Modal Styles */
.choice-modal-body {
    flex-direction: row;
    justify-content: space-around;
    padding-bottom: 2rem;
}

.choice-btn {
    flex: 1;
    padding: 1.5rem;
    flex-direction: column;
}

.choice-btn .icon {
    margin-bottom: 0.5rem;
}

/* Mobile Layout */
@media (max-width: 500px) {
    .actions-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .action-btn {
        width: 100%;
    }

    .settings-trigger {
        width: 100%;
        margin-left: 0;
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        justify-content: center;
        height: auto;
        min-height: 48px;
    }
}
/* Settings Modal Provider Sections */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
    opacity: 0.7;
}

.provider-group {
    margin-bottom: 0.75rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.provider-group:last-child {
    margin-bottom: 0;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    transition: var(--transition);
}

.radio-label:hover {
    background-color: var(--border-color);
}

.radio-label input[type="radio"] {
    margin-right: 0.75rem;
    cursor: pointer;
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.provider-config {
    margin-top: 0.5rem;
    margin-left: 0.75rem;
    padding: 0.75rem;
    display: none;
    gap: 0.625rem;
    flex-direction: column;
    background-color: var(--card-bg);
    border-left: 3px solid var(--primary-color);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.api-key-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    transition: var(--transition);
}

.api-key-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.model-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.model-select:hover {
    border-color: var(--primary-hover);
}


.select-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.refresh-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

@media (prefers-color-scheme: dark) {
    .refresh-btn {
        background-color: #111827;
        border-color: #374151;
    }
    .refresh-btn:hover {
        background-color: #374151;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    max-width: 90%;
    min-width: 280px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.toast.error .toast-icon {
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.toast-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
    .toast-close:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

@media (max-width: 500px) {
    .toast {
        min-width: auto;
        width: calc(100% - 2rem);
    }
}

