/* ============================================================
   TERRYSYSTEM MEDIA STUDIO
   Premium, luxurious design matching terrysystem.skin
   ============================================================ */

:root {
  --dark: #0F2824;
  --dark-light: #1A3B35;
  --dark-lighter: #254D45;
  --gold: #C5A67C;
  --gold-light: #D4BC9A;
  --gold-dark: #A8895F;
  --sand: #F4F1EA;
  --sand-dark: #E8E3D8;
  --white: #FFFFFF;
  --text-primary: #2D2D2D;
  --text-secondary: #6B6B6B;
  --text-light: #999;
  --error: #C0392B;
  --success: #27AE60;
  --card-bg: rgba(255, 255, 255, 0.95);
  --border: rgba(197, 166, 124, 0.2);
}

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

html, body {
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  font-family: 'Manrope', sans-serif;
  background-color: var(--sand);
  color: var(--text-primary);
}

/* ============================================================
   SUBTLE BACKGROUND
   ============================================================ */
.bg-pattern {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(197, 166, 124, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(15, 40, 36, 0.05) 0%, transparent 50%);
}

.bg-glow {
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(197, 166, 124, 0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: glowFloat 20s ease-in-out infinite;
}

@keyframes glowFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-100px, 100px); }
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark-light) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 4px;
  padding: 3.5rem 3rem;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
  animation: cardReveal 0.6s ease;
}

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

.login-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.25em;
  color: var(--dark);
}

.login-tagline {
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 0.25rem;
  font-weight: 500;
}

.login-divider {
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 2rem auto;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-group input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--sand-dark);
  border-radius: 2px;
  font-family: 'Manrope', sans-serif;
  font-size: 0.9rem;
  background: var(--sand);
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s ease;
}

.input-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 166, 124, 0.15);
  background: var(--white);
}

.input-group input::placeholder {
  color: var(--text-light);
}

.login-error {
  color: var(--error);
  font-size: 0.85rem;
  min-height: 1.2rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  padding: 14px 32px;
  border: none;
  border-radius: 2px;
  font-family: 'Manrope', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--white);
  cursor: pointer;
  background: var(--dark);
  position: relative;
  overflow: hidden;
  transition: all 0.4s ease;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(197, 166, 124, 0.3), transparent);
  transition: left 0.6s ease;
}

.btn-primary:hover {
  background: var(--dark-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(15, 40, 36, 0.3);
}

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

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

.btn-secondary {
  padding: 8px 20px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  color: var(--gold-dark);
  font-family: 'Manrope', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-secondary:hover {
  background: var(--gold);
  color: var(--white);
}

.btn-generate {
  width: 100%;
  padding: 16px;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.btn-logout {
  padding: 8px 20px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-family: 'Manrope', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--white);
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: relative;
  padding: 1.2rem 2rem;
  background: var(--dark);
  border-bottom: 1px solid var(--gold);
  z-index: 10;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.header-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--white);
}

.header-subtitle {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}

/* ============================================================
   TAB NAVIGATION
   ============================================================ */
.tab-nav {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  padding: 16px 40px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: 'Manrope', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  color: var(--dark);
  background: rgba(197, 166, 124, 0.05);
}

.tab-btn.active {
  color: var(--dark);
  border-bottom-color: var(--gold);
}

/* ============================================================
   TAB CONTENT
   ============================================================ */
.tab-content {
  display: none;
  padding: 2rem;
  animation: contentFade 0.4s ease;
}

.tab-content.active {
  display: block;
}

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

/* ============================================================
   GENERATOR GRID
   ============================================================ */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .generator-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border-radius: 4px;
  padding: 2rem;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--dark);
  margin-bottom: 0.3rem;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-label .hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-light);
  font-size: 0.75rem;
}

.form-textarea,
.form-input,
.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--sand-dark);
  border-radius: 2px;
  font-family: 'Manrope', sans-serif;
  font-size: 0.9rem;
  background: var(--sand);
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s ease;
  resize: vertical;
}

.form-textarea:focus,
.form-input:focus,
.form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 166, 124, 0.1);
  background: var(--white);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23C5A67C'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* ============================================================
   FILE UPLOAD ZONE
   ============================================================ */
.file-upload-zone {
  position: relative;
  border: 1px dashed var(--gold-light);
  border-radius: 2px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(197, 166, 124, 0.03);
}

.file-upload-zone:hover {
  border-color: var(--gold);
  background: rgba(197, 166, 124, 0.08);
}

.file-upload-zone.drag-over {
  border-color: var(--gold);
  background: rgba(197, 166, 124, 0.12);
  box-shadow: 0 0 20px rgba(197, 166, 124, 0.15);
}

.file-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.file-upload-zone p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.preview-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.preview-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--error);
  color: white;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================================
   PROGRESS & LOADING
   ============================================================ */
.progress-zone {
  text-align: center;
  padding: 3rem 2rem;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.4); }
}

.progress-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  animation: textFade 2s ease-in-out infinite;
}

@keyframes textFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================================
   RESULT DISPLAY
   ============================================================ */
.result-display {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

.empty-state svg {
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.9rem;
}

.result-image {
  max-width: 100%;
  border-radius: 2px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.3s ease;
  animation: resultReveal 0.5s ease;
}

.result-image:hover {
  transform: scale(1.01);
}

.result-video {
  max-width: 100%;
  border-radius: 2px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  animation: resultReveal 0.5s ease;
}

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

.result-text {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(197, 166, 124, 0.08);
  border-radius: 2px;
  border-left: 3px solid var(--gold);
  font-size: 0.85rem;
  color: var(--text-secondary);
  width: 100%;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-action {
  padding: 8px 16px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  color: var(--gold-dark);
  font-family: 'Manrope', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
}

.btn-action:hover {
  background: var(--gold);
  color: var(--white);
}

.last-frame-section {
  margin-top: 1.5rem;
  padding: 1.2rem;
  background: rgba(15, 40, 36, 0.03);
  border-radius: 2px;
  border: 1px solid var(--border);
  text-align: center;
  width: 100%;
}

.last-frame-section h3 {
  font-family: 'Cormorant Garamond', serif;
  color: var(--dark);
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
  font-weight: 500;
}

.last-frame-section img {
  max-width: 200px;
  border-radius: 2px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 0.8rem;
}

.last-frame-section p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ============================================================
   GALLERY
   ============================================================ */
.gallery-card {
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
  background: var(--white);
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  border-color: var(--gold);
}

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

.gallery-item-info {
  padding: 0.7rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-item-type {
  padding: 3px 10px;
  border-radius: 2px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.gallery-item-type.image {
  background: rgba(197, 166, 124, 0.15);
  color: var(--gold-dark);
}

.gallery-item-type.video {
  background: rgba(15, 40, 36, 0.1);
  color: var(--dark);
}

.gallery-item-date {
  font-size: 0.7rem;
  color: var(--text-light);
}

.gallery-item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(192, 57, 43, 0.85);
  color: white;
  border: none;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
}

.gallery-item:hover .gallery-item-delete {
  display: flex;
}

.gallery-item-delete:hover {
  background: var(--error);
  transform: scale(1.1);
}

.gallery-item-startframe {
  position: absolute;
  bottom: 48px;
  left: 8px;
  padding: 4px 10px;
  border-radius: 2px;
  background: var(--gold);
  color: var(--white);
  border: none;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: 'Manrope', sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(197, 166, 124, 0.4);
  transition: all 0.2s ease;
  z-index: 5;
}

.gallery-item:hover .gallery-item-startframe {
  display: flex;
}

.gallery-item-startframe:hover {
  background: var(--gold-dark);
  transform: scale(1.05);
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 40, 36, 0.92);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 2px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--white);
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.lightbox-close:hover {
  background: var(--gold);
  border-color: var(--gold);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
  }

  .header-brand {
    flex-direction: column;
    gap: 0;
  }

  .header-title {
    font-size: 1.2rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .tab-btn {
    padding: 12px 20px;
    font-size: 0.75rem;
  }

  .card {
    padding: 1.2rem;
  }

  .tab-content {
    padding: 1rem;
  }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--sand);
}

::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dark);
}

/* ============================================================
   GENERATING STATE
   ============================================================ */
.generating {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 2px rgba(197, 166, 124, 0.2) !important;
}

/* ============================================================
   USE AS START BTN
   ============================================================ */
.use-as-start-btn {
  padding: 6px 14px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: transparent;
  color: var(--gold-dark);
  font-family: 'Manrope', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 0.5rem;
}

.use-as-start-btn:hover {
  background: var(--gold);
  color: var(--white);
}
