@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Shippori+Mincho:wght@400;500;700&display=swap');

/* --- Modern Custom Design Tokens --- */
:root {
  --font-serif: 'Shippori Mincho', 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Curated Harmonious Palette */
  --bg-cream: hsl(36, 25%, 97%);
  --bg-card: hsla(0, 0%, 100%, 0.85);
  --text-charcoal: hsl(210, 10%, 15%);
  --text-muted: hsl(210, 10%, 45%);
  
  --color-vermilion: hsl(5, 70%, 46%);
  --color-vermilion-glow: hsla(5, 70%, 46%, 0.15);
  --color-gold: hsl(40, 48%, 52%);
  --color-gold-light: hsl(40, 48%, 95%);
  --color-border: hsl(36, 12%, 88%);
  --color-border-focus: hsl(40, 48%, 65%);
  
  --color-success: hsl(140, 50%, 35%);
  --color-success-bg: hsl(140, 50%, 96%);
  --color-error: hsl(5, 75%, 45%);
  --color-error-bg: hsl(5, 75%, 96%);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(43, 38, 30, 0.08);
  --shadow-lg: 0 16px 40px rgba(43, 38, 30, 0.12);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- Base resets & Layout --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-cream);
  color: var(--text-charcoal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Subtle texture background for the washi paper feel */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.025;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(var(--text-charcoal) 0.5px, transparent 0.5px),
                    radial-gradient(var(--text-charcoal) 0.5px, var(--bg-cream) 0.5px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

header {
  padding: 2.5rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
  background-color: transparent;
}

.logo-container {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: var(--transition-smooth);
}

.logo-container:hover {
  transform: translateY(-2px);
}

.logo-img {
  width: 70px;
  height: 70px;
  margin-bottom: 0.75rem;
}

.shop-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--text-charcoal);
}

.shop-subtitle {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem 1.5rem;
}

.container {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.container-wide {
  max-width: 960px;
}

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

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--text-charcoal);
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 2.2rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.6rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.lead {
  font-size: 1.1rem;
  color: var(--text-charcoal);
}

/* --- Forms & Inputs --- */
.form-group {
  margin-bottom: 1.75rem;
  position: relative;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select {
  width: 100%;
  padding: 0.85rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-charcoal);
  background-color: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition-smooth);
}

input:focus,
select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-gold-light);
}

/* Form Helper Hints */
.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.error-message {
  display: none;
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.4rem;
  font-weight: 500;
}

/* Built-in and Fallback Validation support */
input:user-invalid,
input.user-invalid-fallback {
  border-color: var(--color-error);
  background-color: var(--color-error-bg);
}

input:user-invalid + .error-message,
input.user-invalid-fallback + .error-message {
  display: block;
  animation: slideDown 0.25s ease-out;
}

input:user-valid,
input.user-valid-fallback {
  border-color: var(--color-success);
}

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

/* --- Buttons & CTAs --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.8rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary {
  background-color: var(--color-vermilion);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: hsl(5, 70%, 40%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--color-vermilion-glow);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-charcoal);
  border-color: var(--text-charcoal);
}

.btn-secondary:hover {
  background-color: var(--text-charcoal);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-gold {
  background-color: var(--color-gold);
  color: #ffffff;
}

.btn-gold:hover {
  background-color: hsl(40, 48%, 45%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(197, 160, 89, 0.25);
}

.btn-danger {
  background-color: transparent;
  color: var(--color-error);
  border-color: var(--color-error);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background-color: var(--color-error);
  color: #ffffff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* --- Customer Portal Specific Components --- */
.preview-container {
  position: relative;
  background-color: #f0ede8;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 2rem;
  aspect-ratio: 4 / 5;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: var(--transition-smooth);
}

.watermark-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(rgba(255, 255, 255, 0.15) 20%, transparent 80%);
}

.watermark-text {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: rgba(184, 58, 48, 0.12);
  transform: rotate(-30deg);
  text-transform: uppercase;
  white-space: nowrap;
}

.order-metadata {
  background: var(--color-gold-light);
  border-left: 3px solid var(--color-gold);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 2rem;
}

.metadata-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1.5rem;
  font-size: 0.9rem;
}

.metadata-label {
  font-weight: 600;
  color: var(--text-charcoal);
}

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

/* --- Download Items List --- */
.download-list {
  list-style: none;
  margin-bottom: 2rem;
}

.download-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.download-item:hover {
  transform: translateY(-2px);
  border-color: var(--color-border-focus);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.download-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.download-icon {
  font-size: 1.5rem;
  color: var(--color-vermilion);
}

.download-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-charcoal);
}

.download-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.expiry-alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background-color: hsl(40, 70%, 95%);
  border: 1px solid hsl(40, 50%, 85%);
  color: hsl(40, 60%, 25%);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.expiry-alert.expired {
  background-color: var(--color-error-bg);
  border-color: hsl(5, 50%, 85%);
  color: var(--color-error);
}

/* --- Admin Panel Components --- */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1rem;
}

.admin-header h1 {
  margin-bottom: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 350px 1fr;
  }
}

.card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

/* File Upload Dropzone */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  background-color: var(--bg-cream);
  cursor: pointer;
  transition: var(--transition-smooth);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.dropzone.dragover {
  border-color: var(--color-gold);
  background-color: var(--color-gold-light);
}

.dropzone-icon {
  font-size: 2.2rem;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.dropzone.dragover .dropzone-icon {
  color: var(--color-gold);
  transform: scale(1.1);
}

.file-list {
  margin-top: 1rem;
  width: 100%;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
}

.file-item-remove {
  cursor: pointer;
  color: var(--color-error);
  font-weight: bold;
}

/* Order List Table */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

th, td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

th {
  background-color: var(--color-gold-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-charcoal);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--bg-cream);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-active {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.status-expired {
  background-color: var(--color-error-bg);
  color: var(--color-error);
}

.order-actions {
  display: flex;
  gap: 0.5rem;
}

.copy-link-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.copy-link-btn:hover {
  border-color: var(--color-gold);
  color: var(--color-gold);
}

/* Passkey visual trigger */
.passkey-container {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.passkey-text {
  font-family: monospace;
  background-color: var(--bg-cream);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-weight: 600;
  color: var(--color-vermilion);
  min-width: 90px;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
}

.passkey-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  opacity: 0.6;
  transition: var(--transition-smooth);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.passkey-btn:hover {
  opacity: 1;
  background-color: var(--color-gold-light);
}

/* --- Modal Overlay (e.g. Logs) --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
}

.close-modal {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

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

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: #1a1a1a;
  color: #ffffff;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 250px;
  max-width: 380px;
  transform: translateY(20px);
  opacity: 0;
  animation: slideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.toast-error {
  border-left: 4px solid var(--color-error);
}

.toast.toast-success {
  border-left: 4px solid var(--color-success);
}

@keyframes slideIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.fade-out {
  animation: slideOut 0.3s ease-in forwards;
}

@keyframes slideOut {
  to {
    transform: translateY(10px);
    opacity: 0;
  }
}

/* --- Footer --- */
footer {
  padding: 2.5rem 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

footer a {
  color: var(--text-charcoal);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-charcoal);
}

footer a:hover {
  color: var(--color-vermilion);
  border-bottom-color: var(--color-vermilion);
}
