/* =========================================================
   CSR MAIN CSS - Fully Integrated Clean Layout
   Works with current template + dynamic content
   ========================================================= */

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-alt: #f2f6ff;
    --text: #0f172a;
    --muted: #475569;
    --border: #d6deea;
    --border-strong: #b9c6dc;
    --primary: #1f5fbf;
    --primary-soft: #e6f0ff;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 6px 18px rgba(0,0,0,0.08);
    --font: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}

/* ================= Base ================= */

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

*, *:before, *:after {
    box-sizing: border-box
}

/* ================= Page Width ================= */

#page {
    /*    width: min(1200px,calc(100% - 24px));
    margin: 20px auto; */
    width: 90%;
    max-width: 1800px; /* optional safety cap */
    margin: 0 auto;
}

/* Ensure ALL content sections inherit full container width */
.contentdiv {
    width: 100%;
    box-sizing: border-box;
}

/* ================= Section Cards ================= */

.contentdiv {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-left: 5px solid var(--primary-soft);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
}

    .contentdiv h2,
    .contentdiv h3 {
        margin-top: 0;
        margin-bottom: 18px;
        padding-bottom: 8px;
        border-bottom: 2px solid var(--primary-soft);
    }

/* ================= CSR Support Panel ================= */

#logoout {
    float: right;
    width: 320px;
    max-width: 100%;
    margin-top: 10px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

    #logoout h4 {
        margin: 0 0 10px 0;
        font-size: 15px;
        text-align: center;
    }

.support-buttons {
    display: flex;
    gap: 10px;
}

#logoout .nicebut {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
}

/* ================= Buttons ================= */

.nicebut {
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    cursor: pointer;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    transition: all .15s ease;
    width: auto;
}

    .nicebut:hover {
        background: var(--primary-soft);
        border-color: var(--primary);
        transform: translateY(-1px);
    }

    .nicebut.block {
        width: 100%
    }

/* ================= Inputs ================= */

/* Default compact behaviour */
input[type="text"],
input[type="file"],
input[type="password"],
select,
textarea {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    font-size: 14px;
    width: auto; /* IMPORTANT FIX */
    max-width: 100%;
}

    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--primary);
        outline: none;
        box-shadow: 0 0 0 3px rgba(31,95,191,.15);
    }

/* Date fields */
.hasDatepicker {
    width: 120px !important;
}

/* ================= Supply Line ================= */

#sup p {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

#sup_initials {
    width: 56px !important;
    text-align: center;
    text-transform: uppercase;
}

#sup_numunits {
    width: 64px !important;
    text-align: center;
}

#sup_sku {
    min-width: 220px;
    max-width: 360px;
}

#pharma {
    width: 100px !important;
}

/* ================= Reports ================= */

#reports select {
    min-width: 180px;
}

#reports input[type="text"] {
    width: 120px;
}

/* ================= Product Management ================= */

#productmgmt input[type="text"] {
    width: 320px;
    max-width: 100%;
}

#pm_content,
#pm_editor {
    margin-top: 20px;
}

/* ================= Tables ================= */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

th {
    background: linear-gradient(180deg,#f7faff 0%,#eef4ff 100%);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tr:nth-child(even) td {
    background: #fafcff;
}

tr:hover td {
    background: var(--primary-soft);
}

/* ================= Dropzone ================= */

#dropzone {
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    background: var(--surface);
    transition: all .2s ease;
}

    #dropzone:hover {
        background: var(--primary-soft);
    }

/* ================= Mobile ================= */

@media(max-width:768px) {

    #page,
    .contentdiv {
        width: calc(100% - 16px);
        margin: 14px auto;
    }

    #logoout {
        float: none;
        width: 100%;
    }

    .nicebut {
        width: 100%;
    }

    table {
        font-size: 13px;
    }

    th, td {
        padding: 10px;
    }
}

@media screen and (max-width: 1200px) {
    #page {
        width: 96%;
    }
}

/* ======================================
   Product Management Tables
====================================== */

#productmgmt table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

#productmgmt th,
#productmgmt td {
    padding: 6px 8px;
    white-space: nowrap;
}

#productmgmt {
    overflow-x: auto; /* allow horizontal scroll if needed */
}

/* ==========================================
   Supply Section Alignment Fix
========================================== */

#sup {
    text-align: center!;
}

#sup br {
    display: block;
    margin: 6px 0;
}

/* ==========================================
   Supplier Releases Toggle (Admin)
   Restored show / hide behaviour
   ========================================== */

#asr {
    margin-bottom: 20px;
}

/* Header */
#asr .header {
    background: linear-gradient(180deg,#f7faff 0%,#eef4ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

#asr .header:hover {
    background: var(--primary-soft);
}

/* Content wrapper */
#asr .content {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--surface);
    overflow: hidden;
    max-height: 0;
    padding: 0 14px;
    transition: max-height 0.25s ease, padding 0.2s ease;
}

/* Active (expanded) */
#asr .content.active {
    max-height: 2000px;      /* large enough for table */
    padding: 14px;
}

/* Table inside toggle */
#asr .content table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
}

#asr .content th {
    background: #f1f5fb;
    font-weight: 600;
    padding: 8px;
}

#asr .content td {
    padding: 8px;
}

/* Ensure table scrolls nicely on small screens */
@media(max-width:768px) {
    #asr .content {
        overflow-x: auto;
    }

    #asr .content.active {
        max-height: 900px;
    }

    #asr .content table {
        min-width: 900px;
    }
}
