﻿@import url('https://fonts.googleapis.com/css?family=Poppins');

/* ============================================================
   SOUTHERN CHILL A/C AND HEATING -- "ICY BLUE" THEME
   Swapped from Young's orange/salmon palette to a cool blue/teal
   scheme fitting the "Chill" branding.
   FROST   #EAF6FB  (light backgrounds / text on dark)
   SKY     #38BDF8  (primary accent / buttons)
   DEEP    #0C4A6E  (dark panels)
   NAVY    #0F2A3A  (page background)
   TEAL    #14B8A6  (secondary accent)
   FROSTBITE RED #DC2626 (kept for delete/error -- universal warning color)
   ============================================================ */

html {
    scroll-behavior: smooth;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}

body {
    min-height: 100vh;
    background: linear-gradient(to bottom right, #0F2A3A, #0C4A6E);
}

/* -------------------- */
/* LOGIN PAGE STYLES */
/* -------------------- */

.container {
    width: 90%;
    max-width: 28rem;
    margin: 6vh auto;
}

.form-box {
    width: 100%;
    padding: 2rem;
    background: #10344A;
    border-radius: 0.6rem;
    box-shadow: 0 0 0.8rem rgba(0, 0, 0, 0.35);
    display: none;
}

.form-box.active {
    display: block;
}

h2 {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 1rem;
    color: #38BDF8;
}

input,
select {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: none;
    border-radius: 0.4rem;
    outline: none;
    background: #eeeeee;
    color: #333333;
    font-size: 1rem;
}

button {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: none;
    border-radius: 0.4rem;
    background: #38BDF8;
    color: #0C1E2B;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: #0EA5E9;
    color: white;
}

.error-message {
    margin-bottom: 1rem;
    padding: 0.8rem;
    border-radius: 0.4rem;
    background: #fecaca;
    color: #991b1b;
    text-align: center;
}

/* -------------------- */
/* ADMIN / USER PAGE STYLES */
/* -------------------- */

.admin-page {
    background: #0F2A3A;
    color: #EAF6FB;
}

.admin-wrapper {
    width: 96%;
    max-width: 80rem;
    margin: 3vh auto;
    padding: 2rem;
    background: #10344A;
    border-radius: 0.6rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.admin-title {
    font-size: 1.6rem;
    color: white;
    margin-bottom: 0.3rem;
}

.admin-subtitle {
    color: #a8c6d8;
    font-size: 0.95rem;
}

.logout-button {
    width: auto;
    margin-bottom: 0;
    background: #DC2626;
    color: white;
    padding: 0.7rem 1rem;
}

.logout-button:hover {
    background: #b91c1c;
}

.message {
    padding: 0.8rem;
    border-radius: 0.4rem;
    margin-bottom: 1rem;
}

.message.success {
    background: #0f4d3f;
    color: #d1fae5;
}

.message.error {
    background: #7f1d1d;
    color: #fee2e2;
}

.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.page-link {
    display: inline-block;
    text-decoration: none;
    background: #17495F;
    color: white;
    padding: 0.7rem 1rem;
    border-radius: 0.4rem;
}

.page-link:hover {
    background: #1E5A73;
}

/* FILTER AREA */
.filter-box {
    margin-bottom: 2rem;
    padding: 1rem;
    background: #0F2A3A;
    border-radius: 0.6rem;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
}

.filter-label {
    display: block;
    width: 100%;
    color: #EAF6FB;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}

.filter-select {
    width: 100%;
    max-width: 18rem;
    margin-bottom: 0;
    flex: 0 0 18rem;
}

.filter-button,
.clear-filter-button {
    width: auto;
    min-width: 6.5rem;
    padding: 0.55rem 0.9rem;
    margin-bottom: 0;
    font-size: 0.9rem;
    line-height: 1.2;
}

.filter-button {
    background: #14B8A6;
    color: #0C1E2B;
    font-weight: 600;
}

.filter-button:hover {
    background: #0d9488;
}

.clear-filter-button {
    background: #17495F;
    color: white;
}

.clear-filter-button:hover {
    background: #1E5A73;
}

@media (max-width: 700px) {
  .desktop-only {
    display: none !important;
  }
}


   Each stock item is a card with a header (Part ID + actions) and
   a CSS grid of labeled fields below. auto-fill/minmax means it
   naturally reflows from several fields per row on a wide desktop
   down to one per row on a phone, with no separate breakpoint
   rules needed for this component specifically.
   ============================================================ */

.stock-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stock-card {
    background: #10344A;
    border: 1px solid #1E5A73;
    border-radius: 0.6rem;
    padding: 1.1rem 1.4rem;
    scroll-margin-top: 1.2rem;
}

.stock-card-editing {
    border-color: #38BDF8;
    box-shadow: 0 0 0 1px #38BDF8;
}

.stock-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 0.9rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid #1E5A73;
}

/* Collapsible summary row -- tap/click toggles the rest of the fields */
.stock-card-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.3rem 0;
    border-radius: 0.4rem;
}

.stock-card-summary::-webkit-details-marker {
    display: none;
}

.stock-card-summary::marker {
    content: "";
}

.stock-card-summary:hover {
    background: rgba(56, 189, 248, 0.06);
}

.summary-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    padding-right: 1.4rem;
}

.summary-top-row::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid #7dd3fc;
    border-bottom: 2px solid #7dd3fc;
    transform: translateY(-70%) rotate(45deg);
    transition: transform 0.15s ease;
}

.stock-card-details[open] .summary-top-row::after {
    transform: translateY(-30%) rotate(-135deg);
}

.summary-part-type {
    font-weight: 600;
    color: #EAF6FB;
    font-size: 1rem;
}

.summary-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.summary-right .calc-price {
    font-size: 1.05rem;
}

.summary-description {
    margin-top: 0.35rem;
    color: #a8c6d8;
    font-size: 0.88rem;
    line-height: 1.35;
}

.stock-card-details .stock-card-fields {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #1E5A73;
}

.stock-card-partid {
    font-size: 1.15rem;
    font-weight: 700;
    color: #38BDF8;
    word-break: break-word;
}

.stock-card-actions {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.stock-card-actions .small-btn,
.stock-card-actions .table-link {
    width: auto;
    margin-bottom: 0;
}

.stock-card-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem 1.4rem;
}

.field-wide {
    grid-column: 1 / -1;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.field-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7dd3fc;
    font-weight: 600;
}

.field-value {
    color: #EAF6FB;
    font-size: 0.95rem;
    word-break: break-word;
}

.field-group input {
    width: 100%;
    margin-bottom: 0;
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    color: black;
}

.field-value.calc-price {
    font-size: 1.05rem;
}

.empty-state {
    padding: 1.5rem;
    text-align: center;
    color: #a8c6d8;
    background: #10344A;
    border-radius: 0.6rem;
}

@media (max-width: 480px) {
    .stock-card-fields {
        grid-template-columns: 1fr 1fr;
    }
}

.stock-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.stock-table input[type=text], .stock-table input[type=number] {
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
    padding: 0.4rem;
    font-size: 0.85rem;
    color: black;
}

.stock-table .small-btn {
    width: auto;
    margin-bottom: 0;
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
}

.stock-table {
    width: 100%;
    border-collapse: collapse;
    background: #0F2A3A;
    table-layout: fixed;
}

.stock-table th,
.stock-table td {
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid #1E5A73;
    vertical-align: middle;
    overflow-wrap: break-word;
}

/* Give the actions column enough room */
.stock-table th:last-child,
.stock-table td:last-child {
    width: 14%;
    min-width: 8rem;
}

.stock-table th {
    background: #0A2030;
    color: #f8fafc;
}

.stock-table td {
    color: #EAF6FB;
}

/* Calculated price + low-stock styling */
.calc-price {
    color: #14B8A6;
    font-weight: 600;
}

.calc-price.price-missing {
    color: #a8c6d8;
    font-weight: 400;
    font-style: italic;
    font-size: 0.85rem;
}

.low-stock {
    color: #f87171;
    font-weight: 600;
}

.low-stock-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    border-radius: 1rem;
    background: #7f1d1d;
    color: #fee2e2;
    font-size: 0.7rem;
    vertical-align: middle;
}

.action-cell {
    white-space: nowrap;
}

.table-link {
    display: inline-block;
    margin-right: 0.35rem;
    color: #7dd3fc;
    text-decoration: none;
}

.table-link:hover {
    text-decoration: underline;
}

.current-admin-text {
    color: #a8c6d8;
    font-size: 0.9rem;
}

.inline-form {
    display: inline;
    margin-left: 0.35rem;
}

.small-btn {
    width: auto;
    margin-bottom: 0;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
}

.delete-btn {
    background: #DC2626;
    color: white;
}

.delete-btn:hover {
    background: #991b1b;
}

.admin-card {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #0F2A3A;
    border-radius: 0.6rem;
}

.admin-card h2 {
    text-align: left;
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: #38BDF8;
}

.admin-card label {
    display: block;
    margin-bottom: 0.4rem;
    color: #EAF6FB;
    font-size: 0.95rem;
}

.primary-submit {
    background: #14B8A6;
    color: #0C1E2B;
    font-weight: 600;
}

.primary-submit:hover {
    background: #0d9488;
}

.field-hint {
    display: block;
    margin-top: -0.6rem;
    margin-bottom: 1rem;
    color: #a8c6d8;
    font-size: 0.8rem;
}

/* ============================================================
   MOBILE RESPONSIVE
   With cost/markup/bin/unit/reorder columns added on top of the
   original 5, the horizontal-scroll table gets cramped even with
   small font sizes. Below 700px we switch the table to a stacked
   "card" layout: each row becomes a block, each cell becomes its
   own labeled line (label pulled from a data-label attribute set
   in the PHP output). This keeps every column readable on a phone
   instead of forcing sideways scrolling.
   ============================================================ */

@media (max-width: 576px) {

  .container {
    width: 92%;
  }

  .form-box {
    padding: 1.4rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .admin-wrapper {
    width: 96%;
    padding: 1rem;
    overflow-x: hidden;
  }

  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-title {
    font-size: 1.3rem;
  }

  .admin-subtitle {
    font-size: 0.9rem;
  }

  .logout-button {
    width: 100%;
    text-align: center;
  }

  .admin-links {
    flex-direction: column;
  }

  .page-link {
    width: 100%;
    text-align: center;
  }

  .filter-form {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-label {
    margin-bottom: 0.35rem;
  }

  .filter-select {
    max-width: 100%;
    flex: 1 1 auto;
  }

  .filter-button,
  .clear-filter-button {
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  .admin-card {
    padding: 1rem;
  }
}

@media (max-width: 700px) {

  .stock-table-wrapper {
    width: 100%;
    overflow-x: hidden;
  }

  .stock-table,
  .stock-table thead,
  .stock-table tbody,
  .stock-table th,
  .stock-table td,
  .stock-table tr {
    display: block;
  }

  .stock-table thead {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .stock-table tr {
    margin-bottom: 1rem;
    border: 1px solid #1E5A73;
    border-radius: 0.5rem;
    padding: 0.5rem 0.8rem;
    background: #10344A;
  }

  .stock-table td {
    border-bottom: none;
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    text-align: right;
  }

  .stock-table td:not(:last-child) {
    border-bottom: 1px solid #17495F;
  }

  .stock-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #7dd3fc;
    text-align: left;
    flex: 0 0 auto;
    margin-right: 0.6rem;
  }

  .stock-table td.action-cell {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .stock-table td.action-cell::before {
    text-align: center;
    margin-bottom: 0.4rem;
  }

  .stock-table th:last-child,
  .stock-table td:last-child {
    width: auto;
    min-width: 0;
  }

  .table-link {
    display: block;
    margin-right: 0;
    margin-bottom: 0.35rem;
    text-align: center;
  }

  .inline-form {
    display: block;
    margin-left: 0;
  }

  .small-btn,
  .stock-table .small-btn,
  .delete-btn {
    width: 100%;
    margin-right: 0;
    margin-bottom: 0;
    text-align: center;
  }

  .stock-table input[type=text],
  .stock-table input[type=number] {
    max-width: 60%;
    text-align: right;
  }
}
