@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');

:root {
  --primary-gradient: radial-gradient(ellipse 168.37% 143.84% at 3.80% 129.80%, #FF0000 0%, #FF8400 100%);
  --secondary-color: #BBBBBB;
  --text-color: black;
  --bg-color: white;
}

* {
  box-sizing: border-box;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Nunito', sans-serif;
}

.app-container {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--primary-gradient);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.app-header {
  height: 15%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.app-logo {
  max-height: 60px;
  width: auto;
}

.app-content {
  flex: 1;
  background: var(--bg-color);
  border-top-left-radius: 30px;
  border-top-right-radius: 30px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  overflow-y: auto;
}

.page-title {
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  margin: 0;
  color: var(--text-color);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  margin-top: auto;
  margin-bottom: 0;
}

.btn {
  width: 100%;
  padding: 1rem;
  border-radius: 45px;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0px 4px 5.5px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease;
  text-align: center;
  text-decoration: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-color);
}

.btn-secondary {
  background: linear-gradient(0deg, #BBBBBB 0%, #BBBBBB 100%), white;
  color: var(--text-color);
}

.sticker-text {
  color: black;
  -webkit-text-stroke: 4px white;
  paint-order: stroke fill;
  filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
}

@media (min-width: 481px) {
  .app-container {
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    height: 90vh;
    margin: 5vh auto;
    border-radius: 30px;
  }
  
  .app-content {
    border-radius: 30px;
    margin-top: -30px;
    padding-top: 40px;
  }
}
/* Modal Styles */
.modal {
  display: none; 
  position: fixed; 
  z-index: 1000; 
  left: 0;
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow: auto; 
  background-color: rgba(0,0,0,0.5); 
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 400px;
  border-radius: 15px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  text-align: center;
}

.modal-content h2 {
    margin-top: 0;
    color: #333;
}

.modal-content input, .modal-content textarea {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: inherit;
}

.modal-content textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
}

.modal-actions button:first-child {
    background-color: #ccc;
    color: #333;
}

.modal-actions button:last-child {
    background-color: #FF8400;
    color: white;
}

/* Meme Creator Styles */
.meme-creator-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

.canvas-container {
  position: relative;
  width: 100%;
  margin: 0 auto;
  border: 2px solid #ddd;
  border-radius: 15px;
  overflow: hidden;
  background: white;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#memeCanvas {
  max-width: 100%;
  height: auto !important;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group label {
  font-weight: 800;
  font-size: 14px;
  color: #333;
}

.control-group input, .control-group select {
  padding: 10px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #f9f9f9;
}

.control-group input:focus, .control-group select:focus {
  outline: none;
  border-color: #FF8400;
}

.button-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.btn-small {
  padding: 0.8rem;
  font-size: 16px;
  border-radius: 15px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  color: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-small:active {
  transform: scale(0.95);
}

.btn-add-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-new-image {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-upload-image {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.btn-download {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.btn-send {
  background: var(--primary-gradient);
  color: black;
}

.btn-back {
  background: #eee;
  color: #333;
  grid-column: span 2;
}

.text-controls {
  background: #f5f5f5;
  padding: 1rem;
  border-radius: 15px;
  border: 1px solid #eee;
}

.color-size-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 15px;
  border: 1px solid #eee;
}

.image-preview img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  border-radius: 8px;
  transition: transform 0.2s;
  border: 2px solid transparent;
}

.image-preview img:hover {
  transform: scale(1.05);
  border-color: #FF8400;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #666;
  grid-column: 1 / -1;
}

/* Gallery Styles */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 20px;
  width: 100%;
}

.gallery-item {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  background: #f0f0f0;
}

.gallery-item img, .gallery-item video {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.back-link {
  display: block;
  text-align: center;
  padding: 10px;
  color: var(--text-color);
  text-decoration: none;
  font-weight: bold;
}

/* Meme Creator Page Styles */
.view-container {
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#selection-view {
  padding: 1.5rem;
  overflow-y: auto;
}

.selection-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-bar {
  width: 100%;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #eee;
  border-radius: 25px;
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  background: #f9f9f9;
}

.search-bar input:focus {
  outline: none;
  border-color: #FF8400;
}

.meme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  width: 100%;
}

.meme-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
  background: #f0f0f0;
}

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

.meme-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#editor-view {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.editor-overlay > * {
  pointer-events: auto;
}

.top-controls {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 100;
}

.side-controls {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 100;
}

.bottom-controls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 100;
}

.icon-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s;
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn .icon {
  font-size: 24px;
}

.icon-btn .label {
  font-size: 10px;
  font-weight: 700;
  color: #333;
}

.btn-round {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s;
}

.btn-round:active {
  transform: scale(0.95);
}

.btn-pill {
  padding: 12px 30px;
  border-radius: 30px;
  background: var(--primary-gradient);
  border: none;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 18px;
  font-weight: 900;
  color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s;
}

.btn-pill:active {
  transform: scale(0.95);
}

.text-edit-overlay {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 15px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

.color-picker-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #ddd;
}

.color-picker-wrapper input[type="color"] {
  width: 60px;
  height: 60px;
  border: none;
  cursor: pointer;
  margin: -10px;
}


/* Spinner for upload */
.spinner {
  border: 3px solid rgba(255, 255, 255, 0.3);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
