/* ==========================================================================
   Polaris App - Custom Styles
   Minimal CSS for components Polaris web components don't cover.
   ========================================================================== */

/* --- Wider page layout (Polaris default is too narrow) --- */
s-page {
    --p-page-max-width: 75rem;
}

/* --- DataTable Polaris-style overrides --- */
.datatable-wrap {
    border: 1px solid var(--p-color-border, #e1e3e5);
    border-radius: 12px;
    overflow: hidden;
    background: var(--p-color-bg-surface, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.datatable-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.datatable-wrap thead th {
    background: var(--p-color-bg-surface-secondary, #f6f6f7);
    color: var(--p-color-text-secondary, #616161);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 16px;
    border-bottom: 1px solid var(--p-color-border, #e1e3e5);
    text-align: left;
}

.datatable-wrap tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--p-color-border-subdued, #f1f1f1);
    vertical-align: middle;
    color: var(--p-color-text, #1a1a1a);
}

.datatable-wrap tbody tr:hover {
    background: var(--p-color-bg-surface-hover, #f7f7f7);
}

.datatable-wrap tbody tr:last-child td {
    border-bottom: none;
}

/* DataTables controls */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_filter {
    padding: 12px 16px;
    border-bottom: 1px solid var(--p-color-border, #e1e3e5);
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--p-color-border, #c9cccf);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.8125rem;
    outline: none;
    margin-left: 8px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--p-color-border-interactive, #2c6ecb);
    box-shadow: 0 0 0 1px var(--p-color-border-interactive, #2c6ecb);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate,
.dataTables_wrapper .dataTables_length {
    padding: 10px 16px;
    font-size: 0.8125rem;
    color: var(--p-color-text-secondary, #616161);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    margin: 0 2px;
    cursor: pointer;
    font-size: 0.8125rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--p-color-bg-fill-brand, #2c6ecb);
    color: #fff !important;
    border-color: transparent;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--p-color-bg-surface-hover, #f1f1f1);
    border-color: var(--p-color-border, #c9cccf);
    color: var(--p-color-text, #1a1a1a) !important;
}

.dataTables_empty {
    text-align: center;
    padding: 40px 16px !important;
    color: var(--p-color-text-secondary, #616161);
}

/* --- Status badges --- */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}
.status-badge.active {
    background: #c8f9d4;
    color: #0d5e23;
}
.status-badge.inactive {
    background: #ffd6d6;
    color: #b01b1b;
}

/* --- Action buttons for DataTable rows --- */
.action-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}

.btn-action {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    color: #fff;
    transition: opacity 0.15s;
}
.btn-action:hover { opacity: 0.85; }
.btn-action.edit { background: #2c6ecb; }
.btn-action.preview { background: #29845a; }
.btn-action.download { background: #2c6ecb; }
.btn-action.qr { background: #c67a00; }
.btn-action.configure { background: #7c3aed; }
.btn-action.delete { background: #d72c0d; }
.btn-action.disabled { opacity: 0.4; pointer-events: none; }

/* --- Collection tags --- */
.collection-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.collection-tag {
    display: inline-block;
    background: var(--p-color-bg-surface-secondary, #f1f1f1);
    color: var(--p-color-text-secondary, #616161);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
}
.collection-tag.more {
    background: var(--p-color-bg-fill-brand, #2c6ecb);
    color: #fff;
}

/* --- Multi-select dual listbox (menus page) --- */
.multiselect-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.multiselect-box {
    width: 100%;
    min-height: 180px;
    max-height: 200px;
    border: 1px solid var(--p-color-border, #c9cccf);
    border-radius: 8px;
    padding: 4px;
    font-size: 0.8125rem;
    overflow-y: auto;
    background: #fff;
}

.multiselect-box option:checked {
    background: var(--p-color-bg-fill-brand, #2c6ecb);
    color: #fff;
}

.multiselect-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 20px;
}

.multiselect-buttons button {
    width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--p-color-border, #c9cccf);
    border-radius: 6px;
    background: var(--p-color-bg-surface, #fff);
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--p-color-text, #1a1a1a);
}

.multiselect-buttons button:hover {
    background: var(--p-color-bg-surface-hover, #f1f1f1);
}

.reorder-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 20px;
}

.reorder-buttons button {
    width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--p-color-border, #c9cccf);
    border-radius: 6px;
    background: var(--p-color-bg-surface, #fff);
    cursor: pointer;
    font-size: 0.75rem;
}

.reorder-buttons button:hover {
    background: var(--p-color-bg-surface-hover, #f1f1f1);
}

/* --- Template sidebar (pdf-menu page) --- */
.template-layout {
    display: flex;
    gap: 0;
    min-height: 600px;
    border: 1px solid var(--p-color-border, #e1e3e5);
    border-radius: 12px;
    overflow: hidden;
    background: var(--p-color-bg-surface, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.template-sidebar {
    width: 25%;
    min-width: 200px;
    border-right: 1px solid var(--p-color-border, #e1e3e5);
    background: var(--p-color-bg-surface-secondary, #f6f6f7);
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    padding: 14px 16px;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 650;
    color: var(--p-color-text, #1a1a1a);
    border-bottom: 1px solid var(--p-color-border, #e1e3e5);
}

.sidebar-title i { margin-right: 4px; }

.template-list {
    flex: 1;
    overflow-y: auto;
}

.template-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--p-color-border-subdued, #f1f1f1);
    transition: background 0.15s;
    font-size: 0.8125rem;
    color: var(--p-color-text-secondary, #616161);
}
.template-tab:hover {
    background: var(--p-color-bg-surface-hover, #ebebeb);
}
.template-tab.active {
    background: var(--p-color-bg-surface, #fff);
    border-left: 3px solid var(--p-color-border-interactive, #2c6ecb);
    font-weight: 600;
    color: var(--p-color-text, #1a1a1a);
}

.template-tab-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Category color dots */
.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-dot-SPEAKEASY { background: #D4AF37; }
.cat-dot-COCKTAIL { background: #E43F5A; }
.cat-dot-WINE { background: #722F37; }
.cat-dot-CRAFT_BEER { background: #D4A745; }
.cat-dot-NIGHTCLUB { background: #FF0080; }
.cat-dot-PUB { background: #2E5339; }
.cat-dot-SPIRITS { background: #C17F30; }
.cat-dot-TIKI { background: #FF6B4A; }
.cat-dot-FINE_DINING { background: #B8860B; }
.cat-dot-MODERN_BAR { background: #2563EB; }

/* --- Template preview panel (pdf-menu) --- */
.template-preview-panel {
    width: 75%;
    display: flex;
    flex-direction: column;
    background: var(--p-color-bg-surface, #fff);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--p-color-border, #e1e3e5);
    flex-wrap: wrap;
    gap: 8px;
}

.preview-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-header-left h5 {
    font-size: 1rem;
    font-weight: 650;
    color: var(--p-color-text, #1a1a1a);
    margin: 0;
}

.preview-header-right {
    display: flex;
    gap: 8px;
}

.preview-description {
    font-size: 0.8rem;
    color: var(--p-color-text-secondary, #616161);
    margin: 0;
    padding: 8px 20px 0 20px;
}

/* Preview iframe area */
.preview-frame-wrapper {
    flex: 1;
    position: relative;
    margin: 10px 20px 20px 20px;
    border: 1px solid var(--p-color-border, #e1e3e5);
    border-radius: 8px;
    overflow: hidden;
    min-height: 400px;
    background: var(--p-color-bg-surface-secondary, #f6f6f7);
}

.preview-frame {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border: none;
}

.preview-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--p-color-text-secondary, #616161);
    font-size: 0.8rem;
    background: var(--p-color-bg-surface-secondary, #f6f6f7);
    z-index: 2;
}
.preview-loading.hidden { display: none; }

/* --- Config panel layout (pdf-configure) --- */
.config-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 80px);
}

.config-panel {
    width: 380px;
    flex-shrink: 0;
    border-right: 1px solid var(--p-color-border, #e1e3e5);
    background: var(--p-color-bg-surface, #fff);
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

.config-panel-inner {
    padding: 16px;
}

.config-section {
    border: 1px solid var(--p-color-border, #e1e3e5);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    background: #fff;
}

.config-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    background: var(--p-color-bg-surface-secondary, #f6f6f7);
    border-bottom: 1px solid transparent;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--p-color-text, #1a1a1a);
    user-select: none;
}

.config-section-header:hover {
    background: var(--p-color-bg-surface-hover, #ebebeb);
}

.config-section-header.expanded {
    border-bottom-color: var(--p-color-border, #e1e3e5);
}

.config-section-header .chevron {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 0.7rem;
}

.config-section-header.expanded .chevron {
    transform: rotate(180deg);
}

.config-section-body {
    padding: 12px 14px;
    display: none;
}

.config-section-body.open {
    display: block;
}

.config-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--p-color-border, #e1e3e5);
    background: var(--p-color-bg-surface, #fff);
    flex-wrap: wrap;
    gap: 8px;
}

.config-preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--p-color-bg-surface-secondary, #f6f6f7);
}

.config-preview-frame {
    flex: 1;
    border: none;
    width: 100%;
}

/* --- Form field helpers --- */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.form-row > * {
    flex: 1;
}

.field-group {
    margin-bottom: 10px;
}

.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--p-color-text-secondary, #616161);
    margin-bottom: 4px;
}

/* --- Plans page --- */
.plans-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 0;
}

.plan-card {
    flex: 1;
    min-width: 260px;
    max-width: 340px;
    border: 1px solid var(--p-color-border, #e1e3e5);
    border-radius: 12px;
    background: var(--p-color-bg-surface, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.plan-card .plan-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--p-color-text, #1a1a1a);
    margin: 0 0 12px 0;
}

.plan-card .plan-price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--p-color-text, #1a1a1a);
}

.plan-card .plan-price sub {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--p-color-text-secondary, #616161);
    margin-left: 4px;
}

.plan-card .plan-features {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    flex: 1;
}

.plan-card .plan-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 0.8125rem;
    color: var(--p-color-text, #1a1a1a);
}

.plan-card .plan-features li svg {
    flex-shrink: 0;
    color: #29845a;
}

.plan-card .plan-actions {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--p-color-border, #e1e3e5);
}

/* --- Empty state --- */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--p-color-text-secondary, #616161);
}

/* --- Responsive: stack on small screens --- */
@media (max-width: 768px) {
    .template-layout { flex-direction: column; }
    .template-sidebar { width: 100%; min-height: auto; border-right: none; border-bottom: 1px solid var(--p-color-border, #e1e3e5); }
    .template-list { max-height: 200px; }
    .template-preview-panel { width: 100%; }

    .config-layout { flex-direction: column; }
    .config-panel { width: 100%; max-height: none; border-right: none; border-bottom: 1px solid var(--p-color-border, #e1e3e5); }

    .plans-grid { flex-direction: column; }
    .plan-card { max-width: 100%; }
}
