/* Feed Charm — Custom Styles */

/* ---- Design Tokens ---- */
:root {
    --fc-primary: #1E40AF;
    --fc-secondary: #3B82F6;
    --fc-accent: #F59E0B;
    --fc-success: #16A34A;
    --fc-danger: #DC2626;
    --fc-muted: #64748B;
    --fc-bg: #F8FAFC;
    --fc-text: #1E293B;
    --fc-override: #F59E0B;
    --fc-radius: 6px;
    --fc-transition: 0.2s ease;
}

/* ---- Typography ---- */
body {
    font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
    background: var(--fc-bg);
    color: var(--fc-text);
}

/* ---- Global Transitions ---- */
a, button, .small-btn, tr, .image-card, .override-dot {
    transition: all var(--fc-transition);
}

/* ---- Thumbnail images in table ---- */
.thumb {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: var(--fc-radius);
    cursor: pointer;
}

/* ---- Row hover ---- */
#offers-table tbody tr {
    cursor: default;
    transition: background-color var(--fc-transition);
}

#offers-table tbody tr:hover {
    background-color: rgba(30, 64, 175, 0.04);
}

/* ---- Override indicators ---- */
.overridden {
    border-left: 3px solid var(--fc-override) !important;
    padding-left: 8px;
}

.override-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--fc-secondary);
}

.override-badge {
    background: var(--fc-override);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.override-label {
    color: var(--fc-override);
    font-weight: 600;
}

.reset-link {
    color: var(--fc-danger);
    font-size: 0.8em;
    margin-left: 8px;
    cursor: pointer;
}

.reset-link:hover {
    text-decoration: underline;
}

/* ---- Availability badges ---- */
.avail-yes {
    color: var(--fc-success);
    font-weight: 600;
}

.avail-no {
    color: var(--fc-danger);
    font-weight: 600;
}

/* ---- Status badges ---- */
.status-active {
    color: var(--fc-success);
    font-weight: 600;
}

.status-inactive {
    color: var(--fc-muted);
}

/* ---- Buttons ---- */
.small-btn {
    padding: 6px 12px !important;
    font-size: 0.8em !important;
    margin: 2px !important;
    min-height: 32px;
    cursor: pointer;
}

.small-btn:hover {
    opacity: 0.85;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

button[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
}

/* ---- Edit form ---- */
.edit-fields {
    display: grid;
    gap: 16px;
}

.edit-section-title {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--fc-primary);
    margin-top: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(30, 64, 175, 0.15);
}

.field-overridden {
    background: rgba(245, 158, 11, 0.06);
    padding: 10px;
    border-radius: var(--fc-radius);
    border-left: 3px solid var(--fc-override);
}

/* ---- Images grid ---- */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.image-card {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.image-card:hover {
    border-color: var(--fc-secondary);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.08);
}

.image-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--fc-radius);
    margin-bottom: 8px;
}

.image-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 8px;
}

.image-url-input {
    font-size: 0.75em !important;
    padding: 4px !important;
}

/* ---- Pagination ---- */
.pagination-controls {
    text-align: center;
    margin-top: 16px;
}

.pagination-controls nav ul {
    display: flex;
    justify-content: center;
    gap: 4px;
    list-style: none;
    padding: 0;
}

.pagination-controls nav ul li a {
    padding: 6px 12px;
    border-radius: var(--fc-radius);
    cursor: pointer;
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination-controls nav ul li a:hover {
    background: rgba(30, 64, 175, 0.08);
}

.pagination-controls nav ul li a.active {
    background: var(--fc-primary);
    color: white;
}

/* ---- Toast notifications ---- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 40px 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 0.9em;
    animation: slideIn 0.3s ease;
    max-width: 420px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast .toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 1.1em;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    min-height: auto;
}

.toast .toast-close:hover {
    opacity: 1;
}

.toast.success {
    background: var(--fc-success);
}

.toast.error {
    background: var(--fc-danger);
}

.toast.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }
    .toast.fade-out {
        animation: none;
        opacity: 0;
    }
    a, button, .small-btn, tr, .image-card, .override-dot {
        transition: none;
    }
}

/* ---- Table responsiveness ---- */
figure {
    overflow-x: auto;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--fc-muted);
}

.empty-state p {
    margin: 0;
    font-size: 1.1em;
}

/* ---- Params in edit ---- */
.params-list {
    display: grid;
    gap: 4px;
}

.param-row {
    padding: 6px 10px;
    background: var(--pico-card-background-color);
    border-radius: var(--fc-radius);
    font-size: 0.9em;
}

/* ---- Loading spinner ---- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* ---- Footer ---- */
footer {
    margin-top: 40px;
    padding-bottom: 20px;
}

/* ---- Adaptive layout ---- */
main#main-content {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

footer#main-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

@media (min-width: 1400px) {
    main#main-content {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (min-width: 2560px) {
    main#main-content {
        padding-left: 4rem;
        padding-right: 4rem;
    }
}

/* ---- New picture cell ---- */
.new-pic-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 90px;
}

.new-pic-actions {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
}

.thumb-sm {
    width: 160px;
    height: 160px;
    object-fit: cover;
    border-radius: var(--fc-radius);
    cursor: pointer;
}

.video-name {
    font-size: 0.75em;
    color: var(--fc-muted);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* ---- Resizable column headers ---- */
th.resizable {
    position: relative;
    overflow: visible;
}

th.resizable .col-resizer {
    position: absolute;
    right: 0;
    top: 0;
    width: 5px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    background: transparent;
    z-index: 1;
}

th.resizable .col-resizer:hover,
th.resizable .col-resizer.dragging {
    background: var(--fc-secondary);
    opacity: 0.5;
}

/* ---- Inline editable inputs in table ---- */
.inline-input {
    width: 100%;
    padding: 2px 4px;
    font-size: 0.8em;
    margin: 0;
    min-width: 80px;
}

/* ---- Draggable column headers: cursor только на .drag-handle ---- */
.drag-handle {
    cursor: grab;
    opacity: 0.35;
    font-size: 0.85em;
    user-select: none;
    display: inline-block;
    margin-right: 2px;
}
.drag-handle:hover { opacity: 0.85; }
.drag-handle:active { cursor: grabbing; }

/* ---- Photo hover preview ---- */
.thumb-wrap {
    position: relative;
    display: inline-block;
}
.thumb-hover {
    display: none;
    position: absolute;
    top: 188px;
    left: 0;
    width: auto;
    height: auto;
    max-width: 320px;
    max-height: 320px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 200;
    background: white;
    pointer-events: none;
}
.thumb-wrap:hover .thumb-hover { display: block; }
.no-photo { opacity: 0.4; }

/* ---- URL cell ---- */
.url-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 100px;
}
.url-link {
    font-size: 1.1em;
    text-decoration: none;
    flex-shrink: 0;
    opacity: 0.6;
}
.url-link:hover { opacity: 1; }

/* ---- Filters row ---- */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    padding-bottom: 0.5rem;
}
.filters-row label {
    flex: 0 0 auto;
    min-width: 160px;
    max-width: 260px;
    margin-bottom: 0;
}

/* ---- Table toolbar ---- */
.table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}
.col-visibility-wrapper {
    position: relative;
}
.col-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--pico-card-background-color, #fff);
    border: 1px solid var(--pico-muted-border-color, #ddd);
    border-radius: var(--fc-radius);
    padding: 8px 12px;
    z-index: 300;
    min-width: 180px;
    max-height: 420px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.col-panel-title {
    font-weight: 600;
    font-size: 0.82em;
    color: var(--fc-muted);
    padding-bottom: 5px;
    border-bottom: 1px solid var(--pico-muted-border-color, #ddd);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.col-panel-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 0.9em;
    cursor: pointer;
    margin-bottom: 0;
}

/* ---- Icon buttons (replace/delete in cells) ---- */
.icon-btn {
    background: none;
    border: 1px solid var(--pico-muted-border-color, #ccc);
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 1em;
    line-height: 1.4;
    min-height: auto;
}
.icon-btn:hover {
    background: rgba(0,0,0,0.05);
}
.icon-btn.danger {
    border-color: var(--fc-danger);
}

/* ---- Column visibility panel inside filters ---- */
.col-panel-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 8px 0 4px;
}
