/* Knowledge Base Specific Styles */

/* ===== KB Index Page Layout ===== */
.iux-kb-index {
    background: #ffffff;
}

.iux-kb-index h1 {
    color: #222;
}

/* Header with search and filters */
.iux-kb-header {
    border-bottom: 1px solid #e1e5e9;
    padding: 2rem 0 1rem;
}

/* Search interface */
.iux-kb-search-section {
    background: #f9f9f9;
    border-bottom: 1px solid #e1e5e9;
}

.iux-kb-search-toolbar {
    margin-bottom: 0;
}

.iux-kb-search-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.iux-kb-search-wrapper {
    display: flex;
    flex: 1;
    min-width: 300px;
    max-width: 500px;
}

.iux-kb-search-input {
    flex: 1;
    border: 1px solid #d5dbdb;
    border-right: none;
    border-radius: 4px 0 0 4px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s ease;
    height: 44px;
}

.iux-kb-search-input:focus {
    outline: none;
    border-color: #0073bb;
    box-shadow: 0 0 0 2px rgba(0, 115, 187, 0.1);
}

.iux-kb-search-button {
    background: #0073bb;
    color: white;
    border: 1px solid #0073bb;
    border-radius: 0 4px 4px 0;
    padding: 0 1rem;
    height: 44px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iux-kb-search-button:hover {
    background: #005a94;
    border-color: #005a94;
}

.iux-kb-filter-select {
    border: 1px solid #d5dbdb;
    border-radius: 4px;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    background: white;
    height: 44px;
    min-width: 200px;
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23666"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.iux-kb-filter-select:focus {
    outline: none;
    border-color: #0073bb;
    box-shadow: 0 0 0 2px rgba(0, 115, 187, 0.1);
}

.iux-kb-results-info {
    color: #5a6c7d;
    font-size: 0.875rem;
    white-space: nowrap;
}

.iux-kb-filters-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.iux-kb-tag-select {
    padding: 0.5rem 1rem;
    border: 1px solid #d5dbdb;
    border-radius: 6px;
    background: #ffffff;
    min-width: 150px;
}

.iux-kb-results-count {
    font-size: 0.875rem;
    color: #5a6c7d;
    font-weight: 500;
}

.iux-kb-articles {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .iux-kb-articles {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1400px) {
    .iux-kb-articles {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.iux-kb-article-item {
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1.5rem;
    background: #ffffff;
    transition: box-shadow 0.2s ease;
}

.iux-kb-article-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #d5dbdb;
}

.iux-kb-article-title {
    color: var(--iux-color-text-default);
    text-decoration: none;
    font-weight: 500;
}

.iux-kb-article-title:hover {
    text-decoration: underline;
}

.iux-kb-official-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #e8f4f8;
    color: #0073bb;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.iux-kb-updated {
    font-size: 0.875rem;
    color: #5a6c7d;
}

.iux-kb-article-summary {
    color: #16191f;
    line-height: 1.5;
}

.iux-kb-article-type {
    font-size: 0.875rem;
    color: #0073bb;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Tag styling  */
.iux-kb-tag, .iux-kb-category-link {
    display: inline-block;
    background: #e8f4f8;
    color: #0073bb;
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.75rem;
    text-decoration: none;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
}

.iux-kb-tag:hover, .iux-kb-category-link:hover {
    background: #0073bb;
    color: white;
}

/* ===== KB Article Page Layout ===== */
.iux-kb-article {
    background: #ffffff;
}

.iux-kb-article-header a {
    color: var(--iux-color-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.iux-kb-article-header a:hover {
    text-decoration: underline;
}

/* Article content styling - relies on UX framework grid */
.iux-kb-article-content h1:first-child {
    margin-top: 0;
}

.iux-kb-article-sidebar {
    background: #f9f9f9;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1.5rem;
    position: sticky;
    top: 80px;
    height: fit-content;
}

.iux-kb-metadata-section {
    margin-bottom: 1.5rem;
}

.iux-kb-metadata-section:last-child {
    margin-bottom: 0;
}

.iux-kb-metadata-section h3 {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #232f3e;
    margin-bottom: 1rem;
    letter-spacing: 0.025em;
}

.iux-kb-metadata-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.iux-kb-metadata-label {
    color: #5a6c7d;
    font-weight: 500;
}

.iux-kb-metadata-value {
    color: #16191f;
    text-align: right;
}

/* Language indicator warning */
.iux-kb-language-indicator {
    background: #fef7e3;
    border: 1px solid #f4c430;
    border-left: 4px solid #f4c430;
    color: #7d6608;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

/* Attachments styling */
.iux-kb-attachments {
    background: #e8f4f8;
    border: 1px solid #0073bb;
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.iux-kb-attachments h4 {
    color: #0073bb;
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 700;
}

.iux-kb-attachment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.iux-kb-attachment-link {
    color: #0073bb;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.iux-kb-attachment-link:hover {
    text-decoration: underline;
}

/* Related articles */
.iux-kb-related-articles {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #e1e5e9;
}

.iux-kb-related-articles h3, 
.iux-kb-related-articles h4 {
    color: var(--iux-color-text-default);
}

.iux-kb-related-article {
    display: block;
    padding: 1rem;
    margin-bottom: 1rem;
    text-decoration: none;
    color: inherit;
}

.iux-kb-related-article:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #d5dbdb;
}

.iux-kb-related-article h4 {
    color: var(--iux-color-text-default);
    margin: 0 0 0.5rem 0;
    font-weight: 500;
}

.iux-kb-related-article h4:hover {
    text-decoration: underline;
}

.iux-kb-related-article p {
    color: #5a6c7d;
    margin: 0;
    line-height: 1.4;
}

/* Empty state */
.iux-kb-empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.iux-kb-empty-icon {
    font-size: 3rem;
    color: #5a6c7d;
    margin-bottom: 1rem;
}

.iux-kb-empty-title {
    color: #232f3e;
    margin-bottom: 0.5rem;
}

.iux-kb-empty-message {
    color: #5a6c7d;
    margin-bottom: 1.5rem;
}

/* Loading and error states */
.iux-kb-loading {
    text-align: center;
    padding: 2rem;
    color: #5a6c7d;
}

.iux-kb-error {
    background: #fdf2f2;
    border: 1px solid #f56565;
    color: #c53030;
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
}

/* Mobile metadata styling */
.iux-kb-mobile-metadata {
    background: #ffffff;
    border-bottom: 1px solid #e1e5e9;
    display: none;
}

.iux-kb-desktop-only {
    display: block;
}

/* Article layout grid */
.iux-kb-article-layout {
    display: grid;
    grid-template-columns: calc(100% - 320px - 2rem) 320px;
    gap: 2rem;
    align-items: start;
}

/* Responsive design */
@media (max-width: 768px) {
    .iux-kb-article-layout {
        display: block;
    }
    
    .iux-kb-desktop-only {
        display: none !important;
    }
    
    .iux-kb-mobile-metadata {
        display: block;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .iux-kb-article-body {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .iux-kb-related-articles {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Override container padding on mobile for full-width content */
    .iux-kb-mobile-metadata .iux-container-center,
    .iux-kb-article-body .iux-container-center,
    .iux-kb-related-articles .iux-container-center {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .iux-kb-mobile-metadata .iux-container-max,
    .iux-kb-article-body .iux-container-max,
    .iux-kb-related-articles .iux-container-max {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Ensure article content itself has minimal padding */
    .iux-kb-article-content {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    .iux-kb-filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .iux-kb-search-input {
        max-width: none;
    }
}

.iux-kb-article-content h1 {
    color: #222;
}

.iux-kb-article-content h1,
.iux-kb-article-content h2,
.iux-kb-article-content h3,
.iux-kb-article-content h4 {
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: var(--iux-color-text-default);
}

.iux-kb-article-content img {
    display: block;
    max-width: 100%;
    height: auto;
    padding: 12px;
    border: 12px solid #ededed;
}

.iux-kb-article-content pre {
    display: block;
    overflow-y: hidden;
    overflow-x: auto;
    background-color: #222;
    color: #efefef;
    padding: 12px;
    border: 8px solid #000;
}

.iux-kb-article-content pre code {
    overflow: hidden;
    display: inline-block;
}


.iux-kb-article-content table {
  border-collapse: collapse;
  width: max(65rem, 100%);
  table-layout: fixed;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
}

.iux-kb-article-content th,
.iux-kb-article-content caption {
  text-align: start;
}

.iux-kb-article-content caption {
  margin-block: 0.75rem;
}

.iux-kb-article-content thead {
  border-block-end: 2px solid;
  background: whitesmoke;
}

.iux-kb-article-content tfoot {
  border-block: 2px solid;
  background: whitesmoke;
}

.iux-kb-article-content th,
.iux-kb-article-content td {
  border: 1px solid lightgrey;
  padding: 0.25rem 0.75rem;
  vertical-align: baseline;
}

.iux-kb-article-content th:first-child {
  position: sticky;
  inset-inline-start: 0;
  border-inline-end: none;
}

.iux-kb-article-content tbody th {
  background: white;
}

.iux-kb-article-content thead th,
.iux-kb-article-content tfoot th {
  background: whitesmoke;
}

.iux-kb-article-content thead th {
  vertical-align: bottom;
}

.iux-kb-article-content td:first-of-type,
.iux-kb-article-content :where(thead, tfoot) th:nth-child(2) {
  border-inline-start: none;
}

.iux-kb-article-content th:first-of-type {
  width: 10rem;
}

.iux-kb-article-content th:first-child::after {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  width: 1px;
  height: 100%;
  background: lightgrey;
}

/* For the shadow: https://adrianroselli.com/2020/01/fixed-table-headers.html */
.iux-kb-article-content div[tabindex="0"][aria-labelledby][role="region"] {
  background:
    linear-gradient(to right, transparent 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
    radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,0.2), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.2), rgba(0,0,0,0)) 0 100%;
  background-repeat: no-repeat;
  background-color: #fff;
  background-size: 4em 100%, 4em 100%, 1.4em 100%, 1.4em 100%;
  background-position: 0 0, 100%, 0 0, 100%;
  background-attachment: local, local, scroll, scroll;
}
