/* Styling for the MUI layer of the app.
 *
 * Anything that can be expressed as a typed component prop belongs in the Scala code, not here.
 * This file is for the things props cannot reach: density overrides on MUI's internal slot classes
 * (.MuiDrawer-paper, .MuiTableCell-root, ...) and plain layout for the surrounding divs.
 *
 * Semantic UI still styles the pages that have not been migrated yet -- see css/semantic.min.css.
 */

/* ---- app shell ------------------------------------------------------------------------------ */

.appDrawer .MuiDrawer-paper {
    width: 230px;
    box-sizing: border-box;
    position: relative; /* sits inside the flex row, not pinned to the viewport */
    border-right: 1px solid rgba(0, 0, 0, 0.12);
}

.appContent {
    flex: 1;
    min-width: 0;
    max-width: 1500px;
    padding: 12px 16px;
}

/* ---- left hand menu ------------------------------------------------------------------------- */

.appMenu .MuiListSubheader-root {
    line-height: 30px;
    padding-left: 16px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.55);
    background: transparent;
}

.appMenu .MuiListItem-root {
    padding: 0;
}

.appMenu .MuiListItemButton-root {
    padding: 3px 16px;
    border-radius: 4px;
    margin: 0 6px;
}

.appMenu .MuiListItemText-primary {
    font-size: 0.9rem;
}

.appMenu .MuiListItemButton-root.Mui-selected {
    background-color: rgba(25, 118, 210, 0.12);
}

.appMenu .MuiListItemButton-root.Mui-selected .MuiListItemText-primary {
    font-weight: 600;
    color: #1976d2;
}

/* ---- recipe list ---------------------------------------------------------------------------- */

.recipeSearchBar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
}

.recipeSearchBar .searchSelect {
    width: 200px;
    flex: 0 0 auto;
}

/* Semantic's table was a good deal tighter than MUI's default, even at size="small". */
.recipeTable .MuiTableCell-root {
    padding: 4px 8px;
    font-size: 0.875rem;
}

/* MUI tables are plain white. Backgrounds go on the cells, not the rows: MuiTableCell paints its own
 * background, so a colour set only on MuiTableRow can end up hidden underneath it. */
.recipeTable .MuiTableCell-head {
    font-weight: 700;
    white-space: nowrap;
    background-color: #b3c5da;
    color: rgba(0, 0, 0, 0.87);
    border-bottom: 1px solid #8fa6c0;
}

/* zebra striping */
.recipeTable .MuiTableBody-root .MuiTableRow-root:nth-of-type(odd) > .MuiTableCell-root {
    background-color: #eef2f7;
}

.recipeTable .MuiTableBody-root .MuiTableRow-root:nth-of-type(even) > .MuiTableCell-root {
    background-color: #dae2ec;
}

.recipeTable .MuiTableFooter-root .MuiTableCell-root {
    background-color: #b3c5da;
}

/* hover has to beat the striping above, hence the matching specificity */
.recipeTable .MuiTableBody-root .clickableRow:hover > .MuiTableCell-root {
    background-color: #bcd2e8;
    cursor: pointer;
}

/* The Actions picker sits inside a table cell: strip MUI's input padding/min-height so the row
 * stays the height of a line of text rather than the height of a form control. */
.recipeTable .MuiFormControl-root {
    margin: 0;
    vertical-align: middle;
}

.recipeTable .MuiInputBase-root {
    font-size: 0.875rem;
}

.recipeTable .MuiSelect-select {
    min-height: 0;
    padding: 0 24px 0 0;
    line-height: 1.4;
}

.recipePaginationBar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 10px;
}

/* ---- shared widgets ------------------------------------------------------------------------- */

.spinny {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.toastStack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---- recipe editor -------------------------------------------------------------------------- */

.recipeEditor {
    border-width: 6px;
    border-style: solid;
    padding: 8px;
}

.recipeEditor .editorRow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.recipeEditor .editorField {
    flex: 1 1 0;
    min-width: 160px;
}

.recipeEditor .editorColumns {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.recipeEditor .editorColumn {
    flex: 1 1 380px;
    min-width: 320px;
}

.recipeEditor .editorActions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
}

.recipeEditor .ingredientTable .MuiTableCell-root {
    padding: 2px 4px;
}

/* ---- ingredient row (inside the recipe editor's ingredient table) --------------------------- */

.ingredientRow {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ingredientRow .MuiTextField-root:first-of-type {
    width: 90px;
    flex: 0 0 auto;
}

.ingredientRow .ingredientUnit {
    width: 130px;
    flex: 0 0 auto;
}

.ingredientRow .ingredientGroceryItem {
    width: 200px;
    flex: 0 0 auto;
}

/* an ingredient with no grocery item cannot be shopped for -- Semantic flagged these too */
.ingredientRow .ingredientGroceryItem.missing .MuiOutlinedInput-notchedOutline {
    border-color: #d32f2f;
    border-width: 2px;
}

/* ---- image editor --------------------------------------------------------------------------- */

.imageEditor {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.imageEditor .imageThumb {
    position: relative;
    display: inline-block;
}

.imageEditor .imageThumb img {
    max-height: 120px;
    border-radius: 4px;
    display: block;
}

.imageEditor .imageThumb .MuiIconButton-root {
    position: absolute;
    top: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.75);
}

/* ---- import recipes --------------------------------------------------------------------------- */

.importTabPanel {
    padding: 12px 0;
}

.importActions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
}

/* ---- prepare shopping ------------------------------------------------------------------------- */

.shoppingSection {
    padding: 10px 0;
}

/* ---- calendar / meal planner ------------------------------------------------------------------ */

.calendarToolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 0;
}

.mealDetailsTitle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mealPlannerActions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.mealPlannerTable .mealPlannerSearchCell {
    min-width: 320px;
}

.mealPlannerTable .mealPlannerSearch {
    display: inline-flex;
    min-width: 220px;
    vertical-align: middle;
}

/* ---- store / cart ----------------------------------------------------------------------------- */

.cartAddRow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.cartAddRow .groceryItemPicker {
    flex: 1 1 auto;
    max-width: 480px;
}

.cartActions {
    display: flex;
    gap: 8px;
    padding-top: 10px;
}

.cartTable .cartQuantity {
    width: 90px;
}

.cartTable .aisleHeader > .MuiTableCell-root {
    background-color: #b3c5da;
    font-weight: 700;
}

.groceryItemPicker,
.aislePicker,
.unitPicker {
    min-width: 200px;
}
