/* ==========================================
   NGPhoto74 — Base Styles
   Warm Instagram-like theme
   ========================================== */

/* ------------------------------------------
   CSS Variables
   ------------------------------------------ */
:root {
  --color-bg: #FAF3E0;
  --color-primary: #E76F51;
  --color-secondary: #D4A373;
  --color-text: #2B2D42;
  --color-muted: #8D99AE;
  --color-card: #FFFFFF;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-error: #E76F51;
  --color-success: #2A9D8F;

  --gradient-warm: linear-gradient(135deg, #D4A373, #E76F51);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-pill: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);

  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --header-height: 64px;
  --container-max: 1200px;
}

/* ------------------------------------------
   Reset
   ------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul, ol {
  list-style: none;
}

/* ------------------------------------------
   Layout
   ------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-height);
  height: auto;
  background: var(--color-card);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.site-logo {
  font-size: var(--font-size-xl);
  font-weight: 700;
  background: var(--gradient-warm);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.site-nav a {
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.site-nav a:hover {
  color: var(--color-primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--font-size-sm);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-email {
  color: var(--color-muted);
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.main-content {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

/* ------------------------------------------
   Cards
   ------------------------------------------ */
.card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-xl);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  margin-bottom: var(--space-lg);
}

.card-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.card-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-top: var(--space-xs);
}

/* ------------------------------------------
   Buttons
   ------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  border-radius: var(--radius-pill);
  transition: opacity 0.2s ease, transform 0.15s ease;
  cursor: pointer;
}

.btn:hover {
  opacity: 0.9;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--gradient-warm);
  color: #fff;
}

.btn-secondary {
  background: var(--color-secondary);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
}

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ------------------------------------------
   Forms
   ------------------------------------------ */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(231, 111, 81, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-muted);
}

.form-error {
  margin-top: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--color-error);
}

/* ------------------------------------------
   Grid & Utilities
   ------------------------------------------ */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--color-muted);
}

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

.text-sm {
  font-size: var(--font-size-sm);
}

.text-lg {
  font-size: var(--font-size-lg);
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.hidden {
  display: none !important;
}

.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;
}

/* ------------------------------------------
   Alerts / Messages
   ------------------------------------------ */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-lg);
}

.alert-error {
  background: rgba(231, 111, 81, 0.10);
  color: var(--color-error);
  border: 1px solid rgba(231, 111, 81, 0.20);
}

.alert-success {
  background: rgba(42, 157, 143, 0.10);
  color: var(--color-success);
  border: 1px solid rgba(42, 157, 143, 0.20);
}

/* ------------------------------------------
   Loading / Spinner
   ------------------------------------------ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(231, 111, 81, 0.20);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* ------------------------------------------
   Keyframes
   ------------------------------------------ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.animate-fade-in {
  animation: fadeIn 0.4s ease-out both;
}

.animate-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ------------------------------------------
   Responsive
   ------------------------------------------ */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Bottom navigation (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--color-card);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  padding: var(--space-xs) 0 calc(var(--space-xs) + env(safe-area-inset-bottom));
}

.bottom-nav .container {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  transition: color 0.15s ease;
}

.bottom-nav a.active {
  color: var(--color-primary);
}

.bottom-nav a:hover {
  color: var(--color-primary);
}

.mobile-balance {
  display: none;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-primary);
  margin-left: auto;
}

@media (max-width: 800px) {
  .site-nav {
    display: none !important;
  }

  .bottom-nav {
    display: block;
  }

  .mobile-balance {
    display: flex !important;
  }

  .mobile-balance:empty {
    display: none !important;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .container {
    padding-left: var(--space-md);
    padding-right: var(--space-md);
  }

  .card {
    padding: var(--space-lg);
  }
}

.gpt-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(43, 45, 66, 0.06);
  color: var(--color-muted);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

.gpt-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--color-success);
  border-radius: 50%;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Pricing */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.pricing-card {
  background: var(--color-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pricing-card:hover {
  border-color: var(--color-secondary);
  box-shadow: var(--shadow-md);
}

.pricing-card.featured {
  border-color: var(--color-primary);
  position: relative;
}

.pricing-card.featured::before {
  content: 'Самый популярный';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient-warm);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.pricing-card .price {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
}

.pricing-card .generations {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-primary);
  margin-top: var(--space-sm);
}

.pricing-card .description {
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-top: var(--space-xs);
}

.pricing-card .btn {
  margin-top: var(--space-lg);
  width: 100%;
}

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

@media (max-width: 480px) {
  .site-logo {
    font-size: var(--font-size-lg);
  }

  .site-nav a {
    font-size: var(--font-size-xs);
  }

  .user-info {
    gap: var(--space-xs);
  }

  .user-info .nav-link {
    font-size: var(--font-size-xs);
  }

  .user-info .user-email {
    display: none;
  }

  .btn {
    width: 100%;
  }

  .header-brand {
    gap: var(--space-xs);
  }
}

@media (max-width: 340px) {
  .gpt-badge {
    display: none;
  }
}
