/* Meme Generator Specific Styles */

/* Option Cards */
.option-card {
    background-color: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.option-card:hover {
    border-color: #d8b4fe;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.option-card.active {
    border-color: #8b5cf6;
    background-color: #faf5ff;
}

.option-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.option-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
}

.option-description {
    color: #4b5563;
    margin-bottom: 1rem;
}

.option-button {
    width: 100%;
    background: linear-gradient(to right, #8b5cf6, #ec4899);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

.option-button:hover {
    background: linear-gradient(to right, #7c3aed, #db2777);
}

/* Template Categories */
.category-btn {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    border: 1px solid #d1d5db;
    color: #374151;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.category-btn:hover {
    border-color: #d8b4fe;
    color: #8b5cf6;
}

.category-btn.active {
    background-color: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

/* Template Grid */
.template-card {
    background-color: white;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: #d8b4fe;
    transform: translateY(-2px);
}

.template-card.selected {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px #e9d5ff;
}

.template-image {
    width: 100%;
    height: 8rem;
    object-fit: cover;
}

.template-info {
    padding: 0.75rem;
}

.template-name {
    font-weight: 600;
    color: #111827;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.template-category {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: capitalize;
}

/* Canvas Container */
.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f9fafb;
    border-radius: 0.75rem;
    padding: 1rem;
    min-height: 400px;
    position: relative;
}

#memeCanvas {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    max-width: 100%;
    max-height: 600px;
    background: white;
}

/* Editor Buttons */
.editor-btn {
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    color: #4b5563;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.editor-btn:hover {
    color: #1f2937;
    border-color: #9ca3af;
    background-color: rgba(0, 0, 0, 0.05);
}

/* Tool Buttons */
.tool-button {
    width: 100%;
    background-color: #f3f4f6;
    color: #1f2937;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

.tool-button:hover {
    background-color: #e5e7eb;
}

.tool-button svg {
    margin-right: 0.5rem;
}

/* Form Controls */
.tool-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: white;
}

.tool-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px #8b5cf6;
    border-color: transparent;
}

.tool-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background-color: white;
}

.tool-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px #8b5cf6;
    border-color: transparent;
}

.tool-color {
    width: 100%;
    height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: none;
    padding: 0;
}

.tool-color::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 6px;
}

.tool-color::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.tool-color::-moz-color-swatch {
    border: none;
    border-radius: 6px;
}

.tool-range {
    width: 100%;
    height: 0.5rem;
    background-color: #e5e7eb;
    border-radius: 0.5rem;
    appearance: none;
    cursor: pointer;
}

.tool-range::-webkit-slider-thumb {
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    background-color: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
}

.tool-range::-moz-range-thumb {
    width: 1.25rem;
    height: 1.25rem;
    background-color: #8b5cf6;
    border-radius: 50%;
    cursor: pointer;
    border: 0;
}

.range-value {
    font-size: 0.875rem;
    color: #4b5563;
    font-weight: 500;
    float: right;
    margin-top: -25px;
}

/* Style Buttons */
.style-btn,
.align-btn {
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    color: #4b5563;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.style-btn:hover,
.align-btn:hover {
    color: #1f2937;
    border-color: #9ca3af;
}

.style-btn.active,
.align-btn.active {
    background-color: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

/* Loading Spinner */
.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid #e5e7eb;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .canvas-container {
        padding: 1rem;
    }

    #memeCanvas {
        max-width: calc(100vw - 2rem);
        max-height: 400px;
    }

    .option-card {
        padding: 1rem;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .template-grid {
        grid-template-columns: 1fr;
    }

    .range-value {
        float: none;
        margin-top: 5px;
        display: block;
    }
}

/* Text Selection Styles */
::selection {
    background-color: rgba(147, 51, 234, 0.2);
}

::-moz-selection {
    background-color: rgba(147, 51, 234, 0.2);
}

/* Focus Styles for Accessibility */
.option-card:focus,
.template-card:focus,
.editor-btn:focus,
.tool-button:focus,
.style-btn:focus,
.align-btn:focus,
.category-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px #8b5cf6, 0 0 0 4px rgba(139, 92, 246, 0.2);
}

/* Custom Scrollbar */
.tools-panel::-webkit-scrollbar {
    width: 6px;
}

.tools-panel::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.tools-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.tools-panel::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Animation for smooth transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-in-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fabric.js Canvas Styles */
.canvas-container .upper-canvas {
    border-radius: 8px !important;
}

.canvas-container .lower-canvas {
    border-radius: 8px !important;
}

/* Template Preview Tooltips */
.template-card[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    margin-bottom: 5px;
}

.template-card[data-tooltip]:hover::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
    z-index: 10;
}

/* High DPI Display Optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .template-image {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Print Styles */
@media print {
    .option-card,
    .template-selection,
    .tools-panel {
        display: none !important;
    }

    .canvas-container {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
