/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
    color: #333;
}

.wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Input Section */
.input-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
    font-family: inherit;
}

.input-group input[type="text"]:focus,
.input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results */
.results {
    display: grid;
    gap: 30px;
}

.topic-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.topic-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
}

.topic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.topic-title {
    font-size: 1.8em;
    color: #667eea;
    font-weight: 700;
    flex: 1;
    min-width: 200px;
}

.topic-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.btn-regenerate {
    background: #ff9800;
    color: white;
}

.btn-preview {
    background: #4CAF50;
    color: white;
}

.btn-print {
    background: #2196F3;
    color: white;
}

.btn-print-all {
    background: #9c27b0;
    color: white;
    margin-bottom: 20px;
    padding: 15px 20px;
    font-size: 16px;
    flex: 1;
    min-width: 200px;
}

.btn-export {
    background: #e91e63;
    color: white;
}

.btn-export:hover {
    background: #c2185b;
}

.topic-content {
    margin-bottom: 30px;
}

.topic-content p {
    margin-bottom: 18px;
    line-height: 1.8;
    font-size: 16px;
    color: #444;
}

.topic-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.topic-images img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.topic-images img:hover {
    transform: scale(1.05);
}

.image-placeholder {
    width: 100%;
    height: 200px;
    background: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}

.language-separator {
    margin: 40px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
    font-size: 18px;
    border: 2px dashed #667eea;
}

/* RTL Support */
[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .topic-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .topic-actions {
    flex-direction: row-reverse;
}

/* Error Message */
.error {
    background: #ffebee;
    color: #c62828;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid #c62828;
    font-weight: 500;
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .input-section,
    .topic-actions,
    .topic-header .topic-actions,
    header,
    .btn-print-all,
    .btn,
    button {
        display: none !important;
    }
    
    .topic-card {
        page-break-inside: avoid;
        margin-bottom: 30px;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .topic-title {
        page-break-after: avoid;
    }
    
    .topic-content {
        page-break-inside: avoid;
    }
    
    .topic-images {
        page-break-inside: avoid;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 2em;
    }

    .input-section {
        padding: 20px;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .topic-header {
        flex-direction: column;
    }

    .topic-title {
        font-size: 1.5em;
        margin-bottom: 15px;
    }

    .topic-actions {
        width: 100%;
    }

    .btn {
        flex: 1;
        min-width: 100px;
    }

    .topic-images {
        grid-template-columns: repeat(2, 1fr);
    }

    .topic-card {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }

    .topic-images {
        grid-template-columns: 1fr;
    }

    .topic-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

