/*
 * Copyright 2026 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* ==========================================================================
   GOOGLE MATERIAL 3 (GM3) LIGHT THEME DESIGN TOKENS
   ========================================================================== */
:root {
    --font-primary: 'Inter', -apple-system, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-code: 'Fira Code', monospace;

    /* GM3 Light Palette */
    --bg-app: #f8f9fa;             /* Surface Container Lowest */
    --bg-card: #ffffff;            /* Surface */
    --bg-card-hover: #f1f3f4;      /* Surface Container Low */
    --border-m3: #dadce0;          /* Outline Variant */
    
    /* Brand Colors */
    --color-primary: #0b57d0;      /* Primary Blue */
    --color-primary-text: #0b57d0;
    --color-primary-container: #e8f0fe;
    
    /* Neutral Text Colors */
    --color-text-main: #1f1f1f;    /* On Surface */
    --color-text-muted: #5f6368;   /* On Surface Variant */
    --color-text-white: #ffffff;
    --color-text-dark: #1f1f1f;

    /* Status & Alerts */
    --color-success: #137333;      /* On Positive Container */
    --color-success-bg: #e6f4ea;   /* Positive Container */
    --color-warning: #b06000;      /* On Warning Container */
    --color-warning-bg: #fef7e0;   /* Warning Container */
    --color-danger: #c5221f;       /* On Critical Container */
    --color-danger-bg: #fce8e6;    /* Critical Container */

    /* Elevation Shadows */
    --shadow-card: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    --shadow-btn-hover: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
    --shadow-active: 0 2px 6px 2px rgba(60,64,67,0.15);
}

/* ==========================================================================
   RESET & BASE STYLING
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-app);
    color: var(--color-text-main);
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 24px;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-m3);
    flex-wrap: wrap;
    gap: 16px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.package-name-highlight {
    font-family: var(--font-code);
    font-size: 11px;
    color: var(--color-primary);
    background-color: var(--color-primary-container);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid rgba(11, 87, 208, 0.15);
    margin-left: 8px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    color: var(--color-primary);
}

.logo-icon-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 500;
    color: var(--color-text-main);
    letter-spacing: -0.25px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
}

.accent-text {
    color: var(--color-primary);
    font-weight: 600;
}

.app-grid {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

.right-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    overflow-y: hidden;
}

/* ==========================================================================
   MATERIAL CARDS (ELEVATED SURFACE)
   ========================================================================== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-m3);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s ease;
}

.glass-card:hover {
    box-shadow: 0 1px 3px 1px rgba(60,64,67,0.2), 0 2px 8px 2px rgba(60,64,67,0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

h2 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text-main);
    letter-spacing: 0.15px;
}

/* ==========================================================================
   BUTTONS STYLING (GM3 ROUNDED PILLS)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: 100px; /* GM3 Pill Button */
    font-family: var(--font-primary);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    white-space: nowrap;
    outline: none;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-text-white);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-btn-hover);
    background-color: #044dc4; /* Darker Blue */
}

.btn-primary:active:not(:disabled) {
    box-shadow: var(--shadow-active);
    background-color: #033fa2;
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--color-primary);
    border: 1px solid var(--border-m3);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--color-primary-container);
    border-color: #747775;
}

.btn-gray {
    background-color: #f1f3f4;
    color: #1f1f1f;
    border: 1px solid var(--border-m3);
}

.btn-gray:hover:not(:disabled) {
    background-color: #e1e3e4;
    border-color: #c4c7c5;
}

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

.btn-outline:hover:not(:disabled) {
    background-color: var(--color-primary-container);
}

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

.btn-ghost:hover:not(:disabled) {
    color: var(--color-text-main);
    background-color: rgba(0, 0, 0, 0.04);
}

.btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    box-shadow: none !important;
    background-color: rgba(31, 31, 31, 0.12) !important;
    color: rgba(31, 31, 31, 0.38) !important;
    border-color: transparent !important;
}

.btn-icon {
    padding: 6px;
    border-radius: 50%;
    color: var(--color-text-muted);
    background: transparent;
}

.btn-icon:hover {
    color: var(--color-text-main);
    background-color: rgba(0, 0, 0, 0.04);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon-svg {
    width: 16px;
    height: 16px;
}

.btn-xs {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ==========================================================================
   FORM CONTROLS & INPUTS
   ========================================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

input[type="text"], input[type="number"], textarea {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid #747775;
    border-radius: 4px;
    color: var(--color-text-main);
    padding: 10px 14px;
    font-family: var(--font-primary);
    font-size: 14px;
    transition: border-color 0.15s ease;
}

input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    border-width: 2px;
    padding: 9px 13px; /* account for border thickness */
}

textarea {
    min-height: 100px;
    font-family: var(--font-code);
    font-size: 12px;
    resize: vertical;
}

.text-or {
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: center;
    margin: 8px 0;
}

.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-name {
    font-size: 13px;
    color: var(--color-text-muted);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.checkbox-label {
    font-size: 13.5px;
    color: var(--color-text-main);
}

.hidden-input {
    display: none;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Toggle Switch (Material 3 Slider) */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    flex-shrink: 0;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #aeaeae;
    transition: .2s ease;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--bg-card);
    transition: .2s ease;
}

input:checked + .slider {
    background-color: var(--color-primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ==========================================================================
   CONFIG SUMMARY CARD
   ========================================================================== */
.config-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-m3);
}

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

.summary-item .label {
    color: var(--color-text-muted);
    font-size: 13px;
}

.summary-item .value {
    font-weight: 500;
    font-size: 13px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   STATUS INDICATORS (GOOGLE CHIP BADGES)
   ========================================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: #f1f3f4;
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border-m3);
    flex-shrink: 0;
    white-space: nowrap;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-warning);
}

.status-badge.connected .indicator {
    background-color: var(--color-success);
}

.status-badge.mock .indicator {
    background-color: var(--color-primary);
}

.status-badge.error .indicator {
    background-color: var(--color-danger);
}

.status-badge.warning .indicator {
    background-color: var(--color-warning);
}

.badge-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-main);
    letter-spacing: 0.25px;
}

/* ==========================================================================
   DASHBOARD METRICS
   ========================================================================== */
.stats-card h2 {
    margin-bottom: 12px;
}

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

.stat-box {
    background-color: #f8f9fa;
    border: 1px solid var(--border-m3);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 2px;
    color: var(--color-text-main);
}

.stat-val.accent {
    color: var(--color-warning);
}

.stat-box.success .stat-val {
    color: var(--color-success);
}

.stat-lbl {
    font-size: 10px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================================================
   CONSOLE TERMINAL (LIGHT WEIGHTED LOGS)
   ========================================================================== */
.console-card {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 180px;
}

.console-terminal {
    flex-grow: 1;
    background-color: #f1f3f4;
    border-radius: 8px;
    border: 1px solid var(--border-m3);
    padding: 12px;
    font-family: var(--font-code);
    font-size: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.term-line {
    color: #3c4043;
}

.term-line.system {
    color: var(--color-primary);
}

.term-line.success {
    color: var(--color-success);
}

.term-line.error {
    color: var(--color-danger);
}

.term-line.warning {
    color: var(--color-warning);
}

/* ==========================================================================
   PRODUCTS TABLE COMPONENT
   ========================================================================== */
.table-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
}

.table-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.badge {
    background-color: #e8f0fe;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-primary);
}

.actions-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.selection-count-label {
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    min-height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.selection-count-label.hidden {
    display: inline-flex !important;
    visibility: hidden;
}

.selection-count-label.danger {
    color: var(--color-danger);
    font-weight: 600;
}


.table-responsive {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border-m3);
    background-color: #ffffff;
    min-height: 0;
    width: 100%;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.products-table th, .products-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-m3);
    color: var(--color-text-main);
}

.products-table th {
    font-family: var(--font-primary);
    font-weight: 600;
    color: var(--color-text-muted);
    background-color: #f8f9fa; /* Light sticky header */
    position: sticky;
    top: 0;
    z-index: 10;
}

.col-check { width: 40px; text-align: center; flex-shrink: 0; }
.col-id { width: 220px; font-family: var(--font-code); font-size: 12px; }
.col-title { font-weight: 400; }
.col-price { width: 120px; }
.col-status { width: 100px; }
.col-action { width: 120px; text-align: right; }

.products-table tbody tr {
    transition: background-color 0.1s ease;
}

.products-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Material Checkbox */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    margin: 0;
    font: inherit;
    color: var(--color-primary);
    width: 16px;
    height: 16px;
    border: 2px solid #747775;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
    box-sizing: border-box;
}

input[type="checkbox"]::before {
    content: "";
    width: 10px;
    height: 10px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--color-primary);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked {
    border-color: var(--color-primary);
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

/* M3 Chips for status tags */
.status-pill {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    background-color: #e8eaed;
    color: var(--color-text-muted);
}

.status-pill.active,
.status-pill.active_published,
.status-pill.published {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.status-pill.inactive,
.status-pill.inactive_published,
.status-pill.inactive_draft {
    background-color: #f1f3f4;
    color: var(--color-text-muted);
    border: 1px solid var(--border-m3);
}

.status-pill.draft,
.status-pill.pending {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

/* Loading Placeholder inside Table */
.loading-placeholder {
    text-align: center;
    padding: 60px 0 !important;
    color: var(--color-text-muted);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e8f0fe;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(11, 87, 208, 0.15);
    border-top-color: var(--color-primary) !important;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

#saveConfigBtn {
    min-width: 135px;
}
/* ==========================================
   PROGRESS BAR COMPONENT
   ========================================== */
.progress-bar-container {
    background-color: #e8f0fe;
    border: 1px solid var(--border-m3);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    animation: slideDown 0.2s ease;
}

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

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 6px;
}

.progress-message {
    color: #1f1f1f;
    font-weight: 500;
}

.progress-percent {
    font-family: var(--font-code);
    color: var(--color-primary);
    font-weight: 600;
}

.progress-track {
    height: 4px;
    background: rgba(11, 87, 208, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--color-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ==========================================================================
   PAGINATION BAR & SELECTION BAR STYLES
   ========================================================================== */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border-m3);
    font-size: 13px;
    color: var(--color-text-muted);
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-selector select {
    background-color: var(--bg-card);
    border: 1px solid var(--border-m3);
    border-radius: 4px;
    color: var(--color-text-main);
    padding: 4px 8px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.page-size-selector select:focus {
    border-color: var(--color-primary);
}

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

.page-info {
    font-family: var(--font-code);
    padding: 0 4px;
    min-width: 80px;
    text-align: center;
}

.selection-status {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.highlight-count {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 14px;
}

.accent-text-purple {
    color: #6200ee;
    font-weight: 600;
}

/* Custom Scrollbars for table body */
.table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: transparent;
}
.table-responsive::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   SEGMENTED TAB SELECTION CONTROL (MATERIAL 3 CHIPS CONTAINER)
   ========================================================================== */
.tabs-container {
    display: inline-flex;
    background-color: #f1f3f4;
    border-radius: 100px;
    padding: 4px;
    align-self: flex-start;
    margin-bottom: 4px;
    border: 1px solid var(--border-m3);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    padding: 8px 18px;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    outline: none;
    white-space: nowrap;
}

.tab-lbl-short {
    display: none;
}

.tab-btn:hover {
    color: var(--color-text-main);
    background-color: rgba(0, 0, 0, 0.04);
}

.tab-btn.active {
    background-color: var(--bg-card);
    color: var(--color-primary);
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.3);
}

.tab-btn .badge {
    background-color: #f1f3f4;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--color-text-muted);
    transition: all 0.2s ease;
}

.tab-btn.active .badge {
    background-color: var(--color-primary-container);
    color: var(--color-primary);
}

/* ==========================================================================
   MODALS (MATERIAL 3 DIALOG)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(31, 31, 31, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.glass-modal {
    background-color: var(--bg-card);
    border: 1px solid var(--border-m3);
    border-radius: 28px; /* M3 Standard Dialog Corner Radius */
    width: 100%;
    max-width: 560px;
    box-shadow: 0 24px 38px 3px rgba(0,0,0,0.14), 0 9px 46px 8px rgba(0,0,0,0.12), 0 11px 15px -7px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: modalIn 0.2s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px 24px;
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 18px;
    color: var(--color-text-main);
}

.modal-body {
    padding: 0 24px 24px 24px;
    overflow-y: auto;
    font-size: 14px;
}

.close-modal-btn {
    color: var(--color-text-muted);
}

.close-modal-btn:hover {
    color: var(--color-text-main);
}

/* JSON Viewer in Dialog */
.json-viewer {
    background-color: #f1f3f4;
    border-radius: 8px;
    padding: 14px;
    font-family: var(--font-code);
    font-size: 11.5px;
    overflow-x: auto;
    white-space: pre-wrap;
    max-height: 380px;
    border: 1px solid var(--border-m3);
    color: #202124;
}

.highlight-added {
    background-color: rgba(19, 115, 51, 0.12);
    color: var(--color-success);
    font-weight: 600;
    border-radius: 4px;
    padding: 1px 4px;
}

/* ==========================================================================
   TABS AND DETAILS COLUMN UPDATES
   ========================================================================== */
.top-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

.col-details {
    width: 130px;
    text-align: left;
}

/* ==========================================================================
   SEARCH FILTER & TAB TOTAL LABELS
   ========================================================================== */
.search-filter-wrapper {
    display: flex;
    align-items: center;
}

input[type="text"].table-search-input {
    background-color: #f1f3f4;
    border: 1px solid var(--border-m3);
    border-radius: 100px;
    padding: 8px 18px;
    font-size: 13px;
    width: 260px;
    outline: none;
    transition: all 0.15s ease;
    color: var(--color-text-main);
}

input[type="text"].table-search-input:focus {
    border-color: var(--color-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 1px var(--color-primary);
}

.tab-divider {
    width: 1px;
    height: 18px;
    background-color: var(--border-m3);
    margin: 0 8px;
    align-self: center;
}

.tab-total-label {
    display: flex;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    padding: 0 12px 0 4px;
    user-select: none;
}

.tab-total-label span {
    font-weight: 600;
    color: var(--color-primary);
    margin-left: 4px;
}

/* Grayed out disabled cards in mock mode */
.config-card.disabled-card {
    opacity: 0.5;
    pointer-events: none;
    background-color: #f1f3f4 !important;
}
.config-card.disabled-card * {
    cursor: not-allowed;
}

/* Spin animation for refresh arrow */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinning svg {
    animation: spin 0.8s linear infinite;
}

/* Card Loading Overlay Styles */
.table-card {
    position: relative;
}

.card-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    backdrop-filter: blur(1px);
}

.table-card.loading-state .card-loading-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================================
   API CONFIGURATION MODAL STYLES
   ========================================================================== */
.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.config-modal-card {
    width: 480px;
    max-width: 90%;
    background-color: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-m3);
    box-shadow: var(--shadow-btn-hover);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.config-modal-card .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-m3);
    padding-bottom: 12px;
    margin-bottom: 4px;
}

.config-modal-card .modal-header h2 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-main);
    margin: 0;
}

/* ==========================================================================
   AUTH HELPER & CODE SNIPPET STYLES
   ========================================================================== */
.segmented-control {
    display: flex;
    background-color: #f1f3f4;
    border-radius: 24px;
    padding: 3px;
    margin-top: 6px;
    margin-bottom: 16px;
    border: 1px solid var(--border-m3);
}

.segment-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.15s ease;
    text-align: center;
    outline: none;
}

.segment-btn:hover {
    color: var(--color-text-main);
}

.segment-btn.active {
    background-color: #ffffff;
    color: var(--color-primary);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15), 0 1px 2px rgba(60, 64, 67, 0.1);
}

.auth-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
    height: 210px;
}


.auth-panel.hidden {
    display: none !important;
}

.auth-panel-desc {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: 2px;
}

.terminal-code-block {
    display: flex;
    align-items: center;
    background-color: #0f172a;
    border-radius: 8px;
    padding: 10px 14px;
    position: relative;
    border: 1px solid #1e293b;
}

.terminal-code-text {
    font-family: var(--font-code);
    font-size: 11px;
    color: #38bdf8;
    flex-grow: 1;
    word-break: break-all;
    padding-right: 32px;
    line-height: 1.5;
}

.terminal-copy-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #94a3b8;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
}

.terminal-copy-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

.terminal-copy-btn:active {
    background-color: rgba(255, 255, 255, 0.15);
}

.auth-panel textarea {
    width: 100%;
    flex: 1;
    font-family: var(--font-code);
    font-size: 11px;
    padding: 10px 12px;
    border: 1px solid #747775;
    border-radius: 6px;
    background-color: #ffffff;
    color: var(--color-text-main);
    resize: none;
    outline: none;
    transition: border-color 0.15s ease;
}

.auth-panel textarea:focus {
    border-color: var(--color-primary);
    border-width: 2px;
    padding: 9px 11px;
}

/* Migrate buttons fixed widths to prevent shrinkage during loading */
.migrate-single-btn {
    width: 78px;
    justify-content: center;
}

#migrateSelectedBtn {
    width: 174px;
    justify-content: center;
}

/* ==========================================================================
   MOBILE & RESPONSIVE STYLES (GM3 ADAPTIVE LAYOUT)
   ========================================================================== */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-y: auto;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }

    .logo-area {
        width: 100%;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    .logo-area h1 {
        display: none;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
    }

    .header-controls .btn {
        flex: 1;
        justify-content: center;
        padding: 8px 12px;
        font-size: 13px;
    }

    .app-grid {
        height: auto;
    }

    .right-panel {
        height: auto;
        overflow-y: visible;
        gap: 16px;
    }

    .top-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .tabs-container {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        justify-content: space-between;
        padding: 4px;
    }

    .tab-btn {
        flex: 1 1 45%;
        justify-content: center;
        text-align: center;
        font-size: 12px;
        padding: 8px 10px;
    }

    .tab-lbl-full {
        display: none;
    }

    .tab-lbl-short {
        display: inline;
    }

    .tab-divider {
        display: none;
    }

    .tab-total-label {
        display: none;
    }

    #refreshCatalogBtn {
        width: 100%;
        justify-content: center;
    }

    .table-card {
        flex: none;
        height: auto;
    }

    .glass-card {
        padding: 14px 12px;
    }

    .table-actions-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .search-filter-wrapper {
        width: 100%;
        order: 2;
    }

    input[type="text"].table-search-input {
        width: 100%;
    }

    .actions-group {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        justify-content: space-between;
        order: 1;
    }

    .actions-group .btn,
    #migrateSelectedBtn,
    #deselectAllBtn {
        flex: 1 1 45%;
        width: auto !important;
        max-width: none;
        justify-content: center;
        padding: 8px 10px;
        font-size: 12px;
    }

    .selection-count-label {
        flex: 1 1 100%;
        text-align: center;
        width: 100%;
        min-height: 20px;
    }

    .selection-count-label.hidden {
        display: inline-flex !important;
        visibility: hidden;
    }

    .table-responsive {
        max-height: 55vh;
    }

    .products-table {
        min-width: 680px;
        font-size: 12px;
    }

    .products-table th, .products-table td {
        padding: 10px;
    }

    .pagination-bar {
        flex-direction: column;
        gap: 14px;
        align-items: stretch;
        width: 100%;
        padding-top: 14px;
    }

    .page-size-selector {
        justify-content: center;
    }

    .pagination-nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
        width: 100%;
    }

    .pagination-nav .btn-xs {
        flex: 1 1 21%;
        padding: 8px 6px;
        font-size: 11px;
        justify-content: center;
        text-align: center;
    }

    .pagination-nav .page-info {
        flex: 1 1 100%;
        order: -1;
        margin-bottom: 8px;
        font-size: 13px;
        font-weight: 600;
        color: var(--color-primary);
        text-align: center;
    }

    /* Modals Adaptation for Mobile */
    .modal-backdrop {
        padding: 12px;
    }

    .glass-modal, 
    .config-modal-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 16px;
        border-radius: 20px;
        max-height: 90vh;
    }

    .modal-header {
        padding: 12px 12px 10px 12px;
    }

    .modal-body {
        padding: 0 12px 12px 12px;
    }

    .modal-footer {
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }

    #confirmMigrationRunBtn {
        order: 1;
    }

    #confirmMigrationCancelBtn {
        order: 2;
    }

    .segmented-control {
        flex-direction: column;
        border-radius: 12px;
    }

    .segment-btn {
        border-radius: 8px;
        padding: 8px;
    }
}

/* ==========================================
 * MODAL REFACTORING STYLES
 * ========================================== */

/* Alert Modal Custom Layout & Variables */
#alertModal .glass-modal {
    max-width: 480px;
}

#alertModal .modal-header {
    border-bottom: 1px solid rgba(197, 34, 31, 0.15);
    padding: 20px 24px 14px 24px;
}

#alertModal.warning .modal-header {
    border-bottom: 1px solid rgba(176, 96, 0, 0.15);
}

#alertModalTitle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

#alertModal.danger #alertModalTitle {
    color: var(--color-danger);
}

#alertModal.warning #alertModalTitle {
    color: var(--color-warning);
}

#alertModal .modal-icon-danger,
#alertModal .modal-icon-warning {
    display: none;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

#alertModal.danger .modal-icon-danger {
    display: block;
    color: var(--color-danger);
}

#alertModal.warning .modal-icon-warning {
    display: block;
    color: var(--color-warning);
}

#alertModal .modal-body {
    padding: 20px 24px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--color-text-main);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 380px;
    overflow-y: auto;
}

#alertModal .modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 16px 24px 20px 24px;
    gap: 12px;
}

#alertModalOkBtn {
    padding: 8px 24px;
    color: white;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

#alertModal.danger #alertModalOkBtn {
    background-color: var(--color-danger);
}
#alertModal.danger #alertModalOkBtn:hover {
    background-color: #a51d1a;
}

#alertModal.warning #alertModalOkBtn {
    background-color: var(--color-warning);
}
#alertModal.warning #alertModalOkBtn:hover {
    background-color: #8c4c00;
}

/* Wide Modal modifier */
.glass-modal.modal-wide {
    max-width: 820px !important;
}

.glass-modal.modal-normal {
    max-width: 560px !important;
}

/* Modal Subtitle */
.modal-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

/* Error blocks inside modals */
.product-error-block {
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}
.product-error-block.warning {
    background-color: var(--color-warning-bg);
    border: 1px solid rgba(176, 96, 0, 0.15);
}
.product-error-block.danger {
    background-color: var(--color-danger-bg);
    border: 1px solid rgba(197, 34, 31, 0.15);
}
.product-error-block.margin-bottom {
    margin-bottom: 10px;
}

/* Migrated OTP label states */
span.migrated-label.yes {
    color: var(--color-success);
    font-weight: 500;
}
span.migrated-label.no {
    color: var(--color-text-muted);
    opacity: 0.8;
}





