/* CSS Variables for easy theming */
:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-success: #16a34a;
    --color-success-hover: #15803d;
    --color-purple: #9333ea;
    --color-purple-hover: #7e22ce;
    --color-secondary: #64748b;
    --color-secondary-hover: #475569;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    
    --color-bg: #f8fafc;
    --color-card: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    
    --color-api-key-bg: #fef3c7;
    --color-api-key-border: #fcd34d;
    
    --color-help-bg: #dbeafe;
    --color-help-border: #93c5fd;
    --color-help-text: #1e40af;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

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

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

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

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

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

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

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

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

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

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

.btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
}

.icon {
    font-size: 1rem;
}

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

/* Data Summary Section */
.data-summary-section {
    background: #dbeafe;
    border: 2px solid #93c5fd;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.data-summary-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.data-summary-header .icon {
    font-size: 1.5rem;
}

.data-summary-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e40af;
    margin: 0;
}

.data-summary-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-summary-item {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    line-height: 1.5;
}

.data-summary-item strong {
    color: #1e40af;
    margin-right: 0.5rem;
}

/* API Key Section */
.api-key-section {
    background: var(--color-api-key-bg);
    border: 2px solid var(--color-api-key-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.api-key-section.verified {
    background: #d1fae5;
    border-color: #6ee7b7;
}

.api-key-section.verified .api-key-header h3::after {
    content: " ✓";
    color: var(--color-success);
    margin-left: 0.5rem;
}

.api-key-section.minimized {
    padding: 1rem 1.5rem;
    cursor: pointer;
}

.api-key-section.minimized .api-key-header {
    margin-bottom: 0;
}

.api-key-section.minimized .api-key-header p {
    display: none;
}

.api-key-section.minimized .api-key-input-group {
    display: none;
}

.api-key-section.minimized:hover {
    opacity: 0.8;
}

.api-key-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.api-key-header .icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.api-key-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.api-key-header p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.api-key-header a {
    color: var(--color-primary);
    text-decoration: none;
}

.api-key-header a:hover {
    text-decoration: underline;
}

.api-key-input-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#verifyApiKeyBtn.verified {
    background: var(--color-success);
}

/* Form Elements */
.input,
.textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.textarea {
    resize: vertical;
    font-family: inherit;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

/* Custom Instructions Section */
.custom-instructions-section {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
}

/* Edit Section */
.edit-section {
    background: #f1f5f9;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

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

.edit-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
}

/* Form Sections */
.form-section {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1rem;
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    cursor: pointer;
    user-select: none;
}

.form-section-header:hover {
    background: #f1f5f9;
}

.form-section-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.chevron {
    transition: transform 0.2s;
}

.form-section-header.expanded .chevron {
    transform: rotate(180deg);
}

.form-section-content {
    padding: 1.5rem;
    display: none;
}

.form-section-content.show {
    display: block;
}

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

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

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

.categories-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.categories-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
}

.category-header {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.category-name-input {
    flex: 1;
    font-weight: 600;
}

.category-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.category-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.item-checkbox {
    display: flex;
    align-items: center;
    padding-top: 0.75rem;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.priority-controls {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 0.5rem;
}

.priority-btn {
    background: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 0.25rem;
    color: var(--color-text-muted);
    transition: all 0.2s;
}

.priority-btn:hover:not(:disabled) {
    background: #f1f5f9;
    color: var(--color-text);
}

.priority-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.category-item-textarea {
    flex: 1;
    min-height: 60px;
}

.delete-item-btn {
    flex-shrink: 0;
    padding: 0.5rem;
}

.empty-categories {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Bio Variants Section */
.bio-variants-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.bio-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
}

.bio-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.bio-card-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
}

.bio-card-actions {
    display: flex;
    gap: 0.5rem;
}

.bio-content {
    color: var(--color-text);
    line-height: 1.8;
}

.bio-placeholder {
    color: var(--color-text-muted);
    font-style: italic;
    text-align: center;
    padding: 2rem 1rem;
}

.bio-text {
    white-space: pre-wrap;
}

.bio-sentence {
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0 0.25rem;
    margin: 0 -0.25rem;
    border-radius: 0.25rem;
}

.bio-sentence:hover {
    background: #fef9c3;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.bio-sentence.regenerating {
    background: #dbeafe;
    color: var(--color-primary);
    font-style: italic;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--color-text-muted);
    gap: 0.5rem;
}

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

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

/* Help Section */
.help-section {
    background: var(--color-help-bg);
    border: 1px solid var(--color-help-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.help-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-help-text);
    margin-bottom: 1rem;
}

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

.help-section li {
    color: var(--color-help-text);
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    
    .header {
        padding: 1.5rem 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .header-actions .btn {
        flex: 1;
        justify-content: center;
    }
    
    .api-key-input-group {
        flex-direction: column;
    }
    
    .bio-card-header {
        flex-direction: column;
    }
    
    .bio-card-actions {
        width: 100%;
    }
    
    .bio-card-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--color-text-muted);
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
