/* Meme Generator Pro Styles */
:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #1a1a2e;
    --bg-sidebar: #f0f0f0;
    --bg-canvas: #e0e0e0;
    --text-primary: #1a1a2e;
    --text-secondary: #495057;
    --text-light: #6c757d;
    --neon-blue: #00d4ff;
    --neon-blue-hover: #00b8e6;
    --neon-blue-light: #e6f9ff;
    --border-color: #dee2e6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.meme-generator-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header Bar */
.meme-header {
    background: var(--bg-secondary);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--neon-blue);
    z-index: 100;
}

.meme-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.meme-header-title {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
}

.meme-header-subtitle {
    color: var(--neon-blue);
    font-size: 0.85rem;
    font-weight: 500;
}

.meme-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Buttons */
.meme-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.meme-btn-primary {
    background: var(--neon-blue);
    color: var(--text-primary);
}

.meme-btn-primary:hover {
    background: var(--neon-blue-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.meme-btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.meme-btn-outline:hover {
    border-color: var(--neon-blue);
    color: var(--neon-blue);
}

.meme-btn-icon {
    background: transparent;
    color: #ffffff;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.meme-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.meme-btn-full {
    width: 100%;
    justify-content: center;
}

/* Workspace */
.meme-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.meme-sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

.meme-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 5;
}

.meme-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

.meme-tab:hover {
    color: var(--neon-blue);
}

.meme-tab.active {
    color: var(--neon-blue);
    border-bottom-color: var(--neon-blue);
}

.meme-panel {
    display: none;
    padding: 16px;
}

.meme-panel.active {
    display: block;
}

.meme-panel-section {
    margin-bottom: 20px;
}

.meme-panel-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

/* Inputs */
.meme-input, .meme-select, .meme-file-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 8px;
    transition: var(--transition);
    background: #ffffff;
}

.meme-input:focus, .meme-select:focus {
    outline: none;
    border-color: var(--neon-blue);
    box-shadow: 0 0 0 3px var(--neon-blue-light);
}

.meme-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.meme-color-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.meme-color-input {
    width: 40px;
    height: 35px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.meme-range-row {
    margin-bottom: 10px;
}

.meme-range-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

.meme-range {
    width: 100%;
    accent-color: var(--neon-blue);
}

.meme-help-text {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Size inputs */
.meme-size-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.meme-size-inputs span {
    font-weight: 700;
    color: var(--text-secondary);
}

.meme-size-inputs .meme-input {
    flex: 1;
    margin-bottom: 0;
}

/* Preset Grid */
.meme-preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.meme-preset-btn {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.meme-preset-btn:hover {
    border-color: var(--neon-blue);
    background: var(--neon-blue-light);
}

/* Radio Group */
.meme-radio-group {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.meme-radio-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.meme-radio-group input[type="radio"] {
    accent-color: var(--neon-blue);
}

/* Emoji Grid */
.meme-emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.meme-emoji-btn {
    padding: 8px;
    font-size: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    cursor: pointer;
    transition: var(--transition);
}

.meme-emoji-btn:hover {
    border-color: var(--neon-blue);
    transform: scale(1.1);
}

/* Layer List */
.meme-layer-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.meme-layer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.meme-layer-item:hover {
    border-color: var(--neon-blue);
}

.meme-layer-item.active {
    border-color: var(--neon-blue);
    background: var(--neon-blue-light);
}

.meme-layer-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.meme-layer-actions {
    display: flex;
    gap: 4px;
}

.meme-layer-btn {
    padding: 4px 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 3px;
    transition: var(--transition);
}

.meme-layer-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Canvas Container */
.meme-canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-canvas);
    position: relative;
    overflow: hidden;
}

.meme-canvas-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    z-index: 5;
}

#zoomLevel {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 50px;
    text-align: center;
}

.meme-canvas-wrapper {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    touch-action: none;
}

#memeCanvas {
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
}

.meme-canvas-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
}

#canvasDimensions {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
}

/* Modal */
.meme-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.meme-modal.show {
    display: flex;
}

.meme-modal-content {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    text-align: center;
}

.meme-modal-content h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 1.5rem;
}

#downloadPreview {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    margin-bottom: 16px;
}

.meme-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* File Input */
.meme-file-input {
    display: none;
}

/* Scrollbar */
.meme-sidebar::-webkit-scrollbar,
.meme-layer-list::-webkit-scrollbar {
    width: 6px;
}

.meme-sidebar::-webkit-scrollbar-track,
.meme-layer-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.meme-sidebar::-webkit-scrollbar-thumb,
.meme-layer-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.meme-sidebar::-webkit-scrollbar-thumb:hover,
.meme-layer-list::-webkit-scrollbar-thumb:hover {
    background: var(--neon-blue);
}

/* Responsive Design */
@media (max-width: 768px) {
    .meme-header {
        padding: 8px 12px;
    }
    
    .meme-header-title {
        font-size: 1.1rem;
    }
    
    .meme-header-subtitle {
        display: none;
    }
    
    .meme-workspace {
        flex-direction: column;
    }
    
    .meme-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 2px solid var(--border-color);
    }
    
    .meme-tabs {
        font-size: 0.8rem;
    }
    
    .meme-canvas-container {
        flex: 1;
        min-height: 60vh;
    }
    
    .meme-preset-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .meme-modal-content {
        max-width: 95%;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .meme-header-right {
        gap: 4px;
    }
    
    .meme-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .meme-header-right .meme-btn-icon {
        padding: 6px;
    }
    
    .meme-canvas-wrapper {
        padding: 10px;
    }
    
    .meme-emoji-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
    
    .meme-emoji-btn {
        font-size: 1.2rem;
        padding: 6px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.meme-panel.active {
    animation: fadeIn 0.3s ease;
}

/* Loading State */
.meme-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Print Styles */
@media print {
    .meme-header,
    .meme-sidebar,
    .meme-canvas-controls,
    .meme-canvas-info {
        display: none !important;
    }
    
    .meme-canvas-container {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}