/* Styles */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border-color: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #c1cedb;
    --header-color: #0065d8d8;
    --accent-color: #58a6ff;
    --accent-hover: #4898e9;
    --success-color: #3bac4a;
    --success-hover: #2a913d;
    --error-color: #f85149;
    --notice-color: #f8f549;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

/* Sharp edges for most containers */
.main-container {
    background: rgba(33, 38, 45, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 0; /* Sharp edges */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    margin: 2rem auto;
    max-width: 1000px;
}

.header-section {
    font-family: 'K2D', -apple-system, sans-serif;
    background: var(--header-color);
    border-radius: 0; /* Sharp edges */
    padding: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('/static/images/TheBanner2.png');
    opacity: 0.15;
}

.header-section h1 {
    margin: 0;
    font-weight: 500;
    font-size: 2.5rem;
    color: white;
    position: relative;
    z-index: 2;
    letter-spacing: -0.02em; /* Tighter letter spacing for Space Grotesk */
}

.header-section .subtitle {
    margin-top: 0.5rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
    font-weight: 300;
    position: relative;
    z-index: 2;
}

.form-section {
    padding: 2rem;
}

/* Sharp edges for form controls */
.form-control, .form-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0; /* Sharp edges */
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(88, 166, 255, 0.25);
    color: var(--text-primary);
}

.form-label {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Keep rounded edges for buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-color) 0%, #4493e0 100%);
    border: none;
    border-radius: 8px; /* Keep rounded */
    font-weight: 500;
    padding: 0.75rem 2rem;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, #3a7bc8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #119429 100%);
    border: none;
    border-radius: 8px; /* Keep rounded */
    font-weight: 500;
    padding: 0.75rem 2rem;
    transition: all 0.3s ease;
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--success-hover) 0%, #44e261 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(63, 185, 80, 0.3);
}

.error-message {
    color: var(--error-color);
    font-weight: 500;
    text-align: center;
    margin: 1rem 0;
    padding: 0.5rem;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.2);
    border-radius: 0; /* Sharp edges */
    display: none;
}

.input-error {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(248, 81, 73, 0.25) !important;
}

.loading-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0; /* Sharp edges */
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
}

.progress {
    height: 8px;
    background-color: var(--bg-tertiary);
    border-radius: 0; /* Sharp edges */
}

.progress-bar {
    background: linear-gradient(90deg, var(--accent-color) 0%, #7c3aed 100%);
    border-radius: 0; /* Sharp edges */
}

/* Make progress updates sharp (no smooth transition) */
.progress-bar {
    transition: none !important;
}

.results-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0; /* Sharp edges */
    padding: 2rem;
    margin: 2rem auto;
    max-height: 400px;
}

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

.results-header h3 {
    margin: 0;
    color: var(--accent-color);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.name-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
}

.name-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px; /* Keep slightly rounded for name badges */
    padding: 0.75rem 1rem;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.name-item:hover {
    background: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.3);
}

.custom-notice {
    background: rgba(248, 245, 73, 0.1);
    border: 1px solid rgba(248, 236, 73, 0.2);
    border-radius: 0; /* Sharp edges */
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--notice-color);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.form-row > div {
    flex: 1;
    min-width: 200px;
}

.form-row .gender-group {
    flex: 0.4;
    min-width: 120px;
}

/* Custom scrollbar */
.name-grid::-webkit-scrollbar {
    width: 6px;
}

.name-grid::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 0;
}

.name-grid::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 0;
}

.name-grid::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

@media (max-width: 768px) {
    .main-container {
        margin: 1rem;
    }
    
    .header-section h1 {
        font-size: 2rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-row > div {
        min-width: auto;
    }
    
    .name-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* Toggle Button Styles - keep rounded for buttons */
.model-type-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 8px; /* Keep rounded for button-like elements */
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.toggle-option {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.toggle-option.active {
    background: var(--accent-color);
    color: white;
}

.toggle-option:hover:not(.active) {
    background: rgba(88, 166, 255, 0.1);
    color: var(--text-primary);
}

.toggle-option i {
    font-size: 1.1rem;
}

/* Tab Content */
.tab-content {
    min-height: 120px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-pane.active {
    display: block;
}

.custom-model-manager {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0; /* Sharp edges */
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.model-search-container {
    position: relative;
    margin-bottom: 1rem;
}

.model-search-input {
    padding-right: 40px;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.custom-model-list {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0; /* Sharp edges */
    background: var(--bg-secondary);
}

.custom-model-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.custom-model-item:hover {
    background: rgba(88, 166, 255, 0.1);
}

.custom-model-item.selected {
    background: rgba(88, 166, 255, 0.2);
    border-left: 3px solid var(--accent-color);
}

/* Copied-to-clipboard toast */
.copied-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    z-index: 9999;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    font-size: 13px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 180ms ease-in-out, transform 180ms ease-in-out;
}
.copied-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.custom-model-item:last-child {
    border-bottom: none;
}

.model-info {
    flex: 1;
}

.model-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

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

.model-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 6px; /* Keep some rounding for small buttons */
}

.new-model-section {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: 0; /* Sharp edges */
    padding: 1.5rem;
    margin-top: 1rem;
    transition: all 0.3s ease;
}

.new-model-section.active {
    border-color: var(--accent-color);
    background: rgba(88, 166, 255, 0.05);
}

.success-message {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: 0; /* Sharp edges */
    padding: 12px;
    margin: 1rem 0;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeInUp 0.5s ease;
}

.error-message-inline {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: 0; /* Sharp edges */
    padding: 12px;
    margin: 1rem 0;
    color: var(--error-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0; /* Sharp edges */
    z-index: 10;
}

.loading-content {
    text-align: center;
    color: var(--text-primary);
}

.model-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.stat-badge {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px; /* Keep slight rounding for badges */
    padding: 2px 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-model-list::-webkit-scrollbar {
    width: 6px;
}

.custom-model-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 0;
}

.custom-model-list::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 0;
}

/* Custom textarea resize wrapper for training names */
.textarea-resize-wrapper {
    position: relative;
}

.custom-resize-textarea {
    resize: none; /* We'll provide a custom, smoother resize */
    overflow: auto;
    transition: height 220ms cubic-bezier(.2,.8,.2,1); /* smooth size change */
}

/* Make the resize handle more obvious and larger */
.resize-handle {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 3px;
    cursor: se-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.resize-handle::after {
    content: '';
    width: 8px;
    height: 8px;
    background-image: linear-gradient(45deg, rgba(0,0,0,0.35) 25%, transparent 25%, transparent 50%, rgba(0,0,0,0.35) 50%, rgba(0,0,0,0.35) 75%, transparent 75%, transparent);
    background-size: 4px 4px;
    opacity: 0.6;
}

/* Live name count badge */
.names-count {
    position: absolute;
    right: 8px;
    top: 8px;
    background: rgba(0,0,0,0.45);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid rgba(255,255,255,0.04);
    z-index: 4;
    pointer-events: none; /* don't block typing */
}

#new-model-description {
    max-height: 140px;
    overflow: auto;
    transition: height 180ms cubic-bezier(.2,.8,.2,1);
    resize: vertical; 
}

/* Description-specific handle alignment (matches training textarea) */
#desc-resize-handle {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 18px;
    height: 18px;
}