/*
 * bidmaster.css
 *
 * Main stylesheet for BidMaster Django web application.
 * Color scheme and layout matches the original MS Access application exactly.
 *
 * Color reference:
 *   --navy:      #1f3864  (Bid/BOM form headers)
 *   --dark-red:  #8b0000  (Customer/Supplier form headers)
 *   --dark-green:#1e6b1e  (Item Master/Unit Master/Section Master headers)
 *   --irby-red:  #c00000  (Close buttons, required field indicators)
 *   --bg-grey:   #f0f0f0  (Form backgrounds, read-only fields)
 */

/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: Arial, sans-serif;
    font-size: 13px;
    background: #e8e8e8;
    color: #000;
}

a { color: inherit; text-decoration: none; }

/* ── CSS Variables ────────────────────────────────────────────────────── */
:root {
    --navy:         #1f3864;
    --navy-light:   #2e4d8a;
    --dark-red:     #8b0000;
    --dark-green:   #1e6b1e;
    --irby-red:     #c00000;
    --bg-grey:      #f0f0f0;
    --input-bg:     #d9d9d9;
    --border:       #999;
    --btn-face:     #e0e0e0;
    --btn-border:   #808080;
    --white:        #ffffff;
}

/* ── Main Menu ────────────────────────────────────────────────────────── */
.main-menu-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #e8e8e8;
}

.main-menu-box {
    border: 2px solid var(--irby-red);
    background: var(--white);
    padding: 24px 32px;
    width: 300px;
    text-align: center;
}

.main-menu-box .menu-title {
    text-align: left;
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.main-menu-logo {
    margin: 0 auto 20px;
    max-width: 180px;
}

.main-menu-logo img {
    width: 100%;
}

.menu-divider {
    border: none;
    border-top: 1px solid #ccc;
    margin: 16px 0;
}

/* Access-style menu buttons */
.menu-btn {
    display: block;
    width: 100%;
    padding: 6px 12px;
    margin-bottom: 8px;
    background: var(--btn-face);
    border: 1px solid var(--btn-border);
    border-radius: 2px;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    color: #000;
    text-decoration: none;
    transition: background 0.1s;
}

.menu-btn:hover {
    background: #d0d0d0;
    color: #000;
    text-decoration: none;
}

.menu-btn.exit {
    color: var(--irby-red);
    font-weight: bold;
}

/* ── Page Layout ──────────────────────────────────────────────────────── */
.page-wrapper {
    padding: 12px;
    min-height: 100vh;
}

/* ── Form Container ───────────────────────────────────────────────────── */
.bm-form-container {
    border: 2px solid var(--irby-red);
    background: var(--white);
    margin: 0 auto;
    max-width: 980px;
}

/* ── Form Headers ─────────────────────────────────────────────────────── */
.bm-header-navy {
    background: var(--navy);
    color: var(--white);
    text-align: center;
    padding: 14px;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.bm-header-red {
    background: var(--dark-red);
    color: var(--white);
    text-align: center;
    padding: 14px;
    font-size: 22px;
    font-weight: bold;
}

.bm-header-green {
    background: var(--dark-green);
    color: var(--white);
    text-align: center;
    padding: 14px;
    font-size: 22px;
    font-weight: bold;
}

/* ── Toolbar (top bar with buttons) ──────────────────────────────────── */
.bm-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-grey);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.bm-toolbar-center {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: auto;
}

.bm-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* ── Access-style Buttons ─────────────────────────────────────────────── */
.btn-access {
    padding: 4px 12px;
    background: var(--btn-face);
    border: 1px solid var(--btn-border);
    border-radius: 2px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    color: #000;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
    height: 26px;
    line-height: 18px;
    vertical-align: middle;
    box-sizing: border-box;
    min-width: 50px;
    text-align: center;
}

.btn-access:hover {
    background: #d0d0d0;
    color: #000;
    text-decoration: none;
}

.btn-access.btn-close {
    color: var(--irby-red);
}

.btn-access.btn-navy {
    background: var(--navy);
    color: var(--white);
    border-color: var(--navy);
}

.btn-access.btn-navy:hover {
    background: var(--navy-light);
    color: var(--white);
}

.btn-access.btn-red {
    background: var(--dark-red);
    color: var(--white);
    border-color: var(--dark-red);
}

.btn-access.btn-green {
    background: var(--dark-green);
    color: var(--white);
    border-color: var(--dark-green);
}

/* ── Summary Panel ────────────────────────────────────────────────────── */
.bm-summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0;
    padding: 8px 10px;
    background: var(--bg-grey);
    border-bottom: 1px solid var(--border);
    align-items: start;
}

.bm-summary-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bm-summary-center {
    text-align: center;
    padding: 0 20px;
}

.bm-summary-title {
    font-size: 20px;
    font-weight: bold;
    line-height: 1.2;
}

.bm-summary-status {
    font-size: 16px;
    font-weight: bold;
}

.bm-summary-fields {
    display: grid;
    grid-template-columns: auto auto;
    gap: 2px 8px;
    font-size: 12px;
}

.bm-summary-fields .field-label {
    font-weight: bold;
    text-align: left;
}

.bm-summary-fields .field-value {
    background: var(--input-bg);
    padding: 1px 4px;
    text-align: right;
    min-width: 120px;
}

.bm-summary-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Stats Bar ────────────────────────────────────────────────────────── */
.bm-stats-bar {
    padding: 4px 10px;
    font-size: 12px;
    color: var(--irby-red);
    font-weight: bold;
    background: var(--white);
    border-bottom: 1px solid var(--border);
}

.bm-stats-bar span {
    margin-right: 16px;
}

.bm-stats-bar .blank-margins {
    color: #000;
}

/* ── Tab Navigation ───────────────────────────────────────────────────── */
.bm-tabs {
    display: flex;
    gap: 0;
    padding: 0 10px;
    background: var(--bg-grey);
    border-bottom: 2px solid var(--border);
}

.bm-tab {
    padding: 5px 14px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid var(--border);
    border-bottom: none;
    background: var(--btn-face);
    color: #000;
    text-decoration: none;
    margin-right: 2px;
    margin-top: 4px;
    display: inline-block;
}

.bm-tab:hover {
    background: #d8d8d8;
    color: #000;
    text-decoration: none;
}

.bm-tab.active {
    background: var(--white);
    border-bottom: 2px solid var(--white);
    position: relative;
    top: 2px;
}

/* ── Tab Content Area ─────────────────────────────────────────────────── */
.bm-tab-content {
    padding: 12px;
    background: var(--white);
    min-height: 300px;
}

/* ── Form Fields ──────────────────────────────────────────────────────── */
.bm-field-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.bm-field-label {
    font-size: 12px;
    font-weight: bold;
    min-width: 110px;
    text-align: right;
    flex-shrink: 0;
}

.bm-field-label.required::before {
    content: "* ";
    color: var(--irby-red);
}

.bm-field-input {
    border: 1px solid var(--border);
    padding: 2px 4px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    background: var(--white);
    flex: 1;
}

.bm-field-input:focus {
    outline: 2px solid #0066cc;
    outline-offset: -1px;
}

.bm-field-input.readonly {
    background: var(--input-bg);
    color: #333;
}

.bm-field-input.wide { width: 100%; }
.bm-field-input.medium { width: 200px; }
.bm-field-input.small { width: 100px; }
.bm-field-input.xsmall { width: 60px; }

select.bm-field-input {
    padding: 1px 2px;
}

textarea.bm-field-input {
    resize: vertical;
    min-height: 50px;
}

/* Two-column form layout */
.bm-form-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
}

/* ── Subform / Grid ───────────────────────────────────────────────────── */
.bm-subform-header {
    background: var(--navy);
    color: var(--white);
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
}

.bm-subform-header.red {
    background: var(--dark-red);
}

.bm-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.bm-grid th {
    background: var(--navy);
    color: var(--white);
    padding: 4px 6px;
    font-size: 11px;
    font-weight: bold;
    text-align: left;
    border: 1px solid #ccc;
    white-space: nowrap;
}

.bm-grid td {
    padding: 2px 4px;
    border: 1px solid #ddd;
    vertical-align: middle;
}

.bm-grid tr:nth-child(even) td {
    background: #f5f5f5;
}

.bm-grid tr.selected td {
    background: #cce5ff;
}

.bm-grid tr:hover td {
    background: #e8f0fe;
}

.bm-grid td input,
.bm-grid td select {
    border: 1px solid var(--border);
    padding: 1px 3px;
    font-size: 12px;
    font-family: Arial, sans-serif;
    width: 100%;
    background: var(--white);
}

.bm-grid .col-delete {
    width: 24px;
    text-align: center;
}

.btn-delete-row {
    color: var(--irby-red);
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0 4px;
    line-height: 1;
}

.btn-delete-row:hover { color: #ff0000; }

/* ── Unit List Panel ──────────────────────────────────────────────────── */
.bm-unit-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 8px;
    height: 380px;
    overflow: hidden;
}

.bm-unit-panel {
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.bm-unit-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    border: none;
    max-height: 280px;
}

.bm-unit-panel-header {
    background: var(--navy);
    color: var(--white);
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
}

.bm-unit-list-item {
    display: grid;
    grid-template-columns: 50px 1fr 50px;
    padding: 2px 4px;
    font-size: 11px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.bm-unit-list-item:hover {
    background: #e8f0fe;
}

.bm-unit-list-item.selected {
    background: #cce5ff;
}

/* ── Item List Calculated Fields ──────────────────────────────────────── */
.bm-grid .col-margin { color: #000; font-weight: bold; }
.bm-grid .col-cost { text-align: right; }
.bm-grid .col-calc { text-align: right; background: var(--input-bg); }

.bm-item-description {
    font-size: 11px;
    color: #333;
    padding: 0 6px 4px;
}

.bm-historical {
    background: var(--bg-grey);
    border: 1px solid var(--border);
    padding: 4px 8px;
    font-size: 11px;
}

.bm-historical-header {
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
}

.bm-historical-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    text-align: right;
}

.bm-historical-grid .hist-val {
    color: var(--irby-red);
    font-weight: bold;
}

/* ── Alerts & Validation ──────────────────────────────────────────────── */
.bm-alert {
    padding: 6px 10px;
    margin: 8px;
    border: 1px solid;
    font-size: 12px;
    border-radius: 2px;
}

.bm-alert-success {
    background: #dff0d8;
    border-color: #3c763d;
    color: #3c763d;
}

.bm-alert-error {
    background: #f2dede;
    border-color: #a94442;
    color: #a94442;
}

.bm-required-note {
    font-size: 11px;
    color: var(--irby-red);
    padding: 6px 10px;
    border-top: 1px solid #ddd;
}

/* ── Modal / Dialog ───────────────────────────────────────────────────── */
.bm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bm-modal {
    background: var(--white);
    border: 2px solid var(--border);
    padding: 20px 28px;
    min-width: 280px;
    text-align: center;
    box-shadow: 4px 4px 12px rgba(0,0,0,0.3);
}

.bm-modal-message {
    font-size: 13px;
    margin-bottom: 16px;
}

.bm-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* ── Print / Report Styles ────────────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    body { background: white; font-size: 11px; }
    .bm-form-container { border: none; max-width: 100%; }
}

.report-wrapper {
    background: white;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-size: 12px;
}

.report-header {
    display: grid;
    grid-template-columns: 140px 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    align-items: start;
}

.report-title {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin: 12px 0 4px;
}

.report-subtitle {
    text-align: center;
    font-size: 14px;
    margin-bottom: 16px;
}

.report-contact-box {
    border: 1px solid #000;
    padding: 6px 8px;
    font-size: 11px;
}

.report-contact-box .box-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.report-section-header {
    background: #f0f0f0;
    border-top: 2px solid #000;
    border-bottom: 1px solid #000;
    padding: 3px 6px;
    font-weight: bold;
    font-size: 12px;
    margin-top: 12px;
}

.report-unit-header {
    display: flex;
    justify-content: space-between;
    padding: 2px 6px;
    font-weight: bold;
    font-size: 11px;
    border-bottom: 1px solid #ddd;
}

.report-item-row {
    display: grid;
    grid-template-columns: 50px 70px 120px 1fr 80px 80px;
    gap: 4px;
    padding: 2px 6px;
    font-size: 11px;
    border-bottom: 1px solid #f0f0f0;
}

.report-item-header {
    font-weight: bold;
    background: #e8e8e8;
    border-bottom: 1px solid #ccc;
}

.report-footer {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 10px;
    color: #666;
    border-top: 1px solid #ccc;
    margin-top: 16px;
}

/* ── Utility Classes ──────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-red { color: var(--irby-red); }
.text-bold { font-weight: bold; }
.text-small { font-size: 11px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.w-100 { width: 100%; }
.hidden { display: none; }

/* Force Close button appearance — override Bootstrap opacity */
a.btn-access.btn-close,
button.btn-access.btn-close {
    opacity: 1 !important;
    color: #c00000 !important;
    font-weight: 900 !important;
    background: #e0e0e0 !important;
    border: 1px solid #808080 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 12px !important;
    height: 26px !important;
}

a.btn-access.btn-close:hover,
button.btn-access.btn-close:hover {
    background: #d0d0d0 !important;
    color: #c00000 !important;
}
