/**
 * MODULE TABS ROW COMPONENT STYLES
 * Version: 2.0.0
 *
 * Universal tabs navigation row for easykawa modules.
 * Uses CSS variables from themes.css for automatic light/dark theme support.
 *
 * Features:
 * - Horizontal tabs navigation
 * - Active state highlighting (background or underline)
 * - Overflow scroll on mobile
 * - Close button support (optional)
 * - Edit button support (optional)
 * - Add tab button support (optional)
 * - Smooth transitions
 * - Works as third row after header-top-row and module-controls-row
 *
 * Usage:
 * <div class="module-tabs-row">
 *   <div class="module-tabs-container">
 *     <div class="module-tab active">
 *       <span class="module-tab-name">Tab 1</span>
 *       <button class="module-tab-edit">✎</button>
 *       <button class="module-tab-close">×</button>
 *     </div>
 *     <div class="module-tab">
 *       <span class="module-tab-name">Tab 2</span>
 *       <button class="module-tab-edit">✎</button>
 *       <button class="module-tab-close">×</button>
 *     </div>
 *     <button class="module-tab-add">+</button>
 *   </div>
 * </div>
 */

/* ========================================
   TABS ROW CONTAINER
   ======================================== */

.module-tabs-row {
    display: flex;
    align-items: center;
    width: 100%;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    padding: 0;
    min-height: 48px;
    overflow-x: auto;
    overflow-y: hidden;
}

.module-tabs-container {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 0.5rem;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary) transparent;
}

.module-tabs-container::-webkit-scrollbar {
    height: 4px;
}

.module-tabs-container::-webkit-scrollbar-track {
    background: transparent;
}

.module-tabs-container::-webkit-scrollbar-thumb {
    background-color: var(--border-secondary);
    border-radius: 2px;
}

.module-tabs-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--border-hover);
}

/* ========================================
   TAB ITEMS
   ======================================== */

.module-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: none;
    border-right: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-normal);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    user-select: none;
    position: relative;
    max-width: 200px;
}

.module-tab:hover {
    background-color: var(--bg-hover);
}

.module-tab.active {
    background-color: var(--brand-primary);
    color: var(--text-inverse);
    font-weight: var(--font-weight-medium);
}

.module-tab:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: -2px;
}

/* ========================================
   TAB NAME
   ======================================== */

.module-tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    font-size: var(--font-size-sm);
}

/* ========================================
   TAB EDIT BUTTON (OPTIONAL)
   ======================================== */

.module-tab-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.125rem 0.25rem;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.module-tab-edit:hover {
    color: var(--brand-primary);
}

.module-tab.active .module-tab-edit {
    color: rgba(255, 255, 255, 0.7);
}

.module-tab.active .module-tab-edit:hover {
    color: var(--text-inverse);
}

/* ========================================
   TAB CLOSE BUTTON (OPTIONAL)
   ======================================== */

/* Tab curve elements (hidden by default, styled in variants) */
.tab-curve-left,
.tab-curve-right {
    display: none;
}

.module-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.125rem 0.25rem;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.module-tab-close:hover {
    color: var(--danger);
}

.module-tab.active .module-tab-close {
    color: rgba(255, 255, 255, 0.7);
}

.module-tab.active .module-tab-close:hover {
    color: var(--text-inverse);
}

/* ========================================
   TAB ADD BUTTON (OPTIONAL)
   ======================================== */

.module-tab-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.5rem;
    margin-left: 0.25rem;
    transition: color var(--transition-base);
    border-radius: 0;
    flex-shrink: 0;
    position: relative;
}

.module-tab-add:hover {
    background-color: transparent;
    color: var(--brand-primary);
}

.module-tab-add:active {
    transform: scale(0.95);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .module-tabs-row {
        min-height: 44px;
    }

    .module-tab {
        padding: 0.5rem 0.625rem;
        font-size: var(--font-size-xs);
    }

    .module-tab-name {
        font-size: var(--font-size-xs);
    }

    .module-tabs-container {
        padding: 0 0.25rem;
    }
}

@media (max-width: 480px) {
    .module-tabs-row {
        min-height: 42px;
    }

    .module-tab {
        padding: 0.5rem 0.875rem;
    }
}

/* ========================================
   DISABLED STATE
   ======================================== */

.module-tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================
   DARK THEME ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .module-tabs-row {
    border-bottom: none;
    box-shadow: none;
}

[data-theme="dark"] .module-tab:hover {
    background-color: var(--bg-tertiary);
}

/* Add light shadow to active tab in dark theme for Chrome style */
[data-theme="dark"] .module-tabs-row .module-tab.active {
    box-shadow: 0px 0px 12px rgba(255, 255, 255, 0.4);
}

/* ========================================
   STYLE VARIANTS (EXPERIMENTAL)
   ======================================== */

/* VARIANT 2: Chrome Style (Rounded Tabs) */
.module-tabs-row {
    background-color: var(--bg-primary);
    border-bottom: none;
}

.module-tabs-row .module-tabs-container {
    gap: 1rem;
    padding: 0.5rem 0.5rem 0;
}

.module-tabs-row .module-tab {
    background: transparent;
    border: none;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    position: relative;
}

/* Vertical separator line between inactive tabs */
.module-tabs-row .module-tab:not(.active):not(:hover)::after {
    content: '';
    position: absolute;
    right: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 1.2em;
    background-color: var(--border-primary);
    border-radius: 2px;
    opacity: 0.4;
    transition: opacity var(--transition-base);
}

/* Hide separator on inactive tab that's directly before active tab */
.module-tabs-row .module-tab:not(.active):not(:hover):has(+ .module-tab.active)::after {
    display: none;
}

/* Separator after Open Diagram button (before first tab) */
.module-tabs-row #openDiagramBtn::after {
    content: '';
    position: absolute;
    right: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 1.2em;
    background-color: var(--border-primary);
    border-radius: 2px;
    opacity: 0.4;
}

/* Hide separator on Open Diagram button when first tab is active */
.module-tabs-row #openDiagramBtn:has(+ .module-tab.active)::after {
    display: none;
}

/* Separator before Add Tab button (only when no tabs exist - directly after Open Diagram) */
.module-tabs-row #openDiagramBtn + .module-tab-add::before {
    content: '';
    position: absolute;
    left: -0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 1.2em;
    background-color: var(--border-primary);
    border-radius: 2px;
    opacity: 0.4;
}

/* Curved corners at bottom for hover and active tabs - SVG WITH FILL */
.module-tabs-row .tab-curve-left,
.module-tabs-row .tab-curve-right {
    display: block;
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 8px;
    pointer-events: none;
    overflow: visible;
}

.module-tabs-row .tab-curve-left {
    left: -8px;
}

.module-tabs-row .tab-curve-right {
    right: -8px;
}

/* Fill color for curve paths */
.module-tabs-row .tab-curve-fill {
    fill: var(--bg-tertiary);
}

.module-tabs-row .module-tab:hover .tab-curve-fill {
    fill: var(--bg-tertiary);
}

.module-tabs-row .module-tab.active .tab-curve-fill {
    fill: var(--bg-primary);
}

.module-tabs-row .module-tab:hover {
    background-color: var(--bg-tertiary);
    transition: color var(--transition-base), opacity var(--transition-base);
}

.module-tabs-row .module-tab.active {
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1;
    transition: color var(--transition-base), opacity var(--transition-base);
}

.module-tabs-row .module-tab.active .module-tab-edit,
.module-tabs-row .module-tab.active .module-tab-close {
    color: var(--text-secondary);
}

.module-tabs-row .module-tab.active .module-tab-edit:hover {
    color: var(--brand-primary);
}

.module-tabs-row .module-tab.active .module-tab-close:hover {
    color: var(--danger);
}