/* =========================================================
   RECIPE APPLICATION
   Styled to match the main website dark theme
   ========================================================= */

/* ---------------------------------------------------------
   FONT & COLOR VARIABLES
   --------------------------------------------------------- */
:root {
    --default-font: "Roboto", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
    --heading-font: "Raleway", sans-serif;
    --nav-font: "Poppins", sans-serif;

    --background-color: #040b14;
    --default-color: #ffffff;
    --heading-color: #ffffff;
    --accent-color: #149ddd;
    --surface-color: #151f2b;
    --surface-color-2: #1c2937;
    --surface-color-3: #263646;
    --contrast-color: #ffffff;

    --border-color: rgba(255, 255, 255, 0.10);
    --border-color-strong: rgba(255, 255, 255, 0.18);
    --muted-color: rgba(255, 255, 255, 0.70);

    --field-bg: #f4f8fc;
    --field-text: #17212b;
    --field-placeholder: #667788;
    --field-border: #8193a5;

    --danger-color: #6b2930;
    --danger-border: #9c3e49;

    scroll-behavior: smooth;
}

/* Same reusable preset used by the main website. */
.dark-background {
    --background-color: #040b14;
    --default-color: #ffffff;
    --heading-color: #ffffff;
    --surface-color: #151f2b;
    --contrast-color: #ffffff;
}

.light-background {
    --background-color: #f4fafd;
    --default-color: #272829;
    --heading-color: #050d18;
    --surface-color: #ffffff;
    --contrast-color: #ffffff;
}

/* ---------------------------------------------------------
   GENERAL
   --------------------------------------------------------- */
* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background-color);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--default-color);
    background: var(--background-color);
    font-family: var(--default-font);
    font-size: 16px;
    line-height: 1.55;
}

a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.3s, background-color 0.3s, border-color 0.3s;
}

a:hover,
a:focus {
    color: color-mix(in srgb, var(--accent-color), white 25%);
    text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--heading-color);
    font-family: var(--heading-font);
}

p {
    color: var(--default-color);
}

small,
footer {
    color: var(--muted-color);
}

footer {
    margin-top: 30px;
}

.wrap {
    width: min(1120px, calc(100% - 32px));
    margin: auto;
}

/* ---------------------------------------------------------
   HERO / PAGE HEADER
   --------------------------------------------------------- */
.hero {
    padding: 42px 0;
    color: var(--default-color);
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.hero h1,
.hero h2,
.hero h3 {
    margin-top: 0;
    color: var(--heading-color);
}

.top,
.grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

/* ---------------------------------------------------------
   CARDS
   --------------------------------------------------------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 30px 0;
}

.card,
.panel,
.recipe-page article {
    color: var(--default-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.12);
}

.card {
    transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--border-color-strong);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.22);
}

.card img {
    display: block;
    width: 100%;
    height: 190px;
    object-fit: cover;
}

.card div {
    padding: 16px;
}

.card h2 {
    margin: 0.3rem 0;
}

.card h2 a,
.card h2 a:hover,
.card h2 a:focus {
    text-decoration: none;
}

.card h2 a {
    color: var(--heading-color);
}

.card h2 a:hover,
.card h2 a:focus {
    color: var(--accent-color);
}

/* ---------------------------------------------------------
   RECIPE PAGE
   --------------------------------------------------------- */
.recipe-page {
    max-width: 850px;
    padding: 28px 0;
}

.recipe-page article,
.panel {
    padding: 25px;
}

.recipe-page article h1 {
    margin-top: 0;
}

.recipe-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.recipe-section h2 {
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent-color);
}

/* ---------------------------------------------------------
   PANELS
   --------------------------------------------------------- */
.panel {
    max-width: 600px;
    margin: 30px auto;
}

.panel.wide {
    max-width: 1180px;
}

/* ---------------------------------------------------------
   FORM CONTROLS

   Forms intentionally keep a light editing surface so text
   remains easy to read throughout the admin application.
   --------------------------------------------------------- */
input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    color: var(--field-text);
    background: var(--field-bg);
    border: 1px solid var(--field-border);
    border-radius: 5px;
    font: inherit;
    line-height: 1.45;
    transition: border-color 0.3s, box-shadow 0.3s, background-color 0.3s;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--field-placeholder);
    opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    color: #101820;
    background: #ffffff;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color), transparent 75%);
}

select option {
    color: #17212b;
    background: #ffffff;
}

label {
    display: block;
    flex: 1;
    min-width: 200px;
    color: var(--heading-color);
    font-weight: 600;
}

label input,
label select,
label textarea {
    margin-top: 5px;
    font-weight: 400;
}

/* ---------------------------------------------------------
   BUTTONS
   --------------------------------------------------------- */
button,
.button,
.print-button {
    display: inline-block;
    width: auto;
    padding: 10px 16px;
    color: var(--contrast-color);
    background: var(--accent-color);
    border: 0;
    border-radius: 5px;
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, transform 0.2s;
}

button:hover,
button:focus,
.button:hover,
.button:focus,
.print-button:hover,
.print-button:focus {
    color: #ffffff;
    background: color-mix(in srgb, var(--accent-color), black 20%);
    text-decoration: none;
}

button:active,
.button:active,
.print-button:active {
    transform: translateY(1px);
}

button.secondary,
.button.secondary {
    color: #ffffff;
    background: var(--surface-color-3);
    border: 1px solid var(--border-color-strong);
}

button.secondary:hover,
button.secondary:focus,
.button.secondary:hover,
.button.secondary:focus {
    color: #ffffff;
    background: #34495e;
}

/* ---------------------------------------------------------
   TABLES
   --------------------------------------------------------- */
.table {
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--heading-color);
    background: var(--surface-color-2);
    font-family: var(--heading-font);
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.035);
}

tbody tr:last-child td {
    border-bottom: 0;
}

/* ---------------------------------------------------------
   SECTION EDITOR
   --------------------------------------------------------- */
.section-editor {
    display: grid;
    gap: 10px;
    padding: 16px;
    margin: 12px 0;
    background: var(--surface-color-2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.section-editor input,
.section-editor select,
.section-editor textarea {
    color: #121b24;
    background: #f7faff;
    border-color: #91a4b6;
}

.section-editor textarea {
    min-height: 170px;
}

/* ---------------------------------------------------------
   MESSAGES
   --------------------------------------------------------- */
.error {
    padding: 10px;
    color: #ffffff;
    background: var(--danger-color);
    border: 1px solid var(--danger-border);
    border-radius: 5px;
}

/* ---------------------------------------------------------
   RECIPE SEARCH
   --------------------------------------------------------- */
.search {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 16px;
}

.search-keyword {
    width: 100%;
}

.search-keyword input {
    display: block;
    width: 100%;
}

.search-filters {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(180px, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.search-filters select {
    width: 100%;
    min-width: 0;
}

.search-filters button,
.search-filters .button {
    width: auto;
    white-space: nowrap;
}

/* ---------------------------------------------------------
   RECIPE ACTION BUTTONS
   --------------------------------------------------------- */
.recipe-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 18px;
}

.recipe-actions .back-link {
    display: inline-block;
}

.print-button {
    font-size: 0.95rem;
}

/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */
@media (max-width: 650px) {
    .wrap {
        width: min(100% - 24px, 1120px);
    }

    .hero {
        padding: 30px 0;
    }

    .cards {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 20px 0;
    }

    .panel,
    .recipe-page article {
        padding: 18px;
    }

    .search-filters {
        grid-template-columns: 1fr 1fr;
    }

    .search-filters button,
    .search-filters .button {
        width: 100%;
        text-align: center;
    }

    .recipe-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .recipe-actions .back-link,
    .recipe-actions .print-button {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .search-filters {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   PRINT FRIENDLY RECIPE

   Keep this at the end of the stylesheet. These rules
   intentionally override all dark-screen styling.
   ========================================================= */
@media print {
    @page {
        size: auto;
        margin: 0.5in;
    }

    html,
    body {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        color: #000000 !important;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 11pt;
        line-height: 1.4;
    }

    .recipe-actions,
    .print-button,
    .back-link {
        display: none !important;
    }

    .recipe-page > p {
        display: none !important;
    }

    .wrap,
    .recipe-page {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #000000 !important;
    }

    .recipe-page article {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        color: #000000 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    .recipe-page article,
    .recipe-page article p,
    .recipe-page article li,
    .recipe-page article h1,
    .recipe-page article h2,
    .recipe-page article h3 {
        color: #000000 !important;
    }

    .recipe-page h1 {
        margin: 4pt 0 12pt 0 !important;
        padding: 0 !important;
        font-size: 24pt !important;
        line-height: 1.15 !important;
        font-weight: 700 !important;
        color: #000000 !important;
    }

    .recipe-page small {
        display: block !important;
        margin: 0 0 5pt 0 !important;
        color: #555555 !important;
        font-size: 9pt !important;
        font-weight: normal !important;
    }

    .recipe-section {
        display: block !important;
        width: 100% !important;
        margin: 0 0 14pt 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .recipe-section h2 {
        margin: 16pt 0 7pt 0 !important;
        padding: 0 0 4pt 0 !important;
        color: #000000 !important;
        font-size: 15pt !important;
        font-weight: 700 !important;
        border-bottom: 1px solid #999999 !important;
        page-break-after: avoid;
        break-after: avoid;
    }

    .recipe-section ul,
    .recipe-section ol {
        margin: 6pt 0 12pt 0 !important;
        padding-left: 24pt !important;
        color: #000000 !important;
    }

    .recipe-section li {
        margin: 0 0 3pt 0 !important;
        padding: 0 !important;
        color: #000000 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .recipe-image {
        display: block !important;
        width: auto !important;
        height: auto !important;
        max-width: 3.5in !important;
        max-height: 2.5in !important;
        margin: 0 0 12pt 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        object-fit: contain !important;
    }

    .recipe-page footer {
        display: block !important;
        margin: 18pt 0 0 0 !important;
        padding: 6pt 0 0 0 !important;
        color: #666666 !important;
        font-size: 8pt !important;
        background: transparent !important;
        border-top: 1px solid #cccccc !important;
    }

    .recipe-page a {
        color: #000000 !important;
        text-decoration: none !important;
    }
}
