/*
 * GoutSavvy Purine Food Database — Enhanced Styles
 * Theme: GeneratePress + teal #2a7d8c, full-width layout
 * All gsv- prefixed to avoid theme conflicts
 */

/* ===== LAYOUT: Desktop 50/50, Mobile bottom drawer ===== */
.gsv-purine-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.gsv-purine-main {
    flex: 1;
    min-width: 0;
}

/* ===== PLATE PANEL (desktop sidebar) ===== */
.gsv-plate {
    width: 46%;
    flex-shrink: 0;
    background: #2a7d8c;
    border: 2px solid #2a7d8c;
    border-radius: 4px;
    overflow: hidden;
}

.gsv-plate-hdr {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 8px;
    background: #2a7d8c;
    color: #fff;
}

.gsv-plate-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.gsv-plate-total-num {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fff;
    flex: 1;
}
.gsv-plate-total-num.danger { color: #ffcdd2; }
.gsv-plate-total-num.warn   { color: #ffe0b2; }

.gsv-plate-toggle {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 26px;
    height: 26px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.gsv-plate-toggle:hover { background: rgba(255,255,255,0.35); }

.gsv-plate-bar-wrap {
    height: 5px;
    background: rgba(255,255,255,0.3);
    margin: 0 16px;
}
.gsv-plate-bar {
    height: 100%;
    background: #fff;
    border-radius: 3px;
    transition: width 0.4s ease, background 0.3s;
}

.gsv-plate-meta {
    padding: 6px 16px 10px;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
}
.gsv-plate-meta .danger { color: #ffcdd2; font-weight: 600; }
.gsv-plate-meta .warn   { color: #ffe0b2; font-weight: 600; }
.gsv-plate-meta .ok     { color: rgba(255,255,255,0.9); font-weight: 600; }

/* Plate body with its own scroll */
.gsv-plate-list {
    max-height: 320px;
    overflow-y: auto;
    background: #f0f7f8;
}

.gsv-plate-empty {
    padding: 24px 16px;
    text-align: center;
    color: #888;
    font-size: 13px;
    background: #f0f7f8;
}

/* Plate item row */
.gsv-plate-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 9px 16px;
    border-top: 1px solid #dde;
    gap: 10px;
    font-size: 13px;
}
.gsv-plate-item:hover { background: #e8f4f5; }

.gsv-plate-item-l {
    flex: 1;
    min-width: 0;
}

.gsv-plate-item-name {
    font-weight: 600;
    color: #222;
    word-break: break-word;
    line-height: 1.3;
}

.gsv-plate-item-cn {
    font-size: 11px;
    color: #888;
    word-break: break-word;
}

.gsv-plate-item-r {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-size: 12px;
    color: #555;
}

.gsv-grams {
    width: 76px;
    padding: 4px 6px;
    border: 1px solid #bcd;
    border-radius: 3px;
    font-size: 13px;
    text-align: center;
    color: #333;
    background: #fff;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}
.gsv-grams::-webkit-inner-spin-button,
.gsv-grams::-webkit-outer-spin-button {
    opacity: 1;
}
.gsv-grams:focus { outline: none; border-color: #2a7d8c; }

.gsv-plate-item-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.gsv-plate-item-val.low    { color: #2e7d32; }
.gsv-plate-item-val.medium { color: #e65100; }
.gsv-plate-item-val.high   { color: #c62828; }

.gsv-plate-rm {
    background: none;
    border: none;
    color: #bbb;
    font-size: 20px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
}
.gsv-plate-rm:hover { color: #e53935; }

.gsv-plate-foot {
    padding: 8px 16px;
    border-top: 1px solid #dde;
    background: #fff;
    display: flex;
    justify-content: flex-end;
}

.gsv-clear-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    color: #888;
    font-size: 12px;
    padding: 4px 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.gsv-clear-btn:hover { border-color: #e53935; color: #e53935; }

/* ===== DETAIL MODAL ===== */
.gsv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.gsv-modal {
    background: #fff;
    border-radius: 6px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}
.gsv-modal-hdr {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.gsv-modal-name {
    font-size: 18px;
    font-weight: 700;
    color: #222;
    line-height: 1.3;
    padding-right: 12px;
    word-break: break-word;
}
.gsv-modal-cn { font-size: 14px; font-weight: 400; color: #888; }
.gsv-modal-close {
    background: none;
    border: none;
    font-size: 26px;
    color: #aaa;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.gsv-modal-close:hover { color: #333; }
.gsv-modal-body { padding: 20px; }

.gsv-modal-score {
    text-align: center;
    padding: 20px;
    border-radius: 4px;
    margin-bottom: 16px;
}
.gsv-modal-score.low    { background: #e8f5e9; }
.gsv-modal-score.medium { background: #fff3e0; }
.gsv-modal-score.high   { background: #ffebee; }

.gsv-modal-val {
    font-size: 42px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: #222;
}
.gsv-modal-unit { font-size: 13px; color: #666; margin-top: 4px; }

.gsv-modal-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}
.gsv-modal-badge.low    { background: #e8f5e9; color: #2e7d32; }
.gsv-modal-badge.medium { background: #fff3e0; color: #e65100; }
.gsv-modal-badge.high   { background: #ffebee; color: #c62828; }

.gsv-dot-sm {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.gsv-modal-add {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.gsv-modal-add label {
    font-size: 13px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 6px;
}
.gsv-modal-add input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
    text-align: center;
}
.gsv-modal-add input:focus { outline: none; border-color: #2a7d8c; }

.gsv-add-btn {
    background: #2a7d8c;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.gsv-add-btn:hover { background: #236e76; }

.gsv-alt-section {
    background: #f5f5f5;
    border-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.gsv-alt-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #666;
    margin-bottom: 8px;
}
.gsv-alt-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #e8e8e8;
    font-size: 13px;
}
.gsv-alt-row:last-child { border-bottom: none; }
.gsv-alt-name { color: #333; word-break: break-word; }
.gsv-alt-val { font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 2px; }
.gsv-alt-val.low { color: #2e7d32; background: #e8f5e9; }

.gsv-modal-tip {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
    padding: 10px 14px;
    background: #fff9e6;
    border-left: 3px solid #f0ad4e;
    border-radius: 2px;
}

/* ===== QUICK-ADD BUTTON ===== */
.gsv-quick-add-btn {
    background: #e8f4f5;
    color: #2a7d8c;
    border: 1px solid #bcd;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.gsv-quick-add-btn:hover { background: #2a7d8c; color: #fff; border-color: #2a7d8c; }

/* ===== CONTROLS ===== */
.gsv-purine-controls {
    margin-bottom: 16px;
    padding: 16px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.gsv-search-row { margin-bottom: 12px; }
.gsv-search-row input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
    box-sizing: border-box;
}
.gsv-search-row input[type="text"]:focus { border-color: #2a7d8c; }
.gsv-search-row input[type="text"]::placeholder { color: #aaa; }

.gsv-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.gsv-filter-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: #555;
    transition: all 0.15s;
}
.gsv-filter-btn:hover { border-color: #2a7d8c; color: #2a7d8c; }
.gsv-filter-btn.active { background: #2a7d8c; color: #fff; border-color: #2a7d8c; }
.gsv-level-low.active    { background: #4caf50 !important; border-color: #4caf50 !important; color: #fff !important; }
.gsv-level-medium.active  { background: #ff9800 !important; border-color: #ff9800 !important; color: #fff !important; }
.gsv-level-high.active    { background: #e53935 !important; border-color: #e53935 !important; color: #fff !important; }

.gsv-sort-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    color: #555;
    background: #fff;
    outline: none;
    margin-left: auto;
}

/* ===== RESULT INFO ===== */
.gsv-result-info {
    font-size: 13px;
    color: #777;
    margin-bottom: 8px;
}

/* ===== TABLE ===== */
.gsv-purine-table {
    table-layout: auto;
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    font-size: 14px;
}
.gsv-purine-table thead { background: #f7f7f7; }

.gsv-purine-table th {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 2px solid #e0e0e0;
}
.gsv-purine-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}
.gsv-purine-table tbody tr:nth-child(even) { background: #fafafa; }
.gsv-purine-table tbody tr:hover { background: #f0f7f8; }

.gsv-food-name { font-weight: 600; color: #222; }
.gsv-purine-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.gsv-num-col { text-align: right; }

.gsv-level-cell { display: flex; align-items: center; gap: 6px; }
.gsv-level-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.gsv-level-dot.low    { background: #4caf50; }
.gsv-level-dot.medium { background: #ff9800; }
.gsv-level-dot.high   { background: #e53935; }

.gsv-level-label {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 2px;
}
.gsv-level-label.low    { color: #2e7d32; background: #e8f5e9; }
.gsv-level-label.medium { color: #e65100; background: #fff3e0; }
.gsv-level-label.high   { color: #b71c1c; background: #ffebee; }

.gsv-link { cursor: pointer; transition: color 0.15s; }
.gsv-link:hover { color: #2a7d8c; text-decoration: underline; }

/* ===== EMPTY STATE ===== */
.gsv-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 15px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* ===== PAGINATION ===== */
.gsv-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    font-size: 14px;
}
.gsv-pagination a,
.gsv-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
    color: #555;
    text-decoration: none;
    transition: all 0.15s;
}
.gsv-pagination a:hover { border-color: #2a7d8c; color: #2a7d8c; }
.gsv-pagination .gsv-current { background: #2a7d8c; color: #fff; border-color: #2a7d8c; }
.gsv-pagination .gsv-dots { border: none; color: #999; }
.gsv-pagination .gsv-prev-next { font-size: 13px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 767px) {
    /* Mobile: full-width table, plate = fixed bottom drawer */
    .gsv-purine-layout {
        display: block;
        padding-bottom: 60px;
    }

    .gsv-plate {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        z-index: 9998;
        transition: max-height 0.25s ease;
    }

    .gsv-plate-hdr {
        cursor: pointer;
        padding: 10px 16px 8px;
    }

    .gsv-plate.collapsed .gsv-plate-list,
    .gsv-plate.collapsed .gsv-plate-foot,
    .gsv-plate.collapsed .gsv-plate-bar-wrap,
    .gsv-plate.collapsed .gsv-plate-meta {
        display: none;
    }

    .gsv-plate.collapsed {
        max-height: 52px;
    }

    .gsv-plate.collapsed .gsv-plate-toggle {
        transform: rotate(180deg);
    }

    .gsv-plate-list {
        max-height: 260px;
    }

    .gsv-filter-row { gap: 6px; }
    .gsv-filter-btn { padding: 5px 10px; font-size: 12px; }
    .gsv-sort-select { font-size: 12px; margin-left: 0; width: 100%; }
    .gsv-purine-table th:last-child,
    .gsv-purine-table td:last-child { display: none; }
    .gsv-purine-table th,
    .gsv-purine-table td { padding: 8px 10px; font-size: 13px; }

    .gsv-modal-overlay { padding: 8px; align-items: flex-end; }
    .gsv-modal { max-width: 100%; border-radius: 12px 12px 0 0; }
}

@media (max-width: 480px) {
    .gsv-purine-controls { padding: 12px; }
    .gsv-level-label { display: none; }
    .gsv-level-cell { gap: 0; }
}
