/* Modern Theme for Image Puzzle */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* Root Variables for Consistent Design */
:root {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --danger-color: #f44336;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --game-board-width: 70vw;
    --game-board-height: 70vh;
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Modern Page Layout */
.modern-page {
    background: transparent !important;
}

.modern-page .ui-content {
    background: transparent !important;
    padding: 20px;
}

/* Modern Header */
.modern-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    border: none !important;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.modern-title {
    color: var(--white) !important;
    font-weight: 600;
    font-size: 1.8rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.modern-title i {
    color: var(--accent-color);
    margin-right: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Modern Buttons */
.modern-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
    border: none !important;
    border-radius: var(--border-radius) !important;
    color: var(--white) !important;
    font-weight: 500;
    padding: 12px 24px;
    transition: var(--transition);
    box-shadow: var(--shadow);
    text-transform: none !important;
    font-family: 'Poppins', sans-serif;
}

.modern-btn:hover, .modern-btn:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg) !important;
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color)) !important;
}

.modern-btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color)) !important;
}

.modern-btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color), var(--dark-color)) !important;
}

.modern-btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
}

.modern-btn-help {
    background: linear-gradient(135deg, var(--warning-color), #ff7043) !important;
}

.modern-btn i {
    margin-right: 8px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

.welcome-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    max-width: 500px;
    margin: 0 auto;
}

.puzzle-icon-large {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.welcome-title {
    color: var(--dark-color);
    font-weight: 700;
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.welcome-subtitle {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 30px;
    font-weight: 300;
}

/* Modern Section Titles */
.modern-section-title {
    color: var(--white) !important;
    font-weight: 600;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.modern-section-title i {
    color: var(--accent-color);
    margin-right: 10px;
}

/* Modern Image Grid */
.modern-image-grid {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius);
    padding: 20px;
    margin: 20px 0;
    box-shadow: var(--shadow-lg);
}

.modern-image-list {
    margin: 0 !important;
    border-radius: var(--border-radius) !important;
    box-shadow: none !important;
}

.modern-image-item {
    border: none !important;
    border-radius: var(--border-radius) !important;
    margin-bottom: 15px;
    overflow: hidden;
    position: relative;
    transition: var(--transition);
}

.modern-image-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.modern-image-link {
    text-decoration: none !important;
    border-radius: var(--border-radius) !important;
    overflow: hidden;
    position: relative;
    display: block;
}

.modern-preview-img {
    width: 80px !important;
    height: 80px !important;
    object-fit: cover;
    border-radius: 8px;
    transition: var(--transition);
}

.modern-image-title {
    color: var(--dark-color) !important;
    font-weight: 500;
    font-size: 1rem;
    margin: 0 !important;
}

.image-overlay {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 1.5rem;
    opacity: 0.7;
    transition: var(--transition);
}

.modern-image-item:hover .image-overlay {
    opacity: 1;
    color: var(--accent-color);
}

/* Image Grid Styles */
.image-grid-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 0;
  margin: 0;
}

.image-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.image-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}

.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

.image-title {
  padding: 15px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  text-align: center;
  background: #fff;
}

/* Selected state for image cards */
.image-card.selected {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(74, 144, 226, 0.3);
  border: 3px solid #4a90e2;
}

.image-card.selected .image-title {
  background: #4a90e2;
  color: white;
}

/* Add a subtle animation */
.image-card {
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger the animation for each card */
.image-card:nth-child(1) { animation-delay: 0.1s; }
.image-card:nth-child(2) { animation-delay: 0.2s; }
.image-card:nth-child(3) { animation-delay: 0.3s; }
.image-card:nth-child(4) { animation-delay: 0.4s; }
.image-card:nth-child(5) { animation-delay: 0.5s; }
.image-card:nth-child(6) { animation-delay: 0.6s; }
.image-card:nth-child(7) { animation-delay: 0.7s; }
.image-card:nth-child(8) { animation-delay: 0.8s; }

/* Modern game grid styling */
.modern-game-grid {
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#gridContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 10px;
}

#grid {
    border-collapse: separate;
    border-spacing: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    width: var(--game-board-width);
    height: var(--game-board-height);
}

#grid td {
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
}

#grid td:hover {
    border-color: rgba(102, 126, 234, 0.8);
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#grid td canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

/* Responsive puzzle sizing */
@media (max-width: 768px) {
    #gridContainer {
        padding: 5px;
    }
    
    #grid {
        border-spacing: 1px;
        padding: 4px;
    }
    
    #grid td {
        border-width: 1px;
        border-radius: 4px;
    }
}

@media (max-width: 480px) {
    #gridContainer {
        padding: 2px;
    }
    
    #grid {
        border-spacing: 0.5px;
        padding: 2px;
    }
    
    #grid td {
        border-width: 0.5px;
        border-radius: 2px;
    }
}

/* Game stats responsive styling */
.modern-game-stats {
    font-size: 1rem;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: var(--white);
}

@media (max-width: 480px) {
    .modern-game-stats {
        font-size: 0.8rem;
        gap: 10px;
    }
    
    .stat-item {
        font-size: 0.8rem;
    }
}

/* Loading Animation */
.ui-loader .ui-icon-loading {
    background: none;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Popup/Dialog Styling */
.ui-popup {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow-lg) !important;
    backdrop-filter: blur(10px);
}

.ui-popup .ui-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    color: var(--white) !important;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
}

/* Enhanced Visual Effects */
.modern-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(102, 126, 234, 0.2) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Smooth Transitions for All Interactive Elements */
* {
    transition: var(--transition);
}

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

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--secondary-color));
}