@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT,WONK@0,9..144,100..900,0..100,0..1;1,9..144,100..900,0..100,0..1&family=Manrope:wght@400;500;600;700&display=swap');
@import 'tokens.css';

/* 
 * Amano UI Global Styles
 * Integrates typography, responsive layouts, components, and helper utilities.
 */

/* ==========================================================================
   Base & Resets
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--amano-font-body);
  color: var(--amano-text);
  background-color: var(--amano-background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

a {
  color: var(--amano-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover, a:focus {
  color: var(--amano-primary-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4, h5, h6, p {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   Layouts & Grids
   ========================================================================== */
.container {
  width: min(100% - 2rem, var(--content-max));
  margin-inline: auto;
  padding: 0 var(--space-4);
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin-inline: calc(var(--space-4) * -0.5);
}

.col {
  flex: 1;
  padding-inline: calc(var(--space-4) * 0.5);
}

/* Grillas Especializadas */
.grid-4 { display: grid; gap: var(--space-6); grid-template-columns: repeat(4, 1fr); }
.grid-3 { display: grid; gap: var(--space-6); grid-template-columns: repeat(3, 1fr); }
.grid-2 { display: grid; gap: var(--space-6); grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* Layout Artisan / Admin con Sidebar */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background-color: var(--amano-surface);
  border-right: 1px solid var(--amano-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: var(--space-6) 0;
}

.sidebar-header {
  padding: 0 var(--space-6) var(--space-6);
  border-bottom: 1px solid var(--amano-border);
  margin-bottom: var(--space-4);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  color: var(--amano-text);
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
}

.sidebar-nav a:hover, .sidebar-nav a:focus, .sidebar-nav a.active {
  background-color: var(--amano-surface-alt);
  color: var(--amano-primary);
}

.dashboard-content {
  flex: 1;
  padding: var(--space-8);
  background-color: var(--amano-background);
  overflow-y: auto;
}

@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--amano-border);
    padding: var(--space-4) 0;
  }
}

/* ==========================================================================
   Navigation (Header Público)
   ========================================================================== */
.site-header {
  background: var(--amano-surface);
  border-bottom: 1px solid var(--amano-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.brand-logo img {
  height: 40px;
  width: auto;
}

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

.main-nav a {
  color: var(--amano-text);
  font-weight: 500;
  font-size: var(--amano-body-size);
}

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

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

@media (max-width: 1024px) {
  .main-nav { display: none; }
}

/* ==========================================================================
   Componentes Específicos
   ========================================================================== */
/* Tarjeta de Producto */
.product-card {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

.product-image {
  aspect-ratio: 4/5;
  width: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  background-color: var(--amano-surface-alt);
  transition: transform 0.3s ease;
}

.product-card:hover .product-image {
  transform: scale(1.02);
}

.product-info {
  padding: var(--space-3) 0 var(--space-2) 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-category {
  font-size: var(--amano-label-size);
  color: var(--amano-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.product-title {
  font-size: var(--amano-body-lg-size);
  font-weight: 600;
  margin-bottom: var(--space-2);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--amano-text);
}

.product-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--amano-text);
  margin-top: auto;
}

/* Tarjeta de Artesano */
.artisan-card {
  text-align: center;
  padding: var(--space-6);
}

.artisan-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto var(--space-4);
  border: 2px solid var(--amano-surface-alt);
}

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

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: var(--space-2);
  color: var(--amano-carbon);
}

.help-text {
  font-size: 0.85rem;
  color: var(--amano-text-muted);
  margin-top: var(--space-1);
}

/* Tablas */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--amano-border);
  background: var(--amano-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th, .table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--amano-border);
}

.table th {
  background-color: var(--amano-surface-alt);
  font-weight: 600;
  color: var(--amano-text);
  font-size: 0.9375rem;
}

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

/* Estados Demo */
.badge-demo {
  background: var(--amano-warning-bg);
  color: var(--amano-warning);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  font-weight: bold;
  text-transform: uppercase;
  margin-left: 8px;
  vertical-align: middle;
}

.coming-soon {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Animaciones */
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

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

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background-color: var(--amano-carbon);
  color: var(--amano-surface);
  padding: var(--space-12) 0 var(--space-6);
  margin-top: auto;
}

.site-footer a {
  color: var(--amano-surface-alt);
}

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

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-8);
}

.footer-title {
  color: var(--amano-surface);
  font-family: var(--amano-font-display);
  font-size: 1.25rem;
  margin-bottom: var(--space-4);
}

.footer-links li {
  margin-bottom: var(--space-2);
}

.footer-bottom {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  font-size: 0.875rem;
  color: var(--amano-text-muted);
}

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

/* ==========================================================================
   Brand Loader & Skeletons (Iteración 2)
   ========================================================================== */

/* Brand Loader Delicado */
.brand-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FFFDF9; /* Fondo marfil */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.brand-loader.loader-exit {
    opacity: 0;
    pointer-events: none;
}

.loader-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
}

.loader-isotipo {
    width: 64px;
    height: 64px;
    animation: rotate-isotipo 1.2s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

.loader-spinner {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--amano-primary);
    border-right-color: var(--amano-secondary);
    opacity: 0.7;
    animation: spin-softly 1s linear infinite;
}

@keyframes spin-softly {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes rotate-isotipo {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .loader-container { width: 64px; height: 64px; }
    .loader-isotipo { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
    .loader-isotipo { animation: none; }
    .loader-spinner { display: none; }
}

.skeleton {
  background: linear-gradient(90deg, var(--amano-border) 25%, var(--amano-surface-alt) 50%, var(--amano-border) 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonLoading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  #brand-loader {
    display: none !important;
  }
  .product-card:hover {
    transform: none;
  }
  .product-card:hover .product-image {
    transform: none;
  }
  .fade-in {
    animation: none;
    opacity: 1;
  }
  .skeleton {
    animation: none;
    background: var(--amano-surface-alt);
  }
}

/* ==========================================================================
   Editorial Navigation & Artisan Profile Tabs (Handmade Reference Style)
   ========================================================================== */
.artisan-profile-tabs {
  display: flex;
  gap: var(--space-8);
  border-bottom: 1px solid var(--amano-border);
  margin-bottom: var(--space-8);
  overflow-x: auto;
}

.artisan-tab-btn {
  background: none;
  border: none;
  padding: var(--space-3) 0;
  font-family: var(--amano-font-body);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--amano-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.artisan-tab-btn:hover,
.artisan-tab-btn.active {
  color: var(--amano-text);
  border-bottom-color: var(--amano-primary);
}

.artisan-tab-content {
  display: none;
}

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