/* Meme Generator Specific Styles - Compact Layout */

/* Combined Text Controls - Ultra Compact */
.text-controls-combined {
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Text Controls Row */
.text-areas-container {
    background-color: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.text-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.text-area-group {
    flex: 1;
}

.text-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.text-input-main {
    flex: 1;
}

.text-input-main input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.text-input-main input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.text-input-main input[type="text"]::placeholder {
    color: #999;
    font-weight: 500;
}

/* Compact Text Size Controls */
.text-size-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.text-size-control .style-slider {
    width: 70px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, #e0e0e0, #3498db);
    outline: none;
    margin: 2px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-appearance: none;
}

.text-size-control .style-slider:hover {
    background: linear-gradient(to right, #d0d0d0, #2980b9);
    transform: scaleY(1.5);
}

.text-size-control .style-slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.text-size-control .style-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #2980b9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.text-size-control .style-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.text-size-control .slider-value {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
    font-weight: 600;
}

/* Compact Add Text Button */
.add-text-control {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.add-text-button {
    background-color: #3498db;
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
    line-height: 1;
    padding: 0;
}

.add-text-button:hover:not(:disabled) {
    background-color: #2980b9;
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(52, 152, 219, 0.4);
}

.add-text-button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}
/* Remove button for additional text areas */
.remove-text-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.remove-text-btn:hover {
    background-color: #c0392b;
    transform: scale(1.1);
}

.remove-text-btn:after {
    content: '×';
}

/* Additional text areas */
.additional-text-area {
    display: flex;
    align-items: center;
    gap: 15px;
    background-color: white;
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    margin-top: 10px;
}

.additional-text-area .text-area-group {
    flex: 1;
    margin: 0;
}

.additional-text-area .text-input-row {
    margin-bottom: 0;
}

/* Meme Options Row */
.meme-options {
    background-color: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.options-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.option-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.option-group label {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    white-space: nowrap;
}

.option-group select,
.option-group input[type="color"] {
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.option-group select:focus,
.option-group input[type="color"]:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.option-group input[type="color"] {
    width: 40px;
    height: 32px;
    cursor: pointer;
    padding: 0;
    background: none;
}

/* Meme Preview */
.preview-container {
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.preview-container h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
}

.preview-container h3 small {
    color: #666;
    font-weight: normal;
    font-size: 14px;
    margin-left: 10px;
}

.meme-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 6px;
    padding: 20px;
    position: relative;
}

/* Canvas and Text Overlay */
.canvas-container {
    position: relative;
    display: inline-block;
}

#memeCanvas {
    max-width: 500px;
    max-height: 500px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    cursor: crosshair;
}

#memeCanvas:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.text-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.text-overlay * {
    pointer-events: auto;
}

/* Editable Text Elements */
.editable-text-container.dragging {
    transition: none !important;
}

/* Canvas container fix */
.canvas-container {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.text-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.text-overlay * {
    pointer-events: auto;
}

/* Responsive improvements for mobile */
@media (hover: none) and (pointer: coarse) {
    .editable-text {
        padding: 8px 12px;
        min-width: 80px;
        min-height: 40px;
        font-size: 16px !important;
    }
    
    .editable-text:focus {
        outline-width: 3px;
    }
}

.editable-text {
    outline: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
    transition: all 0.2s ease;
    font-family: 'Impact', Arial, sans-serif;
    font-weight: bold;
    white-space: nowrap;
    text-transform: uppercase;
    background-color: transparent;
    display: inline-block;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.editable-text:focus {
    outline: 2px dashed rgba(255, 255, 255, 0.9) !important;
    outline-offset: 2px !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.editable-text:hover:not(:focus) {
    outline: 2px dashed rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
    background-color: rgba(0, 0, 0, 0.2);
}
/* Meme Templates */
.meme-templates {
    margin: 25px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.meme-templates h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
    text-align: center;
}

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

.template-item {
    background-color: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.template-item:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.template-item.selected {
    border-color: #2ecc71;
    background-color: #e8f5e8;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
    animation: templateSelect 0.3s ease-in-out;
}

.template-item.selected::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background-color: #2ecc71;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.template-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
    transition: transform 0.3s ease;
}

.template-item:hover img {
    transform: scale(1.05);
}

.template-item span {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.2;
}

/* Loading states */
.template-item.loading {
    opacity: 0.6;
    pointer-events: none;
}

.template-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #3498db;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.meme-preview.loading {
    background: #f8f9fa;
}

.meme-preview.loading::after {
    content: 'Generating preview...';
    color: #666;
    font-style: italic;
    position: absolute;
}

.text-overlay.loading {
    pointer-events: none;
    opacity: 0.5;
}

.text-overlay.loading::after {
    content: 'Updating...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
}

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

@keyframes templateSelect {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .text-row {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .add-text-control {
        justify-content: center;
        margin-top: 10px;
    }
    
    .options-row {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .option-group {
        flex: 1 1 45%;
        min-width: 120px;
    }
    
    .text-size-control {
        align-self: center;
        margin-top: 8px;
    }
    
    .additional-text-area {
        flex-direction: column;
        align-items: stretch;
    }
    
    .additional-text-area .remove-text-btn {
        align-self: center;
        margin-left: 0;
        margin-top: 8px;
    }
    
    .templates-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .template-item {
        padding: 8px;
    }
    
    .template-item img {
        width: 60px;
        height: 60px;
    }
    
    .template-item span {
        font-size: 10px;
    }
    
    #memeCanvas {
        max-width: 350px;
        max-height: 350px;
    }
    
    .meme-preview {
        padding: 10px;
        min-height: 250px;
    }
    
    .canvas-container {
        width: 100%;
        max-width: 350px;
    }
    
    .text-controls-combined {
        padding: 15px;
    }
    
    .text-areas-container,
    .meme-options {
        padding: 12px;
    }
    
    .editable-text {
        min-width: 80px;
        padding: 6px 10px;
    }
}

@media screen and (max-width: 480px) {
    .options-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .option-group {
        flex: none;
    }
    
    .text-controls-combined {
        gap: 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .editable-text {
        padding: 6px 8px;
        border-width: 2px;
        min-width: 40px;
        min-height: 30px;
        background-color: rgba(0, 0, 0, 0.5);
    }
    
    .editable-text:hover {
        transform: none;
    }
    
    .editable-text:active {
        transform: scale(1.15);
        background-color: rgba(0, 0, 0, 0.7);
    }
}

/* Accessibility improvements */
.editable-text:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.template-item:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .text-overlay,
    .button-group {
        display: none !important;
    }
    
    .meme-preview {
        background: white;
    }
}




/* Enhanced dragging styles */
.editable-text-container.dragging {
    transition: none !important;
    opacity: 0.8;
}

.editable-text {
    /* Improved text styling */
    outline: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
    transition: all 0.2s ease;
    font-family: 'Impact', Arial, sans-serif;
    font-weight: bold;
    white-space: nowrap;
    text-transform: uppercase;
    background-color: transparent;
    display: inline-block;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    cursor: move;
}

.editable-text:focus {
    outline: 2px dashed rgba(255, 255, 255, 0.9) !important;
    outline-offset: 2px !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: text !important;
}

.editable-text:hover:not(:focus) {
    outline: 2px dashed rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
    background-color: rgba(0, 0, 0, 0.2);
}

/* Disable user select when dragging */
body.no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}