@import url('design-tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* =========================================================
   1. RESET & DOCUMENT BASELINE
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
}

body {
    margin: 0;
    font-family: var(--am-font-sans);
    font-size: var(--am-text-base);
    color: var(--am-text);
    background-color: var(--am-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--am-transition-smooth), color var(--am-transition-smooth);
}

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

a {
    color: var(--am-primary);
    text-decoration: none;
    transition: color var(--am-transition-fast), opacity var(--am-transition-fast);
}

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

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

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

/* =========================================================
   2. ACCESSIBILITY & UTILITIES
   ========================================================= */

:focus-visible {
    outline: none;
    box-shadow: var(--am-focus-ring);
}

.am-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.am-container {
    width: min(calc(100% - 32px), var(--am-container));
    margin-inline: auto;
}

.am-container-narrow {
    width: min(calc(100% - 32px), var(--am-container-narrow));
    margin-inline: auto;
}

.am-container-wide {
    width: min(calc(100% - 32px), var(--am-container-wide));
    margin-inline: auto;
}

.am-main {
    flex: 1 0 auto;
    padding-block: var(--am-space-6) var(--am-space-16);
}

.am-section {
    margin-bottom: var(--am-space-8);
}

.am-eyebrow {
    font-size: var(--am-text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--am-primary);
    display: inline-block;
    margin-bottom: 4px;
}

.am-page-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: var(--am-text);
    line-height: 1.2;
    margin: 0 0 var(--am-space-2) 0;
}

.am-page-description {
    font-size: var(--am-text-base);
    color: var(--am-muted);
    max-width: 680px;
    margin: 0 0 var(--am-space-6) 0;
}

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

/* =========================================================
   3. HEADER & NAVIGATION SHELL
   ========================================================= */

/* Top Utility Bar */
.am-topbar {
    background: var(--am-surface-subtle);
    border-bottom: 1px solid var(--am-border);
    font-size: var(--am-text-xs);
    color: var(--am-muted);
    padding-block: 6px;
}

.am-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--am-space-4);
}

.am-topbar-left {
    display: flex;
    align-items: center;
    gap: var(--am-space-4);
}

.am-topbar-right {
    display: flex;
    align-items: center;
    gap: var(--am-space-3);
}

.am-market-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--am-surface);
    padding: 2px 8px;
    border-radius: var(--am-radius-full);
    border: 1px solid var(--am-border);
    font-weight: 600;
    color: var(--am-text);
}

/* Main Navigation Header */
.am-header {
    background: var(--am-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--am-border);
    position: sticky;
    top: 0;
    z-index: var(--am-z-sticky);
    transition: background-color var(--am-transition-smooth), border-color var(--am-transition-smooth);
}

.am-header-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--am-space-6);
}

.am-brand {
    display: flex;
    align-items: center;
    gap: var(--am-space-2);
    text-decoration: none;
    flex-shrink: 0;
}

.am-brand-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.am-brand-logo-compact {
    display: none;
}

/* Global Search Bar */
.am-header-search {
    flex: 1 1 480px;
    max-width: 540px;
    position: relative;
}

.am-search-form {
    display: flex;
    align-items: center;
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius-full);
    padding: 4px 6px 4px 16px;
    transition: border-color var(--am-transition-fast), box-shadow var(--am-transition-fast);
}

.am-search-form:focus-within {
    border-color: var(--am-primary);
    box-shadow: var(--am-focus-ring);
}

.am-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: var(--am-text-sm);
    color: var(--am-text);
    padding-block: 6px;
}

.am-search-input::placeholder {
    color: var(--am-muted);
}

.am-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--am-radius-full);
    background: var(--am-primary);
    color: var(--am-primary-contrast);
    transition: background var(--am-transition-fast);
}

.am-search-btn:hover {
    background: var(--am-primary-hover);
}

/* Desktop Nav Links & Actions */
.am-nav {
    display: flex;
    align-items: center;
    gap: var(--am-space-4);
}

.am-nav-link {
    font-size: var(--am-text-sm);
    font-weight: 600;
    color: var(--am-text-secondary);
    padding: var(--am-space-2) var(--am-space-3);
    border-radius: var(--am-radius-sm);
    transition: color var(--am-transition-fast), background var(--am-transition-fast);
}

.am-nav-link:hover, .am-nav-link.is-active {
    color: var(--am-primary);
    background: var(--am-primary-subtle);
    text-decoration: none;
}

.am-header-actions {
    display: flex;
    align-items: center;
    gap: var(--am-space-3);
}

.am-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--am-radius-full);
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    color: var(--am-text);
    position: relative;
    transition: background var(--am-transition-fast), border-color var(--am-transition-fast), transform 0.1s ease;
}

.am-icon-btn:hover {
    background: var(--am-surface-subtle);
    border-color: var(--am-border-strong);
    color: var(--am-primary);
    text-decoration: none;
}

.am-icon-btn:active {
    transform: scale(0.95);
}

.am-badge-counter {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: var(--am-radius-full);
    background: var(--am-accent);
    color: var(--am-accent-contrast);
    font-size: 0.7rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--am-surface);
}

/* Theme Switcher Toggle Component */
.am-theme-switch {
    display: inline-flex;
    align-items: center;
    background: var(--am-surface-subtle);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius-full);
    padding: 3px;
    gap: 2px;
}

.am-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--am-radius-full);
    color: var(--am-muted);
    font-size: 0.85rem;
    transition: background var(--am-transition-fast), color var(--am-transition-fast);
}

.am-theme-btn:hover {
    color: var(--am-text);
}

.am-theme-btn.is-active {
    background: var(--am-surface);
    color: var(--am-primary);
    box-shadow: var(--am-shadow-xs);
    font-weight: 700;
}

/* Hamburger Menu Toggle */
.am-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--am-radius-sm);
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    gap: 5px;
    padding: 10px;
}

.am-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--am-text);
    border-radius: 2px;
    transition: transform var(--am-transition-smooth), opacity var(--am-transition-smooth);
}

/* =========================================================
   4. MOBILE NAVIGATION DRAWER & BOTTOM BAR
   ========================================================= */

.am-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--am-z-modal-bg);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--am-transition-smooth), visibility var(--am-transition-smooth);
}

.am-drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

.am-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(85vw, 360px);
    background: var(--am-surface);
    z-index: var(--am-z-modal);
    transform: translateX(-100%);
    transition: transform var(--am-transition-smooth);
    display: flex;
    flex-direction: column;
    box-shadow: var(--am-shadow-xl);
    overflow-y: auto;
}

.am-drawer.is-open {
    transform: translateX(0);
}

.am-drawer-header {
    padding: var(--am-space-4) var(--am-space-5);
    border-bottom: 1px solid var(--am-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.am-drawer-body {
    padding: var(--am-space-4) var(--am-space-5);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--am-space-4);
}

.am-drawer-nav {
    display: flex;
    flex-direction: column;
    gap: var(--am-space-2);
}

.am-drawer-link {
    display: flex;
    align-items: center;
    gap: var(--am-space-3);
    padding: var(--am-space-3) var(--am-space-4);
    border-radius: var(--am-radius);
    color: var(--am-text);
    font-weight: 600;
    font-size: var(--am-text-sm);
    transition: background var(--am-transition-fast), color var(--am-transition-fast);
}

.am-drawer-link:hover, .am-drawer-link.is-active {
    background: var(--am-primary-subtle);
    color: var(--am-primary);
    text-decoration: none;
}

.am-drawer-footer {
    padding: var(--am-space-4) var(--am-space-5);
    border-top: 1px solid var(--am-border);
    background: var(--am-surface-subtle);
}

/* Mobile Sticky Bottom Navigation Bar */
.am-mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--am-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--am-border);
    height: 64px;
    z-index: var(--am-z-fixed);
    padding-inline: var(--am-space-2);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.am-mobile-bottom-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: 100%;
    align-items: center;
}

.am-mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--am-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    gap: 3px;
    position: relative;
    transition: color var(--am-transition-fast);
}

.am-mobile-nav-item:hover, .am-mobile-nav-item.is-active {
    color: var(--am-primary);
    text-decoration: none;
}

.am-mobile-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* =========================================================
   5. CARDS, SURFACES & CONTAINERS
   ========================================================= */

.am-card {
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow-sm);
    transition: box-shadow var(--am-transition-fast), border-color var(--am-transition-fast);
    overflow: hidden;
}

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

.am-card-header {
    padding: var(--am-space-5) var(--am-space-6);
    border-bottom: 1px solid var(--am-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--am-space-4);
}

.am-card-body {
    padding: var(--am-space-6);
}

.am-card-footer {
    padding: var(--am-space-4) var(--am-space-6);
    border-top: 1px solid var(--am-border);
    background: var(--am-surface-subtle);
}

/* =========================================================
   6. BUTTONS & INTERACTION CONTROLS
   ========================================================= */

.am-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--am-space-2);
    min-height: 44px;
    padding: 10px 20px;
    border-radius: var(--am-radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: var(--am-text-sm);
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--am-transition-fast);
    white-space: nowrap;
}

.am-btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

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

.am-btn-primary {
    background: var(--am-primary);
    color: var(--am-primary-contrast);
    box-shadow: var(--am-shadow-xs);
}

.am-btn-primary:hover {
    background: var(--am-primary-hover);
    color: var(--am-primary-contrast);
    box-shadow: var(--am-shadow-sm);
}

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

.am-btn-secondary:hover {
    background: var(--am-secondary-hover);
    color: var(--am-text);
    border-color: var(--am-border-strong);
}

.am-btn-accent {
    background: var(--am-accent);
    color: var(--am-accent-contrast);
    box-shadow: var(--am-shadow-xs);
}

.am-btn-accent:hover {
    background: var(--am-accent-hover);
    color: var(--am-accent-contrast);
}

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

.am-btn-danger:hover {
    background: #912018;
}

.am-btn-sm {
    min-height: 36px;
    padding: 6px 14px;
    font-size: var(--am-text-xs);
}

.am-btn-lg {
    min-height: 52px;
    padding: 14px 28px;
    font-size: var(--am-text-base);
}

.am-btn-block {
    width: 100%;
}

/* =========================================================
   7. FORM INPUTS & LABELS
   ========================================================= */

.am-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--am-space-4);
    align-items: flex-end;
}

.am-form-group, .am-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--am-space-4);
}

.am-label, .am-field label {
    display: block;
    font-size: var(--am-text-sm);
    font-weight: 600;
    color: var(--am-text);
    margin-bottom: 2px;
}

.am-input, .am-select, .am-textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: var(--am-radius-sm);
    border: 1px solid var(--am-border);
    background: var(--am-surface);
    color: var(--am-text);
    font-size: var(--am-text-sm);
    transition: border-color var(--am-transition-fast), box-shadow var(--am-transition-fast), background-color var(--am-transition-fast);
}

.am-textarea {
    min-height: 100px;
    resize: vertical;
}

.am-input:focus, .am-select:focus, .am-textarea:focus {
    border-color: var(--am-primary);
    box-shadow: var(--am-focus-ring);
    outline: none;
}

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

.am-contact-form {
    max-width: 540px;
}

/* =========================================================
   8. RESPONSIVE TABLES & DATA GRIDS
   ========================================================= */

.am-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--am-radius-sm);
}

.am-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--am-text-sm);
    text-align: left;
}

.am-table th {
    padding: var(--am-space-3) var(--am-space-4);
    font-weight: 700;
    color: var(--am-muted);
    font-size: var(--am-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--am-border);
    background: var(--am-surface-subtle);
    white-space: nowrap;
}

.am-table td {
    padding: var(--am-space-4);
    border-bottom: 1px solid var(--am-border);
    color: var(--am-text);
    vertical-align: middle;
}

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

.am-table tr:hover td {
    background: var(--am-surface-subtle);
}

/* =========================================================
   9. STATUS BADGES & ALERTS
   ========================================================= */

.am-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--am-radius-full);
    font-size: var(--am-text-xs);
    font-weight: 700;
    line-height: 1.2;
    text-transform: capitalize;
}

.am-badge-success {
    background: var(--am-success-bg);
    color: var(--am-success);
    border: 1px solid var(--am-success-border);
}

.am-badge-warning {
    background: var(--am-warning-bg);
    color: var(--am-warning);
    border: 1px solid var(--am-warning-border);
}

.am-badge-danger {
    background: var(--am-danger-bg);
    color: var(--am-danger);
    border: 1px solid var(--am-danger-border);
}

.am-badge-info {
    background: var(--am-info-bg);
    color: var(--am-info);
    border: 1px solid var(--am-info-border);
}

.am-alert {
    padding: var(--am-space-4) var(--am-space-5);
    border-radius: var(--am-radius);
    font-size: var(--am-text-sm);
    display: flex;
    align-items: center;
    gap: var(--am-space-3);
    margin-bottom: var(--am-space-6);
}

.am-alert-success {
    background: var(--am-success-bg);
    color: var(--am-success);
    border: 1px solid var(--am-success-border);
}

.am-alert-danger {
    background: var(--am-danger-bg);
    color: var(--am-danger);
    border: 1px solid var(--am-danger-border);
}

.am-alert-warning {
    background: var(--am-warning-bg);
    color: var(--am-warning);
    border: 1px solid var(--am-warning-border);
}

/* =========================================================
   10. PRODUCT CARDS & MARKETPLACE GRID
   ========================================================= */

.am-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--am-space-5);
}

.am-product-card {
    background: var(--am-surface);
    border: 1px solid var(--am-border);
    border-radius: var(--am-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--am-transition-fast), box-shadow var(--am-transition-fast), border-color var(--am-transition-fast);
}

.am-product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--am-shadow-md);
    border-color: var(--am-border-strong);
}

.am-product-media, .am-product-image {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--am-surface-subtle);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.am-product-img, .am-product-image img, .am-product-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--am-transition-smooth);
}

.am-product-card:hover .am-product-img,
.am-product-card:hover .am-product-image img,
.am-product-card:hover .am-product-media img {
    transform: scale(1.04);
}

.am-product-info, .am-product-content {
    padding: var(--am-space-4);
    display: flex;
    flex-direction: column;
    flex: 1;
}

.am-product-title {
    font-size: var(--am-text-base);
    font-weight: 700;
    color: var(--am-text);
    margin: 0 0 var(--am-space-1) 0;
    line-height: 1.3;
}

.am-product-title a {
    color: var(--am-text);
}

.am-product-title a:hover {
    color: var(--am-primary);
}

.am-product-meta {
    font-size: var(--am-text-sm);
    color: var(--am-muted);
    margin: 4px 0;
}

.am-product-price {
    font-size: var(--am-text-lg);
    font-weight: 800;
    color: var(--am-primary);
    font-family: var(--am-font-sans);
    margin-top: auto;
    padding-top: var(--am-space-2);
}

/* Product Detail Specifics */
.am-product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: var(--am-space-8);
    align-items: start;
}

.am-product-detail-media {
    aspect-ratio: 4 / 3;
    border-radius: var(--am-radius);
    background: var(--am-surface-subtle);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.am-product-detail-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.am-product-actions {
    display: flex;
    gap: var(--am-space-3);
    align-items: center;
    margin-top: var(--am-space-4);
    flex-wrap: wrap;
}

/* =========================================================
   11. FOOTER
   ========================================================= */

.am-footer {
    background: var(--am-surface);
    border-top: 1px solid var(--am-border);
    padding-block: var(--am-space-12) var(--am-space-8);
    color: var(--am-text-secondary);
    font-size: var(--am-text-sm);
    margin-top: auto;
}

.am-footer-grid {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: var(--am-space-8);
    margin-bottom: var(--am-space-10);
}

.am-footer-brand p {
    color: var(--am-muted);
    font-size: var(--am-text-sm);
    max-width: 320px;
    margin: var(--am-space-2) 0;
}

.am-footer-title {
    font-size: var(--am-text-sm);
    font-weight: 700;
    color: var(--am-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 var(--am-space-4) 0;
}

.am-footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--am-space-2);
}

.am-footer-links a {
    color: var(--am-muted);
    transition: color var(--am-transition-fast);
}

.am-footer-links a:hover {
    color: var(--am-primary);
    text-decoration: none;
}

.am-footer-bottom {
    border-top: 1px solid var(--am-border);
    padding-top: var(--am-space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--am-muted);
    font-size: var(--am-text-xs);
    flex-wrap: wrap;
    gap: var(--am-space-3);
}

/* =========================================================
   12. RESPONSIVE BREAKPOINTS & MOBILE FIRST STRATEGY
   ========================================================= */

@media (max-width: 1024px) {
    .am-footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--am-space-6);
    }
}

@media (max-width: 768px) {
    .am-topbar {
        display: none;
    }

    .am-header-inner {
        min-height: 60px;
        gap: var(--am-space-3);
    }

    .am-nav, .am-header-search {
        display: none;
    }

    .am-menu-toggle {
        display: flex;
    }

    .am-mobile-bottom-nav {
        display: block;
    }

    .am-main {
        padding-bottom: calc(64px + var(--am-space-8));
    }

    .am-product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--am-space-3);
    }

    .am-product-detail-grid {
        grid-template-columns: 1fr;
        gap: var(--am-space-6);
    }

    .am-footer-grid {
        grid-template-columns: 1fr;
        gap: var(--am-space-6);
    }

    .am-card-body, .am-card-header {
        padding: var(--am-space-4);
    }
}

@media (max-width: 480px) {
    .am-product-grid {
        grid-template-columns: 1fr;
    }

    .am-btn-block-mobile {
        width: 100%;
    }
}
