/* bohcay components.css — Base components using tokens from theme.css */

/* Buttons */
.btn { 
  display: inline-flex; align-items: center; justify-content: center; 
  font-weight: 500; transition: 150ms; user-select: none; 
  height: 40px; padding: 0 16px; border-radius: var(--radius-md);
  background: var(--color-surface-muted); color: var(--color-text);
  border: 1px solid var(--color-border);
  text-decoration: none ;
}
/* Ensure icon gap regardless of FA version (i>svg, direct svg, or ::before) */
.btn i { margin-right: 8px; }
.btn i svg, .btn svg { margin-right: 0; }
.btn i::before { margin-right: 0; }
.btn:hover { background: var(--color-surface); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--color-focus); }
.btn:disabled { opacity: .6; pointer-events: none; }

.btn-primary { background: var(--color-primary); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--color-primary-600); }
.btn-primary:active { background: var(--color-primary-700); }

.btn-outline { background: transparent; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-outline:hover { background: var(--color-surface-muted); }

.btn-ghost { background: transparent; color: var(--color-text); border-color: transparent; }
.btn-ghost:hover { background: var(--color-surface-muted); }

/* Destructive */
.btn-danger { background: var(--color-danger) ; color: #fff ; border-color: transparent ; }
.btn-danger:hover { background: color-mix(in oklab, var(--color-danger) 92%, black 8%) ; }
.btn-danger:active { background: color-mix(in oklab, var(--color-danger) 88%, black 12%) ; }

/* Global link styling */
a {
  color: var(--color-link, var(--color-primary));
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--color-link, var(--color-primary)) 70%, transparent);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover,
a:focus-visible {
  color: var(--color-link-hover, var(--color-primary-600));
  text-decoration-color: color-mix(in srgb, var(--color-link-hover, var(--color-primary-600)) 90%, transparent);
}

a:visited {
  color: var(--color-link-visited, var(--color-primary-700));
}

/* Cards */
.card { 
  background: var(--color-surface); border: 1px solid var(--color-border); 
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); 
  padding: var(--spacing-card-p);
}
.card--elevated { box-shadow: var(--shadow-lg); }
.card-header { font-weight: 600; margin-bottom: .5rem; color: var(--color-text); }
.card-body { color: var(--color-text-muted); font-size: .95rem; line-height: 1.5; }

/* Inputs */
.input, .select, .textarea {
  width: 100%; background: var(--color-surface-muted); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.input, .select { height: 44px; padding: 0 12px; }
.textarea { min-height: 160px; padding: 10px 12px; }
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; box-shadow: 0 0 0 2px var(--color-focus); }

/* Form components */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: var(--text-color);
}

.form-help {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-error {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--error-color);
}

/* Image components */
.thumb {
  max-width: 200px;
  max-height: 150px;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  object-fit: cover;
}

.featured-image-preview-container {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 16/9;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure preview container is visible when shown */
.featured-image-preview-container[style*="display: block"] {
  display: flex !important;
}

/* Class-based visibility control */
.featured-image-preview-container.show {
  display: flex !important;
}

.featured-image-preview-container.hide {
  display: none !important;
}

.featured-image-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--color-background);
  border-radius: var(--radius-sm);
}

.blog-post-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 16:9 aspect ratio image containers */
.blog-image-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.blog-detail-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--color-surface);
}

.blog-card-image-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.blog-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: stretch;
}

.blog-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
}

.blog-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  height: 100%;
}

.blog-card-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.blog-card-meta i {
  font-size: 0.875rem;
}

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

.blog-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
}

.blog-card-title .nav-link {
  padding: 0;
}

.blog-card-excerpt {
  font-size: 0.875rem;
}

.blog-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: -0.1rem;
  margin-bottom: 0.5rem;
}

.blog-card-cta {
  margin-top: auto;
  align-self: flex-start;
}

@media (min-width: 1200px) {
  .blog-grid {
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}

/* Badges */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 999px; font-size: .75rem; font-weight: 500; background: var(--color-surface-muted); color: var(--color-text); border: 1px solid var(--color-border); }
.badge--success { background: color-mix(in oklab, var(--color-success) 20%, transparent); border-color: var(--color-success); }
.badge--warning { background: color-mix(in oklab, var(--color-warning) 20%, transparent); border-color: var(--color-warning); }
.badge--danger  { background: color-mix(in oklab, var(--color-danger) 20%, transparent);  border-color: var(--color-danger); }

/* Header & Navigation */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 var(--spacing-container-x);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.125rem;
}

.logo:hover {
    color: var(--color-primary);
}

/* Mobile hamburger menu */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--color-text);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Navigation container */
.nav {
    position: relative;
}

.nav-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-menu-overlay {
    display: none;
}

.mobile-menu-header {
    display: none !important;
}

/* Ensure mobile menu header only shows when nav is active on mobile */
@media (min-width: 769px) {
    .mobile-menu-header {
        display: none !important;
    }
}

.nav-items {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.nav-link[aria-current="page"] {
    background: var(--color-surface);
    color: var(--color-text);
}

.nav-link i {
    margin-right: 8px;
}

/* Profile dropdown */
.profile-section {
    margin-left: 16px;
}

.profile-dropdown {
    position: relative;
}

.profile-button {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-button:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.profile-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px 0;
    display: none;
    z-index: 1000;
}

.profile-menu.show {
    display: block;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.profile-menu-item:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.profile-menu-item.text-red-600 {
    color: var(--color-danger);
}

.profile-menu-item.text-red-600:hover {
    background: color-mix(in oklab, var(--color-danger) 10%, transparent);
    color: var(--color-danger);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    /* Show hamburger button on mobile */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Hide desktop navigation on mobile */
    .nav-container {
        display: none;
    }
    
    /* Mobile navigation overlay */
    .nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 999;
        pointer-events: none;
        visibility: hidden;
    }
    
    .nav.active {
        pointer-events: all;
        visibility: visible;
    }
    
    /* Mobile menu overlay background */
    .mobile-menu-overlay {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .nav.active .mobile-menu-overlay {
        opacity: 1;
    }
    
    /* Mobile navigation container - slide in from right */
    .nav.active .nav-container {
        display: flex;
        position: absolute;
        top: 0;
        right: 0;
        width: 280px;
        height: 100%;
        background: var(--color-surface);
        border-left: 1px solid var(--color-border);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0;
        transform: translateX(0);
        transition: transform 0.3s ease;
        overflow-y: auto;
        box-shadow: var(--shadow-lg);
    }
    
    /* Initial state - hidden off screen */
    .nav .nav-container {
        transform: translateX(100%);
    }
    
    /* Mobile menu header */
    .nav.active .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 64px;
        padding: 0 20px;
        border-bottom: 1px solid var(--color-border);
        background: var(--color-surface-muted);
    }
    
    .mobile-menu-title {
        font-weight: 600;
        color: var(--color-text);
    }
    
    .mobile-menu-close {
        width: 40px;
        height: 40px;
        background: none;
        border: none;
        border-radius: var(--radius-sm);
        color: var(--color-text-muted);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }
    
    .mobile-menu-close:hover {
        background: var(--color-surface);
        color: var(--color-text);
    }
    
    /* Mobile navigation items */
    .nav.active .nav-items {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 16px 0;
    }
    
    .nav.active .nav-link {
        display: flex;
        height: 48px;
        padding: 0 20px;
        border-radius: 0;
        justify-content: flex-start;
        align-items: center;
    }
    
    .nav.active .nav-link:hover {
        background: var(--color-surface-muted);
    }
    
    /* Mobile profile section */
    .nav.active .profile-section {
        display: block;
        margin: 16px 0 0 0;
        padding: 16px 0 0 0;
        border-top: 1px solid var(--color-border);
    }
    
    .nav.active .profile-button {
        width: 100%;
        height: 48px;
        padding: 0 20px;
        justify-content: flex-start;
        border-radius: 0;
    }
    
    .nav.active .profile-menu {
        position: static;
        width: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--color-surface-muted);
        margin-top: 0;
    }
    
    .nav.active .profile-menu-item {
        padding: 12px 40px;
    }
}

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--color-surface); border: 1px solid var(--color-border); }
.table th, .table td { padding: 12px 16px; border-top: 1px solid var(--color-border); }
.table thead th { position: sticky; top: 0; background: var(--color-surface); text-align: left; color: var(--color-text-muted); z-index: 1; }

/* Utility helpers mapped to tokens */
.surface { background: var(--color-surface); }
.surface-muted { background: var(--color-surface-muted); }
.text-muted { color: var(--color-text-muted); }
.ring-focus { box-shadow: 0 0 0 2px var(--color-focus); }
.radius-lg { border-radius: var(--radius-lg); }
.shadow-md { box-shadow: var(--shadow-md); }
