/* Download templates button */
.download-templates-banner {
    background-color: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}

.download-templates-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.download-templates-btn:hover {
    background-color: #45a049;
}

.download-templates-banner span {
    color: #ddd;
    font-size: 0.9rem;
}

/* Ensure scrolling is enabled */
html, body {
    overflow: auto !important;
    min-height: 100% !important;
    height: auto !important;
}

/* Meme Generator Styles */
.meme-container {
    background: rgba(0, 0, 0, 0.7);
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 1000px;
    margin: 0 auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.meme-workspace {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 768px) {
    .meme-workspace {
        flex-direction: row;
    }
    
    .template-section {
        flex: 1;
    }
    
    .editor-section {
        flex: 2;
    }
}

.template-section, .editor-section {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 1rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #4CAF50;
}

h3 {
    font-size: 1.2rem;
    margin: 1rem 0;
    color: #4CAF50;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 350px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

.template-item {
    height: 120px;
    background-size: cover;
    background-position: center;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.template-item::after {
    content: attr(data-name);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px;
    font-size: 0.8rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-item:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.template-item.active {
    border: 3px solid #4CAF50;
}

.template-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1rem;
    color: #aaa;
}

.upload-section {
    margin-top: 1rem;
}

.upload-btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    background-color: #f39c12;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.upload-btn:hover {
    background-color: #e67e22;
}

input[type="file"] {
    display: none;
}

.meme-preview {
    position: relative;
    width: 100%;
    max-width: 350px; /* Smaller width for better capture */
    margin: 0 auto; /* Center it */
    height: 350px;
    background-color: #222;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 5px;
    margin-bottom: 1rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
}

.preview-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    text-align: center;
}

.text-element {
    position: absolute;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    color: white;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    cursor: move;
    user-select: none;
    text-align: center;
    max-width: 90%;
    white-space: pre-wrap;
    word-break: break-word;
    z-index: 10;
}

.text-element.selected {
    outline: 2px dashed #4CAF50;
}

.text-controls {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 5px;
}

.text-input-group {
    margin-bottom: 1rem;
}

textarea {
    width: 100%;
    height: 80px;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 4px;
    resize: vertical;
}

.text-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

label {
    color: #ddd;
    font-size: 0.9rem;
}

input[type="color"] {
    width: 40px;
    height: 25px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

input[type="range"] {
    width: 100px;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.primary-btn {
    background-color: #4CAF50;
    color: white;
}

.primary-btn:hover {
    background-color: #45a049;
}

.secondary-btn {
    background-color: #f44336;
    color: white;
}

.secondary-btn:hover {
    background-color: #d32f2f;
}

.success-btn {
    background-color: #2196F3;
    color: white;
}

.success-btn:hover {
    background-color: #0b7dda;
}

.download-info {
    margin-top: 0.5rem;
    text-align: center;
    color: #aaa;
}

.download-info small {
    font-size: 0.9rem;
}

.fallback-link {
    color: #4CAF50;
    text-decoration: none;
}

.fallback-link:hover {
    text-decoration: underline;
}

.back-button {
    padding: 0.7rem 1.5rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    text-decoration: none;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
}

.modal-content {
    background: #222;
    margin: 10% auto;
    padding: 2rem;
    width: 80%;
    max-width: 700px;
    border-radius: 10px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: #aaa;
    cursor: pointer;
}

.close-btn:hover {
    color: white;
}

/* Helper button for instructions */
.help-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.help-btn:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

/* Loading indicator */
.loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    z-index: 5;
}

.spinner {
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 5px solid #4CAF50;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}