/*!
 * The shop's daily notebook.
 *
 * Presentation only, and only for markup this feature added: the list rows,
 * the two controls above them, the note editor, and the recent-notes strip
 * inside the till's modal. Nothing here reaches a table, form or modal that
 * belonged to another screen.
 *
 * The palette is the one the rest of the application already uses -- the same
 * violet as the sidebar and the POS accent, the same slate greys as the
 * dashboard -- so the notebook reads as part of the till rather than as
 * something bolted to it.
 *
 * Remove the single <link> in layouts/partials/css.blade.php to revert.
 */

/* ------------------------------------------------------------------
   The two controls above the list
   ------------------------------------------------------------------ */
.daily-note__controls {
    margin-bottom: 4px;
}

.daily-note__controls .form-group {
    margin-bottom: 10px;
}

#daily_note_search {
    /* The one thing on this screen somebody arrives wanting to use. */
    height: 42px;
    font-size: 15px;
}

/* ------------------------------------------------------------------
   A row of the list
   ------------------------------------------------------------------
   The row IS the note, not a link to it: a title if there is one, and
   then the opening of the body underneath. A notebook is read by
   scanning it, and a list of dates with an Edit button beside each is
   a list you have to open twelve times to read once.
   ------------------------------------------------------------------ */
.daily-note__row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.daily-note__title {
    font-weight: 700;
    color: #1B1230;
    line-height: 1.35;
}

.daily-note__excerpt {
    color: #64748B;
    font-size: 13px;
    line-height: 1.5;
    /* The excerpt is one paragraph's worth. The whole note is a click
       away and does not need to be in the list twice. */
    overflow-wrap: anywhere;
}

/* A note with a title gets a little air between it and its own body. */
.daily-note__title + .daily-note__excerpt {
    margin-top: 1px;
}

.daily-note__when {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    color: #4A3B63;
    font-weight: 600;
    font-size: 13px;
}

.daily-note__col-when {
    width: 1%;
    white-space: nowrap;
}

.daily-note__col-who,
.daily-note__col-action {
    width: 1%;
    white-space: nowrap;
}

/* ------------------------------------------------------------------
   The editor
   ------------------------------------------------------------------
   A note is prose, so it is set like prose: a readable line length, a
   line height with room between the lines, and the same face the rest
   of the application reads in.
   ------------------------------------------------------------------ */
.daily-note__editor {
    line-height: 1.6;
    font-size: 15px;
    resize: vertical;
    min-height: 150px;
}

.daily-note__author {
    margin: 10px 0 0;
    font-size: 12.5px;
    color: #64748B;
}

/* ------------------------------------------------------------------
   Recent notes, inside the till's modal
   ------------------------------------------------------------------
   Read-only, and deliberately small. It is there so a cashier can see
   that yesterday's note exists without leaving the sale; reading one
   properly is what the notebook screen is for.
   ------------------------------------------------------------------ */
.daily-note__recent {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed #E2E1EA;
}

.daily-note__recent-head {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #94A3B8;
}

.daily-note__recent-item {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 5px 0;
    border-bottom: 1px solid #F1F0F6;
    font-size: 13px;
}

.daily-note__recent-item:last-of-type {
    border-bottom: 0;
}

.daily-note__recent-when {
    flex: 0 0 auto;
    color: #94A3B8;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.daily-note__recent-text {
    color: #4A3B63;
    min-width: 0;
    overflow-wrap: anywhere;
}

.daily-note__recent-all {
    display: inline-block;
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: #7C3AED;
}

/* ------------------------------------------------------------------
   The till's notebook button
   ------------------------------------------------------------------
   Its own hue among the register tools, for the same reason each of
   those has one: three near-identical squares are told apart by colour
   before anybody reads a tooltip.
   ------------------------------------------------------------------ */
body.lockscreen .pos-form-actions .pos-tool--note svg {
    color: #FBBF24;
}


/* ------------------------------------------------------------------
   The three actions
   ------------------------------------------------------------------
   Icons on one line. Labelled buttons wrapped to two rows in a column
   this narrow, and widening the column would take the width from the
   note, which is the thing worth having it.

   Each is its own colour rather than a Bootstrap button class: the
   outline "primary" the Edit button wore put pale text on a violet
   fill and could barely be read.
   ------------------------------------------------------------------ */
.daily-note__act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    margin: 0 3px 0 0;
    border: 1px solid #E2E1EA;
    border-radius: 8px;
    background: #FFFFFF;
    color: #64748B;
    cursor: pointer;
    vertical-align: middle;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.daily-note__act:last-child {
    margin-right: 0;
}

/* Each hue is the one that colour already means in this application:
   the accent violet for the ordinary action, blue for looking, red for
   the one there is no undo for. */
.daily-note__act.is-view:hover,
.daily-note__act.is-view:focus-visible {
    border-color: #7DD3FC;
    background: #F0F9FF;
    color: #0284C7;
    outline: none;
}

.daily-note__act.is-edit:hover,
.daily-note__act.is-edit:focus-visible {
    border-color: #C4B5FD;
    background: #F5EFFE;
    color: #6D28D9;
    outline: none;
}

.daily-note__act.is-delete {
    color: #DC2626;
}

.daily-note__act.is-delete:hover,
.daily-note__act.is-delete:focus-visible {
    border-color: #FCA5A5;
    background: #FEF2F2;
    color: #B91C1C;
    outline: none;
}

/* The column holds all three on one line whatever the table decides
   about its width. */
.daily-note__col-action,
.daily-note__table td:nth-child(4) {
    white-space: nowrap;
}

/* ------------------------------------------------------------------
   Attachments
   ------------------------------------------------------------------
   A picture is shown, because the point of photographing a warranty
   card is to look at it. Anything else is a link with its own name on
   it.
   ------------------------------------------------------------------ */
.daily-note__attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed #E2E1EA;
}

.daily-note__attachment {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #E2E1EA;
    border-radius: 10px;
    overflow: hidden;
    background: #FFFFFF;
    text-decoration: none;
}

.daily-note__attachment.is-image {
    width: 96px;
    height: 96px;
}

.daily-note__attachment.is-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.daily-note__attachment.is-file {
    padding: 10px 14px;
    max-width: 100%;
    color: #4A3B63;
    font-size: 13px;
    font-weight: 600;
}

.daily-note__attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.daily-note__attachment:hover {
    border-color: #7C3AED;
    color: #5B21B6;
}

/* -- On the form ---------------------------------------------------- */
.daily-note__files {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.daily-note__file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border: 1px solid #EFEDF5;
    border-radius: 8px;
    font-size: 13px;
}

.daily-note__file a {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4A3B63;
}

.daily-note__file-remove {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #94A3B8;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.daily-note__file-remove:hover {
    background: #FEF2F2;
    color: #B91C1C;
}

.daily-note__file-input {
    /* A file input is not a text field and Bootstrap's .form-control
       height crops the browser's own button on some of them. */
    height: auto;
    padding: 7px 8px;
}
/* ------------------------------------------------------------------
   Phones
   ------------------------------------------------------------------
   A table is the wrong shape for a notebook on a 390px screen. Four
   columns left the note itself about ninety pixels wide, wrapping to
   one word a line beside a date that had room to spare.

   So each row becomes a card: the note, then the date under it, then
   the two buttons. The header row goes with the columns -- there is
   nothing left to label, and the sort it carried is not something
   anybody reaches for on a phone, where the list already opens on the
   newest note.

   Only the notebook's own table. Every rule here is under
   .daily-note__table, which is on this one table and no other.
   ------------------------------------------------------------------ */
@media (max-width: 767px) {
    .daily-note__table,
    .daily-note__table tbody,
    .daily-note__table tr,
    .daily-note__table td {
        display: block;
        width: auto !important;
    }

    .daily-note__table thead {
        display: none;
    }

    /* The note first, because it is what somebody is scrolling to read.
       Ordered rather than moved: the markup is a table and stays one,
       so the same rows serve both layouts. */
    .daily-note__table tbody tr {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 12px 2px;
        border-bottom: 1px solid #EFEDF5;
    }

    .daily-note__table tbody tr:last-child {
        border-bottom: 0;
    }

    .daily-note__table td {
        border: 0 !important;
        padding: 0 !important;
    }

    .daily-note__table td:nth-child(2) { order: 1; }
    .daily-note__table td:nth-child(1) { order: 2; }
    .daily-note__table td:nth-child(4) { order: 3; }

    /* Who wrote it goes. On a counter with one or two people it is the
       same name on every row, and it is the line with the least to say. */
    .daily-note__table td:nth-child(3),
    .daily-note__table .daily-note__col-who {
        display: none;
    }

    .daily-note__when {
        font-size: 11.5px;
        font-weight: 600;
        color: #94A3B8;
        white-space: nowrap;
    }

    .daily-note__excerpt {
        font-size: 13px;
    }

    /* An empty table still has one cell, and what is in it is a
       sentence rather than a row of a list. */
    .daily-note__table td.dataTables_empty {
        padding: 24px 8px !important;
        text-align: center;
        color: #64748B;
    }

    #daily_note_search {
        height: 44px;
    }
}

/* ------------------------------------------------------------------
   Reading a note
   ------------------------------------------------------------------
   The list shows the first hundred and forty characters, which is
   enough to recognise a note and not enough to read one. This is where
   the whole of it is, set as prose rather than as a field.
   ------------------------------------------------------------------ */
.daily-note__read-when {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: #94A3B8;
    font-variant-numeric: tabular-nums;
}

.daily-note__read-body {
    font-size: 15px;
    line-height: 1.7;
    color: #1B1230;
    /* The paragraphs the writer made, kept. nl2br gives back the line
       breaks; this keeps the runs of spaces they typed between them --
       a list written with indents stays a list. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* On a phone the row is a card, so the three actions sit under the note
   with a little more room around them than a table cell allowed. */
@media (max-width: 767px) {
    .daily-note__act {
        width: 34px;
        height: 34px;
        margin-right: 6px;
    }

    .daily-note__attachment.is-image {
        width: 78px;
        height: 78px;
    }

    .daily-note__attachment-name {
        max-width: 62vw;
    }
}
