/**
 * Checklist Styles
 */

.rd-checklist {
    --checklist-primary: rgb(82, 197, 255);
    --checklist-border: #e5e7eb;
    --checklist-bg: #f9fafb;
    --checklist-text: #1f2937;
    --checklist-muted: #6b7280;
    --checklist-success: #10b981;
    
    font-family: system-ui, -apple-system, sans-serif;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Header */
.rd-checklist__header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--checklist-border);
}

.rd-checklist__header-content {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.rd-checklist__image {
    flex-shrink: 0;
    width: 200px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
}

.rd-checklist__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rd-checklist__meta {
    flex: 1;
}

.rd-checklist__source {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--checklist-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rd-checklist__source-id {
    opacity: 0.6;
}

.rd-checklist__title {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--checklist-text);
}

.rd-checklist__title--editable {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rd-checklist__title-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.6;
    padding: 0.25rem;
    transition: opacity 0.15s;
}

.rd-checklist__title-edit-btn:hover {
    opacity: 1;
}

.rd-checklist__title-input {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--checklist-text);
    border: 2px solid var(--checklist-primary);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    width: 100%;
    max-width: 500px;
}

.rd-checklist__excerpt {
    margin: 0 0 1rem;
    color: var(--checklist-muted);
    font-size: 1rem;
    line-height: 1.5;
}

.rd-checklist__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.rd-checklist__category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--checklist-bg);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--checklist-muted);
}

.rd-checklist__travelers {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--checklist-muted);
}

/* Settings display row */
.rd-checklist__settings {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--checklist-muted);
}

.rd-checklist__setting {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.rd-checklist__setting-icon {
    font-size: 1rem;
}

/* Active conditions chips in header */
.rd-checklist__conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.rd-checklist__condition-chip {
    display: inline-block;
    padding: 0.1875rem 0.5rem;
    font-size: 0.75rem;
    color: #4b5563;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
}

/* Calculation hint for blueprint preview */
.rd-checklist__calculation-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--checklist-muted);
    background: var(--checklist-bg);
    border-radius: 6px;
    border: 1px dashed var(--checklist-border);
}

.rd-checklist__calculation-hint-icon {
    flex-shrink: 0;
}

/* Progress bar */
.rd-checklist__progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.rd-checklist__progress-bar {
    flex: 1;
    max-width: 200px;
    height: 8px;
    background: var(--checklist-border);
    border-radius: 4px;
    overflow: hidden;
}

.rd-checklist__progress-fill {
    height: 100%;
    background: var(--checklist-success);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.rd-checklist__progress-text {
    font-size: 0.875rem;
    color: var(--checklist-muted);
    font-weight: 500;
}

/* Description */
.rd-checklist__description {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--checklist-bg);
    border-radius: 8px;
    line-height: 1.6;
}

/* Sections */
.rd-checklist__sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.rd-checklist__section {
    background: #fff;
    border: 1px solid var(--checklist-border);
    border-radius: 12px;
    overflow: hidden;
}

.rd-checklist__section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--checklist-bg);
    border-bottom: 1px solid var(--checklist-border);
}

.rd-checklist__section-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
}

.rd-checklist__section-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Section title when inside header (with image) */
.rd-checklist__section-header .rd-checklist__section-title {
    margin: 0;
    padding: 0;
    background: transparent;
    border-bottom: none;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--checklist-text);
}

/* Section title when standalone (no image) */
.rd-checklist__section > .rd-checklist__section-title {
    margin: 0;
    padding: 1rem 1.25rem;
    background: var(--checklist-bg);
    border-bottom: 1px solid var(--checklist-border);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--checklist-text);
}

/* Items list */
.rd-checklist__items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rd-checklist__item {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--checklist-border);
}

.rd-checklist__item:last-child {
    border-bottom: none;
}

.rd-checklist__item--checked {
    background: rgba(16, 185, 129, 0.05);
}

.rd-checklist__item--checked .rd-checklist__item-title {
    text-decoration: line-through;
    color: var(--checklist-muted);
}

/* Item row: left (icon, qty, title) | right (chevron, checkbox) */
.rd-checklist__item-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.rd-checklist__item-left {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.rd-checklist__item-right {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex-shrink: 0;
}

.rd-checklist__item-expand {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    margin-top: 0.125rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--checklist-muted);
    border-radius: 4px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rd-checklist__item-expand:hover {
    background: var(--checklist-bg);
    color: var(--checklist-text);
}

.rd-checklist__item-expand[aria-expanded="true"] .rd-checklist__item-chevron {
    transform: rotate(180deg);
}

.rd-checklist__item-chevron {
    transition: transform 0.2s ease;
}

/* Checkbox wrapper */
.rd-checklist__checkbox-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Collapsible item details */
.rd-checklist__item-details {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--checklist-bg);
    border-radius: 6px;
    font-size: 0.875rem;
    overflow-x: auto;
}

.rd-checklist__item-details[hidden] {
    display: none;
}

.rd-checklist__item-details .rd-checklist__item-formula {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--checklist-muted);
    font-family: monospace;
    white-space: pre-line;
    line-height: 1.5;
}

.rd-checklist__item-details .rd-checklist__item-description {
    margin: 0 0 0.5rem;
}

.rd-checklist__item-details .rd-checklist__item-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.rd-checklist__item-details .rd-checklist__link-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #fff;
    border: 1px solid var(--checklist-border);
    border-radius: 4px;
    font-size: 0.8125rem;
    color: var(--checklist-text);
    text-decoration: none;
    transition: all 0.15s;
}

.rd-checklist__item-details .rd-checklist__link-item:hover {
    border-color: var(--checklist-primary);
    color: var(--checklist-primary);
}

/* Checkbox items - title | chevron | checkbox layout */
.rd-checklist__checkbox-label {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-height: 2.5rem;
}

.rd-checklist__checkbox-label .rd-checklist__item-title {
    flex: 1;
    padding-top: 0.25rem;
}

/* Hide native checkbox, use custom styling */
.rd-checklist__checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Custom checkbox appearance */
.rd-checklist__checkbox-visual {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.15s ease;
    order: 2;
}

.rd-checklist__checkbox-visual::before {
    content: '';
}

/* Checked state */
.rd-checklist__checkbox:checked + .rd-checklist__checkbox-visual {
    background: #10b981;
    border-color: #10b981;
}

.rd-checklist__checkbox:checked + .rd-checklist__checkbox-visual::before {
    content: '✓';
    color: #fff;
    font-weight: 700;
}

/* Hover state */
.rd-checklist__checkbox-label:hover .rd-checklist__checkbox-visual {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Focus state */
.rd-checklist__checkbox:focus + .rd-checklist__checkbox-visual {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.rd-checklist__checkbox-placeholder {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    order: 2;
}

.rd-checklist__item-title {
    order: 1;
    flex: 1;
    font-size: 1rem;
    color: var(--checklist-text);
    line-height: 1.4;
}

.rd-checklist__item-description {
    margin: 0.5rem 0 0 0;
    font-size: 0.875rem;
    color: var(--checklist-muted);
    line-height: 1.4;
}

.rd-checklist__item-formula {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--checklist-muted);
    font-family: monospace;
}

/* Quantity items with checkbox */
.rd-checklist__checkbox-label--quantity .rd-checklist__item-qty {
    order: 0;
    margin-right: 0.5rem;
}

/* Quantity items */
.rd-checklist__quantity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rd-checklist__item-qty {
    flex-shrink: 0;
    min-width: 2.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--checklist-primary);
    color: #fff;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.rd-checklist__qty-input {
    width: 4rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--checklist-border);
    border-radius: 4px;
    font-size: 0.875rem;
    text-align: center;
}

/* Item images (user uploaded) */
.rd-checklist__item-images {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    margin-left: 2rem;
}

.rd-checklist__item-image {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
}

.rd-checklist__item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Footer */
.rd-checklist__footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--checklist-border);
    text-align: center;
}

.rd-checklist__save-btn {
    padding: 0.75rem 2rem;
    background: var(--checklist-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.rd-checklist__save-btn:hover {
    background: #1d4ed8;
}

/* Error state */
.rd-checklist-error {
    padding: 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    text-align: center;
}

/* Preview notice */
.rd-checklist__preview-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: #92400e;
}

.rd-checklist__preview-notice-icon {
    flex-shrink: 0;
}

.rd-checklist--preview .rd-checklist__checkbox-label {
    cursor: default;
}

/* Person filter */
.rd-checklist__person-filter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.rd-checklist__person-filter-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #0369a1;
}

.rd-checklist__person-filter-select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #7dd3fc;
    border-radius: 6px;
    background: white;
    color: var(--checklist-text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230369a1' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.rd-checklist__person-filter-select:focus {
    outline: none;
    border-color: var(--checklist-primary);
    box-shadow: 0 0 0 3px rgba(82, 197, 255, 0.2);
}

/* Per-person item highlight */
.rd-checklist__item--per-person .rd-checklist__item-title::before {
    content: "👤 ";
    opacity: 0.6;
}

/* Filter active state - hide non-matching items */
.rd-checklist.rd-checklist--filtering .rd-checklist__item--per-person[data-person-hidden="true"] {
    display: none;
}

/* Hide empty sections when filtering */
.rd-checklist.rd-checklist--filtering .rd-checklist__section--hidden {
    display: none;
}

/* Responsive */
@media (max-width: 640px) {
    .rd-checklist__header {
        flex-direction: column;
    }
    
    .rd-checklist__image {
        width: 100%;
        height: 200px;
    }
    
    .rd-checklist__title {
        font-size: 1.5rem;
    }
    
    .rd-checklist__section-image {
        width: 60px;
        height: 60px;
    }
    
    .rd-checklist__person-filter {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Item Links Dropdown */
.rd-checklist__item-links {
    position: relative;
    display: inline-block;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.rd-checklist__links-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: var(--checklist-bg);
    border: 1px solid var(--checklist-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--checklist-muted);
    transition: all 0.15s ease;
}

.rd-checklist__links-toggle:hover {
    background: #fff;
    border-color: var(--checklist-primary);
    color: var(--checklist-text);
}

.rd-checklist__links-icon {
    font-size: 0.8rem;
}

.rd-checklist__links-count {
    font-weight: 500;
    min-width: 1em;
    text-align: center;
}

.rd-checklist__links-chevron {
    transition: transform 0.2s ease;
}

.rd-checklist__links-toggle[aria-expanded="true"] .rd-checklist__links-chevron {
    transform: rotate(180deg);
}

.rd-checklist__links-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 200px;
    max-width: 300px;
    margin-top: 0.25rem;
    background: #fff;
    border: 1px solid var(--checklist-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease;
}

.rd-checklist__links-toggle[aria-expanded="true"] + .rd-checklist__links-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.rd-checklist__link-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--checklist-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s ease;
}

.rd-checklist__link-item:hover {
    background: var(--checklist-bg);
}

.rd-checklist__link-item:first-child {
    border-radius: 6px 6px 0 0;
}

.rd-checklist__link-item:last-child {
    border-radius: 0 0 6px 6px;
}

.rd-checklist__link-item:only-child {
    border-radius: 6px;
}

.rd-checklist__link-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

.rd-checklist__link-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Close dropdown when clicking outside */
.rd-checklist__item-links:not(:focus-within) .rd-checklist__links-toggle[aria-expanded="true"] + .rd-checklist__links-dropdown {
    /* Handled by JS, but this is a fallback */
}
