/* Custom CSS for PromptBuilder - Modern Illustration Gallery */

/* Modern Color Scheme - Purple & Blue Gradient Theme */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --surface: #ffffff;
    --surface-hover: #f7fafc;
}

/* Gallery Item Hover Effects */
.gallery-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Image Loading States */
.gallery-image {
    transition: opacity 0.3s ease;
}

.gallery-image.loading {
    opacity: 0.5;
}

.gallery-image.loaded {
    opacity: 1;
}

/* Prompt Text Styling */
.prompt-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tag Styling - Modern Gradient Tags */
.tag {
    background: var(--primary-gradient);
    color: white;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

/* Illustration-specific tag colors */
.tag.anime { background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%); }
.tag.character { background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%); }
.tag.fantasy { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.tag.portrait { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }

/* Copy Button Animation */
.copy-btn {
    transition: all 0.2s ease;
}

.copy-btn:hover {
    transform: scale(1.05);
}

.copy-btn.copied {
    background-color: #10b981 !important;
    color: white !important;
}

/* Modal Animations */
.modal-enter {
    opacity: 0;
    transform: scale(0.9);
}

.modal-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.modal-exit {
    opacity: 1;
    transform: scale(1);
}

.modal-exit-active {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Search Input Focus Effect */
input:focus, select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading Animation */
.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Gallery Grid Masonry Effect */
.masonry-grid {
    column-count: 1;
    column-gap: 1.5rem;
}

@media (min-width: 768px) {
    .masonry-grid {
        column-count: 2;
    }
}

@media (min-width: 1024px) {
    .masonry-grid {
        column-count: 3;
    }
}

@media (min-width: 1280px) {
    .masonry-grid {
        column-count: 4;
    }
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .dark-mode {
        background-color: #1a1a1a;
        color: #e5e5e5;
    }
    
    .dark-mode .bg-white {
        background-color: #2d2d2d;
    }
    
    .dark-mode .text-gray-800 {
        color: #e5e5e5;
    }
    
    .dark-mode .border-gray-300 {
        border-color: #404040;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .gallery-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles for Keyboard Navigation */
button:focus,
a:focus,
input:focus,
select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .gallery-item {
        border: 2px solid #000;
    }
    
    button {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile Responsive Enhancements */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .gallery-item {
        margin-bottom: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    /* Stack modal content vertically on mobile */
    .modal-grid {
        display: block;
    }
    
    .modal-grid > div:first-child {
        margin-bottom: 1.5rem;
    }
    
    /* Adjust search bar layout */
    .search-container {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .search-container > div {
        width: 100%;
    }
    
    /* Admin table responsive */
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-table {
        min-width: 600px;
    }
    
    /* Mobile form adjustments */
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-buttons button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Tablet Responsive */
@media (min-width: 769px) and (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .search-container {
        flex-direction: row;
    }
    
    .search-container .search-input {
        flex: 2;
    }
    
    .search-container .filter-select {
        flex: 1;
        margin-left: 0.5rem;
    }
}

/* Large Screen Optimizations */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .gallery-item:hover {
        transform: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .gallery-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Larger touch targets */
    button, .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
        touch-action: manipulation;
    }
    
    .tag {
        padding: 0.375rem 0.875rem;
        margin: 0.25rem;
    }
    
    /* Touch-friendly interactive elements */
    input, select, textarea {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Prevent text selection on buttons */
    button, .btn, .gallery-item {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* スマホ向けモーダルスクロール最適化 */
    .modal-container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scroll-behavior: smooth;
        touch-action: pan-y;
    }
    
    /* モーダル内のスクロールを確実に有効化 */
    #galleryModal {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }
    
    /* Smooth touch scrolling */
    .modal-content, .overflow-y-auto {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Active states for better touch feedback */
    .gallery-item:active,
    button:active,
    .btn:active {
        opacity: 0.8;
        transition: opacity 0.1s ease;
    }
}

/* Performance Optimizations */
.gallery-image {
    will-change: opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.gallery-item {
    will-change: transform, box-shadow;
    backface-visibility: hidden;
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.skeleton-text:last-child {
    width: 60%;
}

/* Error States */
.error-state {
    text-align: center;
    padding: 2rem;
    color: #6b7280;
}

.error-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #f87171;
}

/* Success States */
.success-state {
    text-align: center;
    padding: 2rem;
    color: #059669;
}

.success-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Improved Focus Management */
.focus-trap {
    position: relative;
}

.focus-trap::before,
.focus-trap::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Better Form Validation Styles */
.form-field.error input,
.form-field.error textarea,
.form-field.error select {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-field.error .error-message {
    display: block;
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.error-message {
    display: none;
}

/* Copy Button Enhanced States */
.copy-success {
    background-color: #10b981 !important;
    color: white !important;
    transform: scale(1.05);
}

.copy-success::after {
    content: ' ✓';
}

/* Image Lazy Loading */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Better Modal Animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
}

.modal.opening {
    animation: modalFadeIn 0.3s ease-out;
}

.modal.closing {
    animation: modalFadeOut 0.3s ease-in;
}

/* Modern PromptBuilder Enhancements */

/* Enhanced Header with Gradient */
.header-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Modern Card Styling */
.modern-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.modern-card:hover {
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

/* Glassmorphism Effect for Modals */
.glassmorphism {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Enhanced Search Bar */
.search-enhanced {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(247, 250, 252, 0.9) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* Modern Button Styles */
.btn-modern {
    position: relative;
    overflow: hidden;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    padding: 12px 24px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-modern:hover::before {
    left: 100%;
}

.btn-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Illustration Gallery Specific Styles */
.illustration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.illustration-card {
    border-radius: 16px;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.illustration-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.15);
}

.illustration-image {
    aspect-ratio: 1;
    object-fit: cover;
    width: 100%;
    transition: transform 0.3s ease;
}

.illustration-card:hover .illustration-image {
    transform: scale(1.05);
}

/* Modern Typography */
.title-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

/* Enhanced Focus States */
.focus-modern:focus {
    outline: none;
    ring: 3px;
    ring-color: rgba(102, 126, 234, 0.3);
    ring-offset: 2px;
    border-color: var(--primary-color);
}

/* Prompt Display Enhancement */
.prompt-display {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    border: 1px solid rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    line-height: 1.6;
    position: relative;
}

.prompt-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 12px 12px 0 0;
}

/* Status Indicators */
.status-public {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-private {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Mobile Optimizations for Modern Design */
@media (max-width: 768px) {
    .illustration-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0.5rem;
    }
    
    .modern-card {
        border-radius: 12px;
    }
    
    .btn-modern {
        padding: 10px 20px;
        font-size: 0.875rem;
    }
    
    /* Mobile-specific gallery adjustments */
    .gallery-item {
        margin-bottom: 0.75rem;
    }
    
    .gallery-item .tag {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Modal mobile optimizations */
    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        border-radius: 12px;
    }
    
    /* Form mobile optimizations */
    .form-mobile input,
    .form-mobile textarea,
    .form-mobile select {
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Table mobile responsive */
    .admin-table-mobile {
        min-width: 600px;
    }
    
    .admin-table-mobile th,
    .admin-table-mobile td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Mobile button adjustments */
    .mobile-btn {
        min-height: 44px;
        min-width: 44px;
        font-size: 0.875rem;
    }
    
    /* Search input mobile */
    .search-mobile {
        padding: 0.75rem 1rem;
        font-size: 16px;
    }
}

/* iPhone specific optimizations */
@media (max-width: 480px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .gallery-item {
        border-radius: 8px;
    }
    
    .modal-content {
        border-radius: 8px;
    }
    
    /* Very small screen adjustments */
    .text-xs-mobile {
        font-size: 0.625rem;
    }
    
    .px-xs-mobile {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Landscape mobile optimizations */
@media (max-height: 600px) and (orientation: landscape) {
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
    :root {
        --surface: #1a202c;
        --surface-hover: #2d3748;
        --text-primary: #f7fafc;
        --text-secondary: #e2e8f0;
    }
    
    .modern-card {
        background: rgba(26, 32, 44, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .prompt-display {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
        color: #e2e8f0;
    }
}