/**
 * Reference Documentation Styles
 *
 * Styles for API and CLI reference documentation pages.
 * Used by api-reference/ and cli-reference/ templates.
 */

/* ============================================
   Unified Reference Documentation Base
   Generic components for all reference types
   ============================================ */

/* Reference Header (replaces .api-header-top, .cli-header-top) */
.reference-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.reference-icon {
    font-size: var(--text-3xl);
    line-height: 1;
    flex-shrink: 0;
}

/* Reference Metadata Box (replaces .api-meta) */
.reference-metadata {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: var(--space-4) 0;
    padding: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.reference-metadata-item {
    display: flex;
    gap: var(--space-2);
    font-size: var(--text-sm);
    line-height: 1.5;
    min-width: 0;
    /* Allow flex item to shrink below content size */
}

.reference-metadata-item strong {
    color: var(--color-text-secondary);
    font-weight: var(--weight-semibold);
    min-width: 60px;
    flex-shrink: 0;
    /* Prevent label from shrinking */
}

.reference-metadata-item code {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--color-bg-code);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    /* Responsive overflow handling - truncate from left */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    /* Truncate from left (shows filename at end) */
    text-align: left;
    min-width: 0;
    /* Allow shrinking */
    flex: 1;
    /* Take available space */
}

/* Ensure text inside still reads left-to-right */
.reference-metadata-item code::before {
    content: '\200E';
    /* Left-to-right mark for proper text rendering */
}

/* Reference Content Wrapper */
/* Base content styles - currently inherits from .docs-content */
/* .reference-content - placeholder for future generic content styles */

/* Type-specific variations (only when needed) */
/* .reference-page--api .reference-icon - placeholder for API-specific icon overrides */
/* .reference-page--cli .reference-icon - placeholder for CLI-specific icon overrides */

/* ============================================
   API Reference Styles
   ============================================ */

.api-reference-container {
    max-width: var(--prose-width);
    margin: 0;
    padding: 0;
}

.api-reference-header {
    margin-bottom: var(--space-8);
    padding: var(--space-8) 0 var(--space-6) 0;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

/* Moved to layouts/page-header.css - use .page-header.page-header--centered.page-header--bordered */

.api-reference-description {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    font-weight: var(--weight-normal);
    line-height: 1.7;
    max-width: 700px;
    margin: 0 auto;
    padding-bottom: var(--space-6);
    letter-spacing: 0.01em;
}

/* API Statistics Bar */
.api-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-12);
    flex-wrap: wrap;
    margin-top: var(--space-8);
    margin-bottom: var(--space-8);
    padding: var(--space-6);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--elevation-low);
}

.api-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.api-stat strong {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--color-primary);
}

.api-stat span {
    font-size: var(--text-sm);
    color: var(--color-text-primary-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* API Modules Section */
.api-modules {
    margin-top: var(--space-8);
}

.api-section {
    margin-bottom: var(--space-12);
}

.api-section-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-border);
}

/* API Items List - Narrow Row Layout */
.api-items-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.api-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius-lg); /* Added rounding (8px) */
    transition: all 0.2s ease;
}

/* Gradient border support */
.api-item.gradient-border,
.api-item.gradient-border-subtle {
    border-bottom: none;
}

.api-item:last-child {
    border-bottom: none;
}

.api-item:hover {
    background: var(--color-bg-secondary);
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1rem - 3px);
}

.api-item-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--color-primary);
    opacity: 0.6;
}

.api-item:hover .api-item-icon {
    opacity: 0.9;
}

.api-item-content {
    flex: 1;
    min-width: 0;
}

.api-item-title {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: 1.2;
}

.api-item-title a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.api-item-title a:hover {
    color: var(--color-primary);
}

.api-item-description {
    display: none;
}

.api-item-meta {
    display: inline-flex;
    margin-left: 0.5rem;
    gap: 0.5rem;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.api-item-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    font-weight: var(--weight-medium);
}

/* Keep old classes for backward compatibility if needed elsewhere */
.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-6);
}

/* Force single column on very small screens */
@media (max-width: 399px) {
    .api-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .api-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
}

.api-module-card {
    background: var(--color-surface);
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--elevation-card);
    transition: all 0.2s ease;
    transform: translateY(0);
}

.api-module-card:hover {
    box-shadow: var(--elevation-high);
    transform: translateY(-4px);
}

.api-module-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.api-module-icon {
    font-size: var(--text-2xl);
    line-height: 1;
}

.api-module-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    line-height: 1.3;
    margin: 0 0 var(--space-3) 0;
}

.api-module-title a {
    color: var(--color-text-primary);
    text-decoration: none;
}

.api-module-title a:hover {
    color: var(--color-primary);
}

.api-module-content {
    margin-top: var(--space-3);
}

.api-module-description {
    font-size: var(--text-base);
    color: var(--color-text-primary-secondary);
    line-height: 1.6;
    margin-top: var(--space-3);
    margin-bottom: var(--space-4);
}

.api-module-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-primary-muted);
}

.api-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.api-meta-item svg {
    flex-shrink: 0;
}

/* Empty State */
.api-empty {
    text-align: center;
    padding: var(--space-12);
    color: var(--color-text-primary-muted);
}

/* ============================================
   API Single Page Styles
   ============================================ */

.api-reference-page .api-header-top {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.api-reference-page .api-page-icon {
    font-size: var(--text-3xl);
    line-height: 1;
}

.api-reference-page h1 {
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.api-reference-page .api-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: var(--space-4) 0;
    padding: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    min-width: 0;
    /* Allow container to shrink */
}

.api-reference-page .api-meta-item {
    display: flex;
    gap: var(--space-2);
    font-size: var(--text-sm);
    line-height: 1.5;
    min-width: 0;
    /* Allow flex item to shrink */
}

.api-reference-page .api-meta-item strong {
    color: var(--color-text-secondary);
    font-weight: var(--weight-semibold);
    min-width: 60px;
    flex-shrink: 0;
    /* Prevent label from shrinking */
}

.api-reference-page .api-meta-item code {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--color-bg-code);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    /* Responsive overflow handling - truncate from left */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    /* Truncate from left (shows filename at end) */
    text-align: left;
    min-width: 0;
    /* Allow shrinking */
    flex: 1;
    /* Take available space */
}

/* Ensure text inside still reads left-to-right */
.api-reference-page .api-meta-item code::before {
    content: '\200E';
    /* Left-to-right mark */
}

/* ============================================
   CLI Reference Styles
   ============================================ */

.cli-reference-container {
    max-width: var(--prose-width);
    margin: 0;
    padding: 0;
}

.cli-reference-header {
    margin-bottom: var(--space-8);
    padding: var(--space-8) 0 var(--space-6) 0;
    border-bottom: 1px solid var(--color-border);
}

/* Moved to layouts/page-header.css - use .page-header.page-header--centered.page-header--bordered */

.cli-reference-description {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    font-weight: var(--weight-normal);
    line-height: 1.7;
    max-width: 700px;
    padding-bottom: var(--space-6);
    letter-spacing: 0.01em;
}

/* CLI Intro Section */
.cli-intro {
    margin-top: var(--space-8);
    margin-bottom: var(--space-8);
    padding: var(--space-6);
    background: var(--color-surface);
    border-radius: var(--radius-md);
}

.cli-intro .prose {
    max-width: 100%;
}

/* CLI Commands Section */
.cli-commands {
    margin-top: var(--space-8);
}

.cli-section {
    margin-bottom: var(--space-12);
}

.cli-section-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-border);
}

/* CLI Items List - Narrow Row Layout */
.cli-items-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cli-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius-lg); /* Added rounding (8px) */
    transition: all 0.2s ease;
}

/* Gradient border support */
.cli-item.gradient-border,
.cli-item.gradient-border-subtle {
    border-bottom: none;
}

.cli-item:last-child {
    border-bottom: none;
}

.cli-item:hover {
    background: var(--color-bg-secondary);
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1rem - 3px);
}

.cli-item-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--color-primary);
    opacity: 0.6;
}

.cli-item:hover .cli-item-icon {
    opacity: 0.9;
}

.cli-item-content {
    flex: 1;
    min-width: 0;
}

.cli-item-title {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: 1.2;
}

.cli-item-title a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.cli-item-title a:hover {
    color: var(--color-primary);
}

.cli-item-description {
    display: none;
}

.cli-item-meta {
    display: inline-flex;
    margin-left: 0.5rem;
    gap: 0.5rem;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.cli-item-meta .meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    font-weight: var(--weight-medium);
}

.cli-item-meta .meta-usage code {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    background: transparent;
    padding: 0;
    color: inherit;
}

/* Keep old classes for backward compatibility if needed elsewhere */
.cli-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-6);
}

@media (max-width: 768px) {
    .cli-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
}

.cli-command-card {
    background: var(--color-surface);
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--elevation-card);
    transition: all 0.2s ease;
    transform: translateY(0);
}

.cli-command-card:hover {
    box-shadow: var(--elevation-high);
    transform: translateY(-4px);
}

.cli-command-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.cli-command-icon {
    font-size: var(--text-xl);
    line-height: 1;
}

.cli-command-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    line-height: 1.3;
    margin: 0 0 var(--space-3) 0;
}

.cli-command-title a {
    color: var(--color-text-primary);
    text-decoration: none;
}

.cli-command-title a:hover {
    color: var(--color-primary);
}

.cli-command-content {
    margin-top: var(--space-3);
}

.cli-command-description {
    font-size: var(--text-base);
    color: var(--color-text-primary-secondary);
    line-height: 1.6;
    margin-top: var(--space-3);
    margin-bottom: var(--space-4);
}

.cli-usage {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    background: var(--color-bg-code);
    color: var(--color-code-text);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    margin: var(--space-3) 0;
    overflow-x: auto;
}

.cli-command-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-primary-muted);
    margin: var(--space-3) 0;
}

.cli-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.cli-command-link {
    display: inline-block;
    margin-top: var(--space-3);
    color: var(--color-primary);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}

.cli-command-link:hover {
    text-decoration: underline;
}

.cli-command-link::after {
    content: ' →';
}

/* CLI Help Section */
.cli-help {
    margin-top: var(--space-12);
    padding: var(--space-6);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.cli-help h2 {
    font-size: var(--type-h2);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-4);
}

.cli-help-content pre {
    margin: 0;
}

/* Empty State */
.cli-empty {
    text-align: center;
    padding: var(--space-12);
    color: var(--color-text-primary-muted);
}

/* ============================================
   CLI Single Page Styles
   ============================================ */

.cli-reference-page .cli-header-top {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.cli-reference-page .cli-page-icon {
    font-size: var(--text-3xl);
    line-height: 1;
}

.cli-reference-page .cli-usage-header {
    margin: var(--space-4) 0;
    padding: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.cli-reference-page .cli-usage-header strong {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-primary-muted);
    margin-bottom: var(--space-2);
}

.cli-reference-page .cli-usage-header pre {
    margin: 0;
    background: var(--color-bg-code);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.cli-reference-page .cli-usage-header code {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--color-code-text);
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {

    .api-module-card:hover,
    .cli-command-card:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

[data-theme="dark"] .api-module-card:hover,
[data-theme="dark"] .cli-command-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ============================================
   RESPONSIVE MOBILE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {

    .api-module-card,
    .cli-command-card {
        padding: var(--space-4);
    }

    .api-reference-header,
    .cli-reference-header {
        margin-bottom: var(--space-6);
        padding: var(--space-6) 0 var(--space-4) 0;
    }

    .api-reference-description,
    .cli-reference-description {
        font-size: var(--text-base);
        padding-bottom: var(--space-4);
    }

    /* Narrow row mobile adjustments */
    .api-item,
    .cli-item {
        padding: 0.75rem 0.75rem;
    }

    .api-item:hover,
    .cli-item:hover {
        padding-left: calc(0.75rem - 3px);
    }
}
