/* iOS-style Design System */
:root {
  --primary-color: #007AFF;
  --secondary-color: #5856D6;
  --success-color: #34C759;
  --warning-color: #FF9500;
  --error-color: #FF3B30;
  --background-color: #F2F2F7;
  --card-background: #FFFFFF;
  --text-primary: #000000;
  --text-secondary: #8E8E93;
  --border-color: #ededed;
  --border-radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100vh;
  overflow: hidden;
}

/* App Title */
.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeInDown 0.6s ease-out;
  padding: 20px;
  background: var(--card-background);
  border-bottom: 1px solid var(--border-color);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.app-icon {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.app-name {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.tagline {
  font-size: 14px;
  font-style: italic;
  font-weight: 400;
  color: var(--text-secondary);
  opacity: 0.8;
  white-space: nowrap;
}

.app-link {
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  color: var(--app-link-color);
}

.app-link:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* Credits Button */
.credits-button {
  margin-left: auto;
  padding: 16px 24px;
  background: var(--card-background);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.credits-button:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.credits-button:active {
  transform: translateY(0);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Main Layout */
.main-layout {
  display: flex;
  height: 100vh;
  margin-top: 80px; /* Account for app title height */
}

/* Control Sidebar */
.control-sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--card-background);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 20px;
  height: calc(100vh - 80px);
  position: relative;
}

/* Custom Scrollbar Styling */
.control-sidebar::-webkit-scrollbar {
  width: 8px;
}

.control-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.control-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.control-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Control Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 20px;
}

/* Control Groups */
.control-group {
  margin-bottom: 0;
  width: 100%;
  animation: fadeInUp 0.3s ease-out;
  animation-fill-mode: both;
}

.control-group:nth-child(1) { animation-delay: 0.1s; }
.control-group:nth-child(2) { animation-delay: 0.2s; }
.control-group:nth-child(3) { animation-delay: 0.3s; }
.control-group:nth-child(4) { animation-delay: 0.4s; }
.control-group:nth-child(5) { animation-delay: 0.5s; }
.control-group:nth-child(6) { animation-delay: 0.6s; }
.control-group:nth-child(7) { animation-delay: 0.7s; }
.control-group:nth-child(8) { animation-delay: 0.8s; }
.control-group:nth-child(9) { animation-delay: 0.9s; }

.control-group:last-child {
  margin-bottom: 0;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 24px;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 16px;
  margin-top: 0;
  animation: fadeInUp 0.3s ease-out 1.0s both;
  justify-content: center;
}

.action-buttons .button {
  min-width: 140px;
}

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

.control-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Input Styles */
input[type="text"] {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: 500;
  background: var(--card-background);
  color: var(--text-primary);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

input[type="text"]:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
  transform: translateY(-1px);
}

input[type="text"]::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

/* Select Wrapper */
.select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--text-secondary);
  pointer-events: none;
  z-index: 1;
}

select {
  width: 100%;
  padding: 16px 20px;
  padding-right: 48px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: 500;
  background: var(--card-background);
  color: var(--text-primary);
  appearance: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

select:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
  transform: translateY(-1px);
}

/* Small Selects for Advanced Options */
.select-wrapper.small select {
  padding: 12px 16px;
  padding-right: 40px;
  font-size: 14px;
}

.select-wrapper.small::after {
  right: 12px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-secondary);
}

/* Color Picker */
.color-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

input[type="color"] {
  width: 100%;
  height: 60px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  background: none;
  padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  border-radius: var(--border-radius);
  border: 2px solid var(--border-color);
}

input[type="color"]::-webkit-color-swatch {
  border-radius: calc(var(--border-radius) - 2px);
  border: none;
}

.color-preview {
  width: 60px;
  height: 60px;
  border-radius: var(--border-radius);
  border: 2px solid var(--border-color);
  background-color: #ffe7bd;
}

/* Color Generate Button */
.color-generate-btn {
  width: 60px;
  height: 60px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-background);
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.color-generate-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

.color-generate-btn:active {
  transform: translateY(0);
}



/* Action Buttons */
.button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.button.primary {
  background: var(--primary-color);
  color: white;
}

.button.primary:hover {
  background: #0056CC;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.button.secondary {
  background: var(--card-background);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.button.secondary:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.button-icon {
  font-size: 18px;
}

/* Canvas */
canvas {
  background: var(--card-background);
  max-width: 100%;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  margin-top: 0;
  align-self: center;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #000000;
    --card-background: #1C1C1E;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --border-color: #38383A;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
    height: auto;
    margin-top: 80px;
  }
  
  .control-sidebar {
    width: 100%;
    min-width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 20px;
  }
  
  .control-panel {
    flex-direction: column;
    gap: 20px;
  }
  
  .main-content {
    padding: 20px;
    min-height: auto;
  }
  
  .action-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .action-buttons .button {
    width: 100%;
    max-width: 300px;
  }
}

@media (max-width: 480px) {
  .app-title {
    padding: 16px;
  }
  
  .control-sidebar {
    padding: 16px;
  }
  
  .main-content {
    padding: 16px;
  }
}

/* Loading State */
body.loading .control-panel,
body.loading .action-buttons,
body.loading canvas {
  display: none;
}

/* Fullscreen State */
body.fullscreen {
  background-color: transparent;
}

body.fullscreen .container {
  display: none;
}

body.fullscreen canvas {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: -1;
  margin: 0;
  border-radius: 0;
  border: none;
}

/* Emoji Input Group */
.emoji-input-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.emoji-input-group input[type="text"] {
  flex: 1;
}

.emoji-generate-btn {
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--card-background);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.emoji-generate-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.15);
}

.emoji-generate-btn:active {
  transform: translateY(0);
}

/* Dice rolling animation */
@keyframes diceRoll {
  0% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(90deg) scale(1.1);
  }
  50% {
    transform: rotate(180deg) scale(0.9);
  }
  75% {
    transform: rotate(270deg) scale(1.1);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes paintbrush {
  0% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.2) rotate(-15deg);
  }
  50% {
    transform: scale(0.8) rotate(15deg);
  }
  75% {
    transform: scale(1.1) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.dice-rolling {
  animation: diceRoll 0.6s ease-in-out;
}

.paintbrush-animation {
  animation: paintbrush 0.6s ease-in-out;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease-out;
}

.modal.show {
  display: block;
}

.modal-content {
  background-color: var(--card-background);
  margin: 5% auto;
  padding: 0;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
  animation: slideInUp 0.3s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  font-weight: 300;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background-color: var(--background-color);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.credits-section {
  margin-bottom: 24px;
}

.credits-section:last-child {
  margin-bottom: 0;
}

.credits-section h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-color);
}

.credits-section p {
  margin: 0 0 8px 0;
  color: var(--text-primary);
  line-height: 1.6;
}

.credits-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-primary);
}

.credits-section li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.credits-section a {
  color: var(--primary-color);
  text-decoration: none;
  transition: all 0.2s ease;
  word-break: break-all;
}

.credits-section a:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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