/* Recipe Manager Page Styles
 * @version 2.1.0
 * @changelog
 *   2.1.0 - Mobile fixes: filter section inner row (category filter + Manage Categories
 *            button) now stacks properly. Search box stacks label/input/Clear vertically.
 *            ID column hidden in mobile card view (was only hidden at tablet width).
 *            Checkbox repositioned to sit inline with title instead of its own stacked row.
 *   2.0.0 - Added tablet (768px) and mobile (430px) responsive breakpoints.
 *            Filter section stacks vertically on mobile, table transforms to card layout,
 *            bulk action buttons go full-width and stack on mobile.
 *            Requires data-label attributes on <td> elements for card labels (see template).
 *   1.0.0 - Initial release.
 */

 .filter-group-pair {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.recipe-manager {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
}

.recipe-manager h1 {
    color: #c84a31;
    font-size: 36px;
    margin-bottom: 30px;
}

.filter-section {
    background: #f9f9f9;
    padding: 20px;
    margin-bottom: 30px;
    border: 2px solid #c84a31;
    display: flex;
    gap: 20px;
    align-items: center;
}

.recipe-manager-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.recipe-manager-table thead {
    background: #c84a31;
    color: white;
}

.recipe-manager-table th {
    padding: 15px;
    text-align: left;
    font-weight: bold;
}

.recipe-manager-table td {
    padding: 5px 15px;
    border-bottom: 1px solid #eee;
}

.recipe-manager-table tbody tr:hover {
    background: #f9f9f9;
}

.recipe-manager-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.recipe-id {
    font-family: 'Courier New', monospace;
    color: #666;
    font-weight: bold;
}

.recipe-title-link {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
}

.recipe-title-link:hover {
    text-decoration: underline;
}

.bulk-actions {
    background: #fff;
    padding: 20px;
    margin-top: 20px;
    border: 2px solid #c84a31;
    display: flex;
    gap: 15px;
    align-items: center;
}

.action-btn {
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 3px;
    font-weight: bold;
}

.action-btn:hover {
    opacity: 0.8;
}

.action-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.recipe-count {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.selected-count {
    font-weight: bold;
    color: #c84a31;
}

/* ============================================================
   TABLET — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {

    .recipe-manager h1 {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .filter-section {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-section select,
    .filter-section input:not([type="checkbox"]) {
        box-sizing: border-box;
    }

    /* Hide ID column to save space */
    .recipe-manager-table th:nth-child(2),
    .recipe-manager-table td:nth-child(2) {
        display: none;
    }

    .bulk-actions {
        flex-wrap: wrap;
    }

    .bulk-actions .action-btn {
        flex: 1 1 auto;
    }
}

/* ============================================================
   MOBILE — max-width: 430px (iPhone 16 and all current iPhones)
   ============================================================ */
@media (max-width: 430px) {

    .recipe-manager {
        padding: 0 12px;
        margin: 10px auto;
    }

    .recipe-manager h1 {
        font-size: 22px;
        margin-bottom: 15px;
    }

    .filter-section {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .filter-section select,
    .filter-section input:not([type="checkbox"]) {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px; /* prevents iOS auto-zoom */
    }

    /* The inner row inside .filter-section that holds the category-filter
       dropdown button + "Manage Categories" button — stack them too */
    .filter-inner-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }

    .filter-inner-row > button,
    .filter-inner-row > div {
        width: 100%;
        box-sizing: border-box;
        margin-left: 0 !important;
    }
    /* Collection selector dropdown — kill the fixed min-width that forces horizontal scroll */
    #collection-selector {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Category filter button — same fix */
    #categoryFilterBtn {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Category dropdown panel — make sure it doesn't overflow either */
    #categoryDropdown {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box;
        left: 0;
    }

    /* Search box — stack label, input, and Clear button vertically */
    .recipe-search-box {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .recipe-search-box input,
    .recipe-search-box button {
        width: 100%;
        box-sizing: border-box;
    }

    /* --- Table → 2-column layout: checkbox + title only --- */
    .recipe-manager-table,
    .recipe-manager-table tbody {
        display: block;
    }

    .recipe-manager-table thead {
        display: block;
        background: #c84a31;
        border-radius: 4px;
        padding: 5px 8px;
        margin-bottom: 4px;
    }
    
    .recipe-manager-table thead tr,
    .recipe-manager-table tbody tr {
        display: flex;
        align-items: center;
    }

    .recipe-manager-table thead th,
    .recipe-manager-table tbody td {
        display: block;
        box-sizing: border-box;
        border: none;
    }

    .recipe-manager-table thead th {
        color: white;
        font-size: 11px;
        font-weight: normal;
        letter-spacing: 0.6px;
        text-transform: uppercase;
        text-align: left;
        padding: 0;
    }

    .recipe-manager-table tbody td {
        font-size: 14px;
        padding: 1px 0;
    }

    .recipe-manager-table thead th:first-child,
    .recipe-manager-table tbody td:first-child {
        flex: 0 0 22px;
    }

    .recipe-manager-table thead th:nth-child(3),
    .recipe-manager-table tbody td:nth-child(3) {
        flex: 1 1 auto;
        word-break: break-word;
        padding-left: 6px;
    }

    .recipe-manager-table thead th:nth-child(2),
    .recipe-manager-table tbody td:nth-child(2),
    .recipe-manager-table thead th:nth-child(4),
    .recipe-manager-table tbody td:nth-child(4) {
        display: none;
    }

    .recipe-manager-table input[type="checkbox"] {
        width: 15px;
        height: 15px;
        display: block;
    }

    .recipe-manager-table tbody tr {
        border-bottom: 1px solid #eee;
        padding: 2px 0;
        align-items: flex-start;
    }

    .recipe-manager-table tbody tr:last-child {
        border-bottom: none;
    }

    /* Hide the ID row in mobile card view (was only hidden at tablet width) */
    .recipe-manager-table td:nth-child(2) {
        display: none;
    }

    /* --- Bulk actions --- */
    .bulk-actions {
        flex-direction: column;
        padding: 12px;
        gap: 8px;
    }

    .bulk-actions .action-btn {
        width: 100%;
        padding: 12px;
        font-size: 15px;
        box-sizing: border-box;
    }

    .recipe-count {
        font-size: 13px;
    }
    /* Header row: stack title above logout button, keep button text on one line */
    .page-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .page-header-row h1 {
        font-size: 18px;
        word-break: break-word;
    }

    .page-header-row a {
        white-space: nowrap;
    }
}