/**
 * components.css - Minimalist Component Library
 * Bento grids, cards, buttons, badges, tables & micro-interactions
 */

@import url('./tokens.css?v=6');

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

@media (prefers-reduced-transparency: reduce) {
    .header {
        background-color: var(--surface);
        backdrop-filter: none;
    }
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 100%;
}

.brand-logo {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    white-space: nowrap;
}

.brand-logo .brand-hk {
    color: var(--brand-green);
}

.brand-logo .brand-computer {
    color: var(--text-primary);
    font-weight: 700;
}

.theme-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.btn-accent {
    background-color: var(--brand-orange);
    color: #FFFFFF;
    border-color: var(--brand-orange);
}

.btn-accent:hover {
    background-color: var(--brand-orange-dark);
    border-color: var(--brand-orange-dark);
    color: #FFFFFF;
}

.cart-icon-btn {
    position: relative;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.cart-icon-btn:hover {
    border-color: var(--brand-green);
    background: var(--surface-hover);
    color: var(--brand-green);
}

.cart-icon-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background-color: var(--brand-orange);
    color: #FFFFFF;
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 700;
    border-radius: var(--radius-pill);
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.account-bar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text-primary);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
    white-space: nowrap;
}

.account-bar-btn:hover,
.account-bar-btn[aria-expanded="true"] {
    border-color: var(--brand-green);
    background: var(--surface-hover);
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-hover);
    padding: 8px;
    z-index: 300;
}

.user-dropdown-menu.open {
    display: block;
}

.dropdown-user-header {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    text-align: left;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.dropdown-item:hover {
    background-color: var(--surface-hover);
    color: var(--brand-green);
}

/* Quick Repair Modal */
.hk-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.hk-modal-backdrop.active {
    display: flex;
}

.hk-modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 24px;
    color: var(--text-primary);
}

.footer {
    border-top: 1px solid var(--border);
    padding: 40px 0 28px;
    background-color: var(--surface);
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 960px) {
    .nav-links {
        gap: 14px;
    }
    .header-inner {
        gap: 10px;
    }
}

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

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

.footer-title {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.footer-links a:hover {
    color: var(--brand-green);
}

.footer-bottom {
    padding-top: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
    list-style: none;
}

.nav-link {
    position: relative;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: var(--font-medium);
    padding: 6px 2px;
    transition: color var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
    color: var(--text-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    border-radius: 2px;
    background: var(--brand-green);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#authNavArea {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

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

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    white-space: nowrap;
}

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

.btn-primary {
    background-color: var(--brand-green, #008B45);
    color: var(--text-inverse);
    border-color: var(--brand-green, #008B45);
}

.btn-primary:hover {
    background-color: var(--brand-green-dark, #006B35);
    border-color: var(--brand-green-dark, #006B35);
    color: var(--text-inverse);
}

.btn-secondary {
    background-color: var(--surface-subtle);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: var(--surface-hover);
    border-color: var(--border-hover);
}

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

.btn-outline:hover {
    border-color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
}

.btn-lg {
    padding: 12px 24px;
    font-size: var(--text-base);
}

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

/* ==========================================================================
   Cards & Bento Grid Architecture
   ========================================================================== */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    border-color: var(--border-hover);
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.bento-col-12 { grid-column: span 12; }
.bento-col-8 { grid-column: span 8; }
.bento-col-6 { grid-column: span 6; }
.bento-col-4 { grid-column: span 4; }
.bento-col-3 { grid-column: span 3; }

@media (max-width: 900px) {
    .bento-col-8, .bento-col-6, .bento-col-4, .bento-col-3 {
        grid-column: span 12;
    }
}

/* Product Card */
.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-image-box {
    aspect-ratio: 16/11;
    background-color: var(--surface-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    position: relative;
}

.product-image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    transition: transform var(--transition-normal);
}

.product-card:hover .product-image-box img {
    transform: scale(1.03);
}

.product-category-tag {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.product-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-footer {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
}

.product-price {
    font-family: var(--font-mono);
    font-weight: var(--font-semibold);
    font-size: var(--text-lg);
    color: var(--text-primary);
}

/* ==========================================================================
   Badges (Muted Pastels)
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: var(--font-semibold);
    border-radius: var(--radius-xs);
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.badge-success {
    background-color: var(--pastel-green);
    color: var(--pastel-green-text);
}

.badge-warning {
    background-color: var(--pastel-yellow);
    color: var(--pastel-yellow-text);
}

.badge-danger {
    background-color: var(--pastel-red);
    color: var(--pastel-red-text);
}

.badge-info {
    background-color: var(--pastel-blue);
    color: var(--pastel-blue-text);
}

/* ==========================================================================
   Form Controls
   ========================================================================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.input, .select, .textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
    outline: none;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 3px var(--brand-green-ring);
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--surface);
}

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

.table th {
    padding: 12px 16px;
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    background-color: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.05em;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

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

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

/* ==========================================================================
   Toast Minimalist Notification
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    max-width: 360px;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    animation: toast-in 200ms var(--ease-out) forwards;
}

.toast-exit {
    animation: toast-out 200ms var(--ease-out) forwards;
}

.toast-icon {
    font-weight: var(--font-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-pill);
    font-size: 11px;
}

.toast-success .toast-icon { background: var(--pastel-green); color: var(--pastel-green-text); }
.toast-error .toast-icon { background: var(--pastel-red); color: var(--pastel-red-text); }
.toast-warning .toast-icon { background: var(--pastel-yellow); color: var(--pastel-yellow-text); }
.toast-info .toast-icon { background: var(--pastel-blue); color: var(--pastel-blue-text); }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--text-secondary);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

.user-menu-wrapper {
    position: relative;
}

.user-avatar-initial {
    width: 24px;
    height: 24px;
    background: var(--brand-green);
    color: #FFFFFF;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 6px 0;
}

.text-danger {
    color: #EF4444 !important;
}
