/* CaptionGenius Main Styles */

:root {
    --primary-gradient: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
    --primary-color: #8B5CF6;
    --secondary-color: #EC4899;
    --bg-light: #F9FAFB;
    --bg-white: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --success-color: #10B981;
    --error-color: #EF4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

.cg-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header Styles */
.cg-header {
    text-align: center;
    margin-bottom: 40px;
}

.cg-title {
    font-size: 3rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 10px 0;
    line-height: 1.2;
}

.cg-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Main Card */
.cg-main-card {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

/* Section Styles */
.cg-section {
    margin-bottom: 30px;
}

.cg-label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

/* Platform Buttons */
.cg-platform-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.cg-platform-btn {
    flex: 1;
    min-width: 140px;
    padding: 14px 20px;
    border: 2px solid var(--border-color);
    background: var(--bg-white);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cg-platform-btn:hover {
    border-color: var(--primary-color);
    background: #F3F4F6;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.cg-platform-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-lg);
}

.platform-icon {
    font-size: 1.25rem;
}

/* Input Grid */
.cg-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Upload Area */
.cg-upload-area {
    position: relative;
}

.cg-upload-box {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-light);
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.cg-upload-box:hover {
    border-color: var(--primary-color);
    background: #FAF5FF;
}

.cg-upload-box.drag-over {
    border-color: var(--secondary-color);
    background: #FDF2F8;
    transform: scale(1.02);
}

.cg-upload-content {
    pointer-events: none;
}

.cg-upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

.cg-upload-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.cg-upload-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.cg-image-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
}

.cg-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cg-remove-image {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.cg-remove-image:hover {
    background: var(--error-color);
    transform: scale(1.1);
}

/* Textarea */
.cg-text-area {
    position: relative;
}

.cg-textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
    color: var(--text-primary);
    line-height: 1.6;
}

.cg-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.cg-char-count {
    position: absolute;
    bottom: -24px;
    right: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Select Dropdown */
.cg-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.3s ease;
}

.cg-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Generate Button */
.cg-generate-btn {
    width: 100%;
    padding: 18px 32px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.cg-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

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

.cg-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Results Section */
.cg-results {
    margin-top: 40px;
    animation: fadeInUp 0.5s ease;
}

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

.cg-results-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 24px 0;
    text-align: center;
}

/* Caption Cards */
.cg-captions-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cg-caption-card {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s ease;
    animation: slideIn 0.4s ease;
}

.cg-caption-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.cg-caption-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cg-caption-number {
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
    background: var(--primary-gradient);
    padding: 6px 14px;
    border-radius: 20px;
}

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

.cg-action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.cg-action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.cg-copy-btn.copied {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.cg-caption-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-white);
    border-radius: 8px;
}

.cg-caption-footer {
    display: flex;
    justify-content: flex-end;
}

.cg-caption-length {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* History Section */
.cg-history-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 2px solid var(--border-color);
}

.cg-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cg-history-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.cg-toggle-history-btn {
    padding: 10px 20px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cg-toggle-history-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.cg-history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px;
}

.cg-history-list::-webkit-scrollbar {
    width: 8px;
}

.cg-history-list::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.cg-history-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.cg-history-item {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.cg-history-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.cg-history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.cg-history-platform,
.cg-history-tone,
.cg-history-date {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.cg-history-platform {
    background: #DBEAFE;
    color: #1E40AF;
}

.cg-history-tone {
    background: #FCE7F3;
    color: #BE185D;
}

.cg-history-date {
    background: var(--bg-light);
    color: var(--text-secondary);
}

.cg-history-caption {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.cg-history-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.cg-delete-btn:hover {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

/* Alert Messages */
.cg-alert {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

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

.cg-alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #10B981;
}

.cg-alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #EF4444;
}

.cg-alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #3B82F6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cg-container {
        padding: 15px;
    }
    
    .cg-main-card {
        padding: 24px;
        border-radius: 16px;
    }
    
    .cg-title {
        font-size: 2rem;
    }
    
    .cg-subtitle {
        font-size: 1rem;
    }
    
    .cg-platform-buttons {
        flex-direction: column;
    }
    
    .cg-platform-btn {
        min-width: 100%;
    }
    
    .cg-input-grid {
        grid-template-columns: 1fr;
    }
    
    .cg-upload-box {
        min-height: 200px;
        padding: 30px 15px;
    }
    
    .cg-caption-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .cg-caption-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .cg-history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .cg-toggle-history-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .cg-title {
        font-size: 1.75rem;
    }
    
    .cg-main-card {
        padding: 20px;
    }
    
    .cg-generate-btn {
        font-size: 1rem;
        padding: 16px 24px;
    }
    
    .cg-action-btn {
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}