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

:root {
    --primary-color: #4f46e5;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f9fafb;
    --card-bg: #ffffff;
    --text-color: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --error-color: #ef4444;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

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

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.header-content {
    flex: 1;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0;
}

.btn-lang {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-lang:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.lang-icon {
    font-size: 1.1rem;
}

.api-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: pulse 2s ease-in-out infinite;
}

.api-status.connected .status-indicator {
    background-color: #10b981;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main */
main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Sections */
section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

section h3 {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Form Groups */
.form-group {
    margin-bottom: 25px;
}

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

.input-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.input-field {
    display: flex;
    flex-direction: column;
}

.input-field label {
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-field input,
.input-field select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s;
}

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

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-field label {
    cursor: pointer;
    user-select: none;
}

.info-text {
    background: #eff6ff;
    padding: 15px;
    border-radius: 8px;
    color: #1e40af;
    font-size: 0.95rem;
    border-left: 4px solid var(--primary-color);
}

/* Buttons */
.controls-section {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

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

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

.btn-primary:hover:not(:disabled) {
    background: #4338ca;
}

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

.btn-secondary:hover:not(:disabled) {
    background: #d97706;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Progress Section */
.progress-bar-container {
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 12px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.stat {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-value.error {
    color: var(--error-color);
}

/* Chart Preview */
.chart-preview {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
    overflow: auto;
}

.chart-preview svg {
    max-width: 100%;
    height: auto;
}

.loading {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Gallery */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.gallery-header h2 {
    margin-bottom: 0;
    border-bottom: none;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.gallery-item {
    background: var(--bg-color);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: pointer;
}

.gallery-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.gallery-item-preview {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    overflow: hidden;
}

.gallery-item-preview svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.gallery-item-info {
    padding: 12px;
    background: white;
}

.gallery-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--text-color);
}

.gallery-item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gallery-item-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px;
}

.gallery-item-actions button {
    flex: 1;
    padding: 6px;
    font-size: 0.8rem;
}

/* Log Section */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.log-header h2 {
    margin-bottom: 0;
    border-bottom: none;
}

.log-container {
    background: #1f2937;
    color: #f3f4f6;
    padding: 15px;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.log-entry {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    border-left: 3px solid transparent;
}

.log-entry.info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}

.log-entry.success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
}

.log-entry.error {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: #ef4444;
}

.log-entry.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
}

.log-time {
    color: #9ca3af;
    margin-right: 8px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .controls-section {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
