﻿@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap");

:root {
    --bg-dark: #f3ede2;
    --bg: #f5f2ed;
    --bg-light: #ffffff;
    --text: #17140f;
    --text-muted: #6b6255;
    --border: #17140f;

    --thin-black-border: 1px solid var(--border);
    --black-border: 2px solid var(--border);

    /*--accent: #ffcf3f;*/
    --accent: #FFB200;
    --accent-light: hsl(from var(--accent) h s calc(l + 20));
    --accent-very-light: hsl(from var(--accent) h s calc(l + 40));

    --secondary: #40c76b;
    /*--secondary: #0072e4;*/
    --secondary-light: hsl(from var(--secondary) h s calc(l + 20));
    --secondary-very-light: hsl(from var(--secondary) h s calc(l + 30));

    --tertiary: #ff6100;
    --tertiary-light: hsl(from var(--tertiary) h s calc(l + 20));
    --tertiary-very-light: hsl(from var(--tertiary) h s calc(l + 30));

    /*--happy: #2fb463;*/
    --happy: #5dc95d;
    --bad: #a3271e;
    --bad-light: hsl(from var(--bad) h s calc(l + 20));
    --bad-very-light: hsl(from var(--bad) h s calc(l + 50));

    --color-accent-orange: #ff6a1a;
    --color-accent-purple: #8b5cf6;

    --container-max: min(72rem, 100vw - 2rem);
    --radius: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-pill: 1rem;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
}

* {
    box-sizing: border-box;
    font-size: 16px;
    margin: 0;
    padding: 0;
    /*color: var(--text);*/
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: "Inter", Arial, Helvetica, sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-dark);
    overscroll-behavior-y: none;
}

a {
    text-decoration: none;
    font-weight: 600;
    color: var(--text);
}

.container {
    width: min(100% - (2 * var(--space-4)), var(--container-max));
}


.focusable-primary:has(:focus-visible), .focusable-primary:focus-visible {
    border: 1px solid var(--accent);
}


.focusable-secondary:has(:focus-visible), .focusable-secondary:focus-visible {
    border: 1px solid var(--secondary);
}

.pill {
    padding: var(--space-2) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 1000;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.pill span {
    text-wrap: nowrap;
    white-space: pre;
}

.pill:disabled {
    cursor: context-menu;
}

.primary {
    background: var(--accent);
}

.primary && .active {
    background: var(--accent-light);
}

.primary-hoverable:hover {
    background: var(--accent-light);
}

.secondary {
    background: var(--secondary);
}

.secondary && .active {
    background: var(--secondary-light);
}

.secondary-hoverable:hover {
    background: var(--secondary-light);
}

.tertiary {
    background: var(--tertiary);
}

.tertiary && .active {
    background: var(--tertiary-light);
}

.tertiary-hoverable:hover {
    background: var(--tertiary-light);
}

nav {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
}

header {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-8);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
}

.site-brand {
    margin: 0;
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    /*padding: var(--space-4) 0;*/
    display: flex;
    flex-direction: row;
}

#user-info {
    margin-left: var(--space-8);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#company-name {
    font-weight: normal;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    /*padding: var(--space-4);*/
    gap: var(--space-8);
    margin: var(--space-2);
}

section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
}

h1,
h2,
h3 {
    font-family: "Space Grotesk", "Inter", sans-serif;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-top: 0;
}

h1 {
    margin: 0;
    padding: var(--space-4) 0;
    font-size: 2rem;
}

h2 {
    margin-bottom: var(--space-4);
}

label {
    display: block;
    font-weight: 600;
    /*margin-bottom: var(--space-1);*/
}

input,
select,
textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: var(--thin-black-border);
    border-radius: var(--radius);
    color: inherit;
    background: var(--bg-light);
    font-family: inherit;
    font-size: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
}

.card {
    background: var(--bg-light);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

. {
    color: var(--text-muted);
}

.center-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-text {
    text-align: center;
}

.full-width {
    width: 100%;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: 0.5rem;
    width: 100%;
}

/* CELL/ROW STATES */
.table-container {
    overflow-x: auto;
    border: var(--black-border);
    border-radius: var(--radius-lg);
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-light);
}

.translation-table {
    table-layout: fixed;
    width: 100%;
}

tr {
    height: 1px;
}

tbody .empty-row {
    background: var(--bg-light);
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
    height: 200px;
}

.empty-row && .primary {
    background: var(--accent-light);
}

th,
td {
    padding: var(--space-3) var(--space-4);
}

th:first-child,
td:first-child {
    padding-left: var(--space-6);
}

th:last-child,
td:last-child {
    padding-right: var(--space-6);
}

td:has(.full-cell-text-area) {
    height: 1px;
    margin: 0;
    padding: 0;
    border-left: var(--thin-black-border);
}

.full-cell-text-area {
    border-radius: 0;
    /*border: 1px solid green;*/
    border: 1px solid transparent;
    height: 100%;
    margin: 0;
    text-wrap: wrap;
    resize: none;
    text-align: center;
}

.full-cell-text-area {
    background: var(--bg);
}

.full-cell-text-area:required:invalid {
    background: var(--bad-very-light);
}

.full-cell-text-area:required:valid {
    background: var(--secondary-very-light);
}

.full-cell-text-area:required:invalid:focus {
    border-color: var(--bad);
}

/*tr:has(.full-cell-text-area):not(:has(.full-cell-text-area[required])) {*/
/*    background: var(--bg-dark);*/
/*}*/

/*tr:has(.full-cell-text-area.filled) .full-cell-text-area.empty {*/
/*    background: var(--bg-light);*/
/*}*/


th {
    color: var(--text);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    /*background: var(--secundary-very-light);*/
    border-bottom: var(--black-border);
}

#purchase-price-table th {
    background: var(--accent);
}

tr:not(:last-child) {
    border-bottom: var(--thin-black-border);
}

tr .updated-cell {
    background: var(--accent-light);
}

tbody .error {
    font-style: italic;
    background: var(--bad-very-light);
}

tbody .new_row {
    background: var(--happy);
}

tbody .to-be-removed {
    background: hsl(from var(--bg-light) h s calc(l - 10));
    text-decoration: line-through;
}

.archived {
    color: var(--text-muted);
    background: hsl(from var(--bg-light) h s calc(l - 10));
}

.selected {
    background: var(--tertiary);
}

.selected:hover {
    background: var(--tertiary-light);
}

.selected:disabled {
    background: var(--tertiary-very-light);
}

.out-of-sync {
    background: hsl(from var(--bg-light) h s calc(l - 10));
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    background: var(--secondary-very-light);
}

.money-input {
    max-width: 140px;
    min-width: 100px;
    display: flex;
    flex-direction: row;
    /*align-items: center;*/
    /*gap: var(--space-2);*/
    border: var(--thin-black-border);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    background: var(--accent-very-light);
}

.money-input:hover {
    background: var(--bg-light);
    cursor: text;
}

.money-input input {
    width: 100%;
    border: none;
    border-radius: 0;
    padding: 0;
    text-align: right;
    background: transparent;
}

.up-to-date .money-input {
    background: transparent;
}


.money-input input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.input-up {
    background: var(--happy);
}

.input-down {
    background: var(--bad);
}

.input-equal {
    background: var(--accent-very-light);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.archive-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--happy);
    cursor: pointer;
}

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
    overflow-y: auto;
    z-index: 1000;
}

.popup-overlay[hidden] {
    display: none;
}

.popup-container {
    background: var(--bg-light);
    border: var(--black-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    width: 100%;
    max-width: 48rem;
    box-shadow: 0 10px 30px rgba(23, 20, 15, 0.2);
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: var(--black-border);
    border-radius: var(--radius);
    background: var(--bg-light);
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.icon-button:hover {
    background: var(--bg-dark);
    border-color: var(--border);
}


form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}


.field-error {
    color: var(--bad);
    font-size: 0.875rem;
    margin-top: var(--space-1);
}

.required-marker {
    color: var(--secondary);
}


.flash {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    border: var(--black-border);
    margin-bottom: var(--space-4);
}

.flash-success {
    background: var(--bg-light);
    border-color: var(--happy);
}

.flash-error {
    background: var(--bg-light);
    border-color: var(--bad);
}

/* PRICE LIST EDITOR */
.label-and-field-control {
    display: flex;
    flex-direction: row;
    gap: var();
}
.label-and-field-control > * {
    flex-basis: 0;
    flex-grow: 1;
    flex-shrink: 1;
}

#price-list-editor {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

#price-list-editor .controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

#price-list-editor .controls > * {
    display: flex;
    flex-direction: row;
    gap: var(--space-2);
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

#price-list-product-container {
    min-height: 100px;
    border: var(--thin-black-border);
    border-radius: var(--radius);
    padding: var(--space-3);
}

.product-selector-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.error-message {
    color: var(--bad);
    margin: var(--space-4) 0;
}

@media (max-width: 44rem) {
    .site-brand {
        flex-direction: column;
    }

    #user-info {
        margin-left: 0;
        margin-top: var(--space-2);
    }
    nav {
        flex-direction: column;
        justify-content: space-between;
        align-items: stretch;
        gap: 0.5rem;
    }

    main .container {
        min-width: 100%;
    }
}
