/* ==========================================================================
   Coffee Grind Size — complete stylesheet
   ========================================================================== */

input {
    color: black !important;
}

.grind-size-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0px 20px 80px;
}

.grind-size-title {
    font-size: 2rem;
    margin-bottom: 4px;
}

.grind-size-subtitle {
    color: #777;
    margin-bottom: 28px;
}

.grind-size-denied {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

/* ── Add form ── */

.grind-form {
    background: var(--bg);
    border: 1px solid #e6ddd0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 36px;
}

.grind-form-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1.3fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.grind-field {
    display: flex;
    flex-direction: column;
}

.grind-field label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a8070;
    margin-bottom: 6px;
}

.grind-field input,
.grind-field textarea {
    border: 1px solid #d8cdbb;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.95rem;
    background: #fff;
    color: #2a1f14;
}

.grind-field input:focus,
.grind-field textarea:focus {
    outline: none;
    border-color: #b08d57;
}

.grind-field-notes {
    margin-bottom: 14px;
}

/* ── Buttons ── */

.grind-btn {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.grind-btn:hover { opacity: 0.82; }

.grind-btn-primary    { background: #6b4a2f; color: #fff; }
.grind-btn-save       { background: #4a7a5c; color: #fff; }
.grind-btn-cancel     { background: #e6ddd0; color: #5a5044; }
.grind-btn-delete     { background: #b3554a; color: #fff; }
.grind-btn-edit       { background: #efe7d8; color: #5a4a32; border: 1px solid #d8cdbb; }
.grind-btn-deactivate { background: #f0e8d8; color: #7a5a32; border: 1px solid #d8c8a8; }
.grind-btn-activate   { background: #2e7444; color: #fff; }

.grind-form-message {
    display: inline-block;
    margin-left: 12px;
    font-size: 0.85rem;
}
.grind-form-message.success { color: #4a7a5c; }
.grind-form-message.error   { color: #b3554a; }

/* ── Cards list ── */

.grind-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.grind-empty,
.grind-loading {
    text-align: center;
    color: #999;
    padding: 32px 0;
    font-size: 0.95rem;
}

/* ── Individual card ── */

.grind-card {
    background: var(--bg);
    border: 1px solid #e6ddd0;
    border-radius: 12px;
    padding: 18px 20px;
    transition: box-shadow 0.15s ease;
}

.grind-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

/* ── Card title row (name + badge inline) ── */
.grind-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.grind-card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.grind-card-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
}

.grind-card-updated {
    font-size: 0.75rem;
    color: #aaa;
    white-space: nowrap;
    padding-top: 3px;
}

.grind-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

/* ── Active / Inactive badge ── */
.grind-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.grind-active-on {
    background: rgba(74, 140, 90, 0.14);
    color: #2e7444;
    border: 1px solid rgba(74, 140, 90, 0.25);
}

.grind-active-off {
    background: rgba(170, 80, 60, 0.12);
    color: #9a3a2c;
    border: 1px solid rgba(170, 80, 60, 0.22);
}

/* ── Inactive card state ── */
.grind-card-inactive {
    opacity: 0.62;
    border-color: #ddd;
    filter: grayscale(0.35);
}

.grind-card-inactive .grind-chart-canvas {
    opacity: 0.55;
}

/* ── Base pill ── */
.grind-card-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    border-radius: 10px;
    padding: 12px 16px;
    min-width: 100px;
}

.grind-pill-icon {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    opacity: 0.85;
}

.grind-pill-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.grind-pill-value {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.1;
}

/* ── Dose pill — warm amber ── */
.grind-pill-dose {
    background: #7c4a1a;
    color: #fff;
}
.grind-pill-dose .grind-pill-label { color: #f0c98a; }
.grind-pill-dose .grind-pill-icon  { color: #f0c98a; }

/* ── Grind size pill — deep teal ── */
.grind-pill-grind {
    background: #1a4a4a;
    color: #fff;
}
.grind-pill-grind .grind-pill-label { color: #7ed8c8; }
.grind-pill-grind .grind-pill-icon  { color: #7ed8c8; }

/* ── Extraction pill — deep indigo ── */
.grind-pill-time {
    background: #2a1f5a;
    color: #fff;
}
.grind-pill-time .grind-pill-label { color: #b0a4f0; }
.grind-pill-time .grind-pill-icon  { color: #b0a4f0; }

/* ── Notes ── */
.grind-card-notes {
    font-size: 0.9rem;
    color: #555;
    background: #faf7f2;
    border: 1px solid #ece4d6;
    border-radius: 8px;
    padding: 10px 14px;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 14px;
    line-height: 1.6;
}

.grind-card-notes-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #a09080;
    margin-bottom: 5px;
    font-weight: 600;
}

.grind-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Chart area ── */
.grind-chart-wrap {
    margin: 14px 0 4px;
    padding: 14px 4px 6px;
    border-top: 1px solid #ece4d6;
    position: relative;
}

/* Explicit fixed-height container — prevents Chart.js from
   reading a growing clientHeight during mobile scroll */
.grind-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
}

.grind-chart-canvas {
    display: block;
    width: 100% !important;
    height: 220px !important;
    max-height: 220px;
}

.grind-chart-note {
    font-size: 0.72rem;
    color: #b0a090;
    margin: 6px 0 0;
    text-align: right;
    font-style: italic;
}

/* ── Edit state ── */

.grind-card.is-editing {
    border-color: #b08d57;
    background: #fdfaf5;
}

.grind-card-edit-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1.3fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.grind-card-edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.grind-card-edit-field label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a09080;
}

.grind-card-edit-field input,
.grind-card-edit-field textarea {
    border: 1px solid #b08d57;
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 0.9rem;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
}

.grind-card-edit-field input:focus,
.grind-card-edit-field textarea:focus {
    outline: none;
    border-color: #8a6030;
}

.grind-card-edit-notes {
    margin-bottom: 12px;
}

.grind-card-edit-notes label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a09080;
    display: block;
    margin-bottom: 4px;
}

.grind-card-edit-notes textarea {
    border: 1px solid #b08d57;
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 0.9rem;
    background: #fff;
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
}

.grind-size-content {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.grind-size-content.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Reactivate modal ── */
.grind-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 12, 6, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 20px;
}

.grind-modal-overlay.is-open {
    opacity: 1;
}

.grind-modal {
    background: #fdfaf5;
    border-radius: 16px;
    padding: 32px 28px 24px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
}

.grind-modal-overlay.is-open .grind-modal {
    transform: translateY(0) scale(1);
}

.grind-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2a1f14;
    margin: 0 0 8px;
}

.grind-modal-title em {
    font-style: italic;
    color: #8a6030;
}

.grind-modal-body {
    font-size: 0.93rem;
    color: #6a5a4a;
    margin: 0 0 20px;
    line-height: 1.6;
}

.grind-modal-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.grind-modal-option {
    display: grid;
    grid-template-columns: auto 28px 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    align-items: start;
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid #e6ddd0;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    background: #fff;
}

.grind-modal-option input[type="radio"] {
    grid-row: 1 / 3;
    grid-column: 1;
    align-self: center;
    width: 17px;
    height: 17px;
    accent-color: #b08d57;
    cursor: pointer;
    margin: 0;
}

.grind-modal-option-icon {
    grid-row: 1 / 3;
    grid-column: 2;
    align-self: center;
    font-size: 1.2rem;
    line-height: 1;
}

.grind-modal-option-label {
    grid-column: 3;
    grid-row: 1;
    font-size: 0.92rem;
    font-weight: 600;
    color: #2a1f14;
}

.grind-modal-option-sub {
    grid-column: 3;
    grid-row: 2;
    font-size: 0.78rem;
    color: #9a8a76;
    margin-top: 2px;
}

.grind-modal-option:has(input:checked) {
    border-color: #b08d57;
    background: #fdf7ed;
}

.grind-modal-grind-row {
    margin-bottom: 18px;
}

.grind-modal-grind-row label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #a09080;
    margin-bottom: 6px;
    font-weight: 600;
}

.grind-modal-input {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #b08d57;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.95rem;
    color: #2a1f14;
    background: #fff;
}

.grind-modal-input:focus {
    outline: none;
    border-color: #8a6030;
    box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.15);
}

.grind-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ── Responsive ── */

@media (max-width: 600px) {
    .grind-size-wrap {
        padding: 24px 14px 60px;
    }

    .grind-form-row {
        grid-template-columns: 1fr 1fr;
    }

    .grind-card-edit-grid {
        grid-template-columns: 1fr 1fr;
    }

    .grind-card-meta {
        gap: 10px 16px;
    }

    .grind-chart-canvas-wrap {
        height: 180px;
    }

    .grind-chart-canvas {
        height: 180px !important;
        max-height: 180px;
    }

    .grind-modal {
        padding: 24px 18px 18px;
    }
}

@media (max-width: 380px) {
    .grind-form-row {
        grid-template-columns: 1fr;
    }

    .grind-card-edit-grid {
        grid-template-columns: 1fr;
    }
}