/* Aesir Blessings Configuration Styling */

/* Layout for page with sidebar - CRITICAL FIX for bottom-alignment issue */
.jotun-page-with-sidebar {
    display: flex;
    gap: 30px;
    max-width: 1710px;
    margin: 0 auto;
    padding: 20px;
    align-items: flex-start; /* CRITICAL: Prevents content from being pushed down by tall sidebar */
}

.jotun-main-content {
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

/* Responsive - Stack on mobile */
@media (max-width: 1200px) {
    .jotun-page-with-sidebar {
        flex-direction: column;
    }
}

.blessings-config-app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 20px 20px; /* Removed top padding to reduce empty space */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary, #2c3e50);
}

.blessings-config-header {
    margin-top: 20px; /* Add small top margin for breathing room */
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, var(--accent-from, #667eea) 0%, var(--accent-to, #764ba2) 100%);
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.blessings-config-title {
    font-size: 2.5em;
    margin: 0 0 10px 0;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.blessings-config-subtitle {
    font-size: 1.1em;
    margin: 0;
    opacity: 0.95;
}

.admin-info {
    background: rgba(255, 255, 255, 0.25);
    padding: 10px 20px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.admin-label {
    font-weight: 600;
    margin-right: 8px;
}

.admin-name {
    font-weight: 700;
}

.blessings-config-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.card-header {
    background: var(--bg-page, #f8f9fa);
    padding: 20px;
    border-bottom: 2px solid var(--border-card, #e9ecef);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    margin: 0;
    font-size: 1.6em;
    color: var(--text-primary, #2c3e50);
    font-weight: 600;
}

.card-content {
    padding: 20px;
}

/* Items List */
.items-list {
    min-height: 100px;
}

.items-list-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted, #6c757d);
    font-style: italic;
}

.item-config-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 100px;
    gap: 15px;
    padding: 15px;
    border: 2px solid var(--border-card, #e9ecef);
    border-radius: 8px;
    margin-bottom: 10px;
    align-items: center;
    transition: all 0.3s ease;
}

.item-config-row:hover {
    border-color: var(--accent-from, #667eea);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.item-config-name {
    font-weight: 600;
    font-size: 1.1em;
    color: var(--text-primary, #2c3e50);
}

.item-config-column {
    color: var(--text-muted, #6c757d);
    font-size: 0.9em;
    font-family: 'Courier New', monospace;
}

.item-config-max {
    text-align: center;
    font-weight: 500;
}

.item-config-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.icon-btn {
    background: none;
    border: 2px solid var(--border-card, #dee2e6);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1em;
}

.icon-btn:hover {
    background: var(--bg-page, #f8f9fa);
    border-color: var(--accent-from, #667eea);
}

.icon-btn.delete {
    color: #dc3545;
}

.icon-btn.delete:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

/* API Configuration */
.api-info-section,
.api-usage-section,
.api-keys-section {
    margin-bottom: 30px;
}

.api-info-section h3,
.api-usage-section h3,
.api-keys-section h3 {
    color: var(--text-primary, #2c3e50);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.api-endpoint-box {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: var(--bg-page, #f8f9fa);
    border-radius: 8px;
    border: 2px solid var(--border-card, #e9ecef);
}

.api-endpoint-box code {
    flex: 1;
    background: white;
    padding: 10px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    word-break: break-all;
}

.api-info-text {
    margin-top: 10px;
    color: var(--text-muted, #6c757d);
    line-height: 1.6;
}

.api-info-text code {
    background: var(--bg-page, #f8f9fa);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.api-usage-box {
    background: var(--bg-page, #f8f9fa);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--border-card, #e9ecef);
}

.api-usage-box h4 {
    color: var(--text-primary, #2c3e50);
    margin-top: 20px;
    margin-bottom: 10px;
}

.api-usage-box h4:first-child {
    margin-top: 0;
}

.api-usage-box pre {
    background: white;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border-card, #dee2e6);
}

.api-usage-box code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--text-primary, #2c3e50);
}

/* Grant Profiles List */
.grant-profiles-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-page, #f8f9fa);
    border-radius: 8px;
}

.grant-profiles-list {
    min-height: 80px;
    margin-top: 15px;
}

.grant-profiles-loading {
    text-align: center;
    padding: 30px;
    color: var(--text-muted, #6c757d);
    font-style: italic;
}

.empty-state {
    text-align: center;
    color: var(--text-muted, #6c757d);
    font-style: italic;
    padding: 20px;
}

/* API Keys List */
.api-keys-list {
    min-height: 80px;
}

.api-keys-loading {
    text-align: center;
    padding: 30px;
    color: var(--text-muted, #6c757d);
    font-style: italic;
}

.api-key-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 1fr 100px;
    gap: 15px;
    padding: 15px;
    border: 2px solid var(--border-card, #e9ecef);
    border-radius: 8px;
    margin-bottom: 10px;
    align-items: center;
    transition: all 0.3s ease;
}

.api-key-row:hover {
    border-color: var(--accent-from, #667eea);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.api-key-row.inactive {
    opacity: 0.6;
}

.api-key-name {
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
}

.api-key-preview {
    font-family: 'Courier New', monospace;
    color: var(--text-muted, #6c757d);
    font-size: 0.9em;
}

.api-key-stats {
    color: var(--text-muted, #6c757d);
    font-size: 0.9em;
}

.api-key-date {
    color: var(--text-muted, #6c757d);
    font-size: 0.85em;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-from, #667eea) 0%, var(--accent-to, #764ba2) 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--text-muted, #6c757d);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-icon {
    font-size: 1.2em;
}

.copy-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #218838;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 2px solid var(--border-card, #e9ecef);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary, #2c3e50);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted, #6c757d);
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: var(--text-primary, #2c3e50);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 2px solid var(--border-card, #e9ecef);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form Fields */
.form-field {
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary, #2c3e50);
}

.form-field small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted, #6c757d);
    font-size: 0.9em;
}

.field-input,
.field-select {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    border: 2px solid var(--border-card, #dee2e6);
    border-radius: 8px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.field-input:focus,
.field-select:focus {
    outline: none;
    border-color: var(--accent-from, #667eea);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* API Key Display */
.api-key-display {
    text-align: center;
}

.warning-text {
    color: #dc3545;
    font-weight: 600;
    margin: 15px 0;
}

.api-key-box {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: var(--bg-page, #f8f9fa);
    border-radius: 8px;
    border: 2px solid var(--accent-from, #667eea);
    margin: 20px 0;
}

.api-key-box code {
    flex: 1;
    background: white;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    word-break: break-all;
    font-weight: 600;
    color: var(--accent-from, #667eea);
}

/* Messages */
.config-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.message {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.message.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* Responsive Design */
@media (max-width: 768px) {
    .blessings-config-header {
        padding: 20px;
    }
    
    .blessings-config-title {
        font-size: 2em;
    }
    
    .item-config-row,
    .api-key-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .item-config-actions,
    .api-key-actions {
        justify-content: flex-start;
    }
}
