/* ============================================
   BAC CALCULATOR - CSS
   Version 1.0
============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

.baccalc-wrap * { box-sizing: border-box; margin: 0; padding: 0; }

.baccalc-wrap {
    --blue:        #0D9488;
    --darkblue:    #0F2A3D;
    --cyan:        #14B8A6;
    --amber:       #E8A33D;
    --red:         #E0554F;
    --grad:        #0D9488;
    --grad-soft:   rgba(13,148,136,0.08);
    --white:       #FFFFFF;
    --bg:          #F2F7F6;
    --card-bg:     #FFFFFF;
    --border:      rgba(13,148,136,0.14);
    --text:        #0F2A3D;
    --text-muted:  #5C7A80;
    --shadow-card: 0 32px 80px rgba(15,42,61,0.16), 0 8px 24px rgba(13,148,136,0.10);
    --shadow-btn:  0 12px 32px rgba(13,148,136,0.40);
    --radius-xl:   24px;
    --radius-lg:   16px;
    --radius-md:   12px;
    --radius-sm:   8px;
    font-family: 'Inter', sans-serif;
    position: relative;
    padding: 32px 20px 60px;
    background: var(--bg);
    min-height: 100%;
    color: var(--text);
}

.baccalc-blob { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: 0; }
.baccalc-blob-1 { width: 380px; height: 380px; background: rgba(13,148,136,0.13); top: -100px; left: -100px; }
.baccalc-blob-2 { width: 320px; height: 320px; background: rgba(15,42,61,0.08); bottom: 0; right: -100px; }

.baccalc-card { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; }

/* ---- Safety banner (always visible) ---- */
.baccalc-safety-banner { background: #FEF3E8; border: 1.5px solid var(--amber); border-radius: var(--radius-md); padding: 12px 16px; font-size: 12px; color: #7A4A0F; line-height: 1.55; margin-bottom: 16px; }
.baccalc-safety-banner strong { color: #5C3709; }

/* ---- Header ---- */
.baccalc-header { background: var(--grad); border-radius: var(--radius-xl); padding: 26px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-card); margin-bottom: 20px; }
.baccalc-header::after { content: ''; position: absolute; width: 260px; height: 260px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -100px; right: -60px; }
.baccalc-header-left { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.baccalc-header-icon { width: 50px; height: 50px; background: rgba(255,255,255,0.18); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.25); }
.baccalc-header-text h1 { color: #fff; font-size: 19px; font-weight: 800; letter-spacing: -0.4px; }
.baccalc-header-text p { color: rgba(255,255,255,0.78); font-size: 12px; margin-top: 4px; }
.baccalc-icon-btn { width: 40px; height: 40px; background: rgba(255,255,255,0.16); border: 1px solid rgba(255,255,255,0.28); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; position: relative; z-index: 1; transition: background 0.2s; }
.baccalc-icon-btn:hover { background: rgba(255,255,255,0.26); }

/* ---- History panel ---- */
.baccalc-history-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); }
.baccalc-history-panel.baccalc-history-open { max-height: 420px; overflow-y: auto; margin-bottom: 20px; }
.baccalc-history-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; font-size: 13px; font-weight: 800; color: var(--text); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-bg); }
.baccalc-history-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; line-height: 1; }
.baccalc-history-list { padding: 14px 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.baccalc-history-empty { font-size: 13px; color: var(--text-muted); padding: 20px 0; text-align: center; }
.baccalc-history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; cursor: pointer; }
.baccalc-history-item:hover { border-color: var(--blue); }
.baccalc-history-item-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.baccalc-history-item-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.baccalc-history-item-btn { border: 1.5px solid var(--border); background: var(--white); color: var(--red); font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 700; border-radius: 7px; padding: 6px 11px; cursor: pointer; flex-shrink: 0; }

/* ---- Explainer ---- */
.baccalc-explainer { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); margin-bottom: 20px; overflow: hidden; }
.baccalc-explainer-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--grad-soft); border: none; cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--text); font-family: 'Inter', sans-serif; }
.baccalc-explainer-toggle svg { color: var(--blue); transition: transform 0.25s ease; flex-shrink: 0; }
#baccalc_explainer_arrow.baccalc-explainer-arrow-open { transform: rotate(180deg); }
.baccalc-explainer-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; padding: 0 24px; }
.baccalc-explainer-body.baccalc-explainer-open { max-height: 420px; padding: 16px 24px; }
.baccalc-explainer-body p { font-size: 12.5px; color: var(--text-muted); line-height: 1.65; margin-bottom: 10px; }
.baccalc-explainer-body p:last-child { margin-bottom: 0; }
.baccalc-explainer-body strong { color: var(--text); }

/* ---- Fields ---- */
.baccalc-mode-panel { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); padding: 24px 28px; margin-bottom: 20px; }
.baccalc-field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.baccalc-field { margin-bottom: 16px; }
.baccalc-field:last-child { margin-bottom: 0; }
.baccalc-field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.4px; }
.baccalc-hint-inline { text-transform: none; font-weight: 500; opacity: 0.75; font-size: 11px; }
.baccalc-input, .baccalc-plain-input {
    width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    padding: 11px 12px; font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600; color: var(--text);
    background: var(--white); outline: none; transition: border-color 0.2s;
}
.baccalc-input:focus, .baccalc-plain-input:focus { border-color: var(--blue); }

.baccalc-unit-input-wrap { display: flex; gap: 6px; }
.baccalc-unit-input-wrap .baccalc-plain-input { flex: 1; min-width: 0; }
.baccalc-unit-static { display: flex; align-items: center; padding: 0 12px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); background: var(--bg); border-radius: var(--radius-sm); border: 1.5px solid var(--border); flex-shrink: 0; white-space: nowrap; }

.baccalc-time-row { display: flex; gap: 10px; }
.baccalc-time-row .baccalc-unit-input-wrap { flex: 1; }

/* ---- Segmented toggle ---- */
.baccalc-toggle-row { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; cursor: default; margin-bottom: 0; }
.baccalc-toggle-row span:first-child { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.baccalc-seg-toggle { display: flex; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 5px; width: 100%; }
.baccalc-seg-btn { flex: 1; background: none; border: none; color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; border-radius: var(--radius-sm); padding: 9px 6px; cursor: pointer; }
.baccalc-seg-btn:hover { color: var(--blue); }
.baccalc-seg-btn.baccalc-seg-active { background: var(--grad); color: #fff; }

/* ---- Clear-all row ---- */
.baccalc-clear-all-row { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.baccalc-clear-all-btn { background: var(--white); border: 1.5px solid var(--border); color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 11.5px; font-weight: 700; border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; }
.baccalc-clear-all-btn:hover { border-color: var(--red); color: var(--red); }

/* ---- Drinks table (fixed 4 categories) ---- */
.baccalc-drinks-head { font-size: 13px; font-weight: 800; color: var(--text); background: var(--grad-soft); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px; }
.baccalc-drink-table-wrap { overflow-x: auto; }
.baccalc-drink-table-head, .baccalc-drink-row {
    display: grid; grid-template-columns: 90px 1.2fr 80px 1.6fr 1.3fr 90px; gap: 10px; align-items: center;
}
.baccalc-drink-table-head { padding: 0 4px 8px; }
.baccalc-drink-table-head > div { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.baccalc-drink-rows { display: flex; flex-direction: column; gap: 8px; }
.baccalc-drink-row { background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; min-width: 640px; }
.baccalc-drink-col-type { font-size: 13px; font-weight: 800; color: var(--text); }
.baccalc-drink-col-std { background: var(--white); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 9px 8px; font-size: 12.5px; font-weight: 800; color: var(--blue); text-align: center; }
.baccalc-drink-col-size, .baccalc-drink-col-abv { min-width: 0; }
.baccalc-drink-col-size .baccalc-unit-input-wrap { margin-top: 6px; }

/* ---- Extra (unlimited) drink rows ---- */
.baccalc-drink-row-extra { grid-template-columns: 110px 1.2fr 80px 1.6fr 1.3fr 90px 34px; }
.baccalc-drink-row-extra .baccalc-drink-col-type select { width: 100%; }
.baccalc-drink-col-std-wrap { display: contents; }
.baccalc-drink-remove { width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(224,85,79,0.10); color: var(--red); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.baccalc-add-row-btn { width: 100%; background: var(--white); border: 2px dashed var(--border); color: var(--blue); font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700; border-radius: var(--radius-md); padding: 12px; cursor: pointer; }
.baccalc-add-row-btn:hover { background: var(--grad-soft); }

/* ---- Result ---- */
.baccalc-result { background: var(--card-bg); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); border: 1px solid var(--border); padding: 24px 28px; }
.baccalc-result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.baccalc-result-badge { font-size: 13px; font-weight: 800; color: var(--text); }
.baccalc-input-recap { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.baccalc-input-recap:empty { display: none; margin: 0; }

.baccalc-due-card { background: var(--grad); border-radius: var(--radius-lg); padding: 22px; text-align: center; margin-bottom: 16px; position: relative; overflow: hidden; }
.baccalc-due-card::after { content: ''; position: absolute; width: 160px; height: 160px; background: rgba(255,255,255,0.06); border-radius: 50%; top: -70px; right: -50px; }
.baccalc-due-label { color: rgba(255,255,255,0.8); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; position: relative; }
.baccalc-due-value { color: #fff; font-size: 36px; font-weight: 900; letter-spacing: -0.5px; margin: 6px 0; position: relative; word-break: break-word; }
.baccalc-due-sub { color: rgba(255,255,255,0.85); font-size: 12px; font-weight: 500; position: relative; }

.baccalc-safety-result { border-radius: var(--radius-md); padding: 14px 16px; font-size: 13px; font-weight: 700; line-height: 1.55; margin-bottom: 16px; text-align: center; }
.baccalc-safety-result.baccalc-safety-under { background: rgba(45,106,79,0.10); border: 1.5px solid #2D6A4F; color: #2D6A4F; }
.baccalc-safety-result.baccalc-safety-over { background: rgba(224,85,79,0.10); border: 1.5px solid var(--red); color: var(--red); }

.baccalc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.baccalc-stats:empty { display: none; margin-bottom: 0; }
.baccalc-stat-card { background: var(--bg); border-radius: var(--radius-md); padding: 14px; text-align: center; border: 1px solid var(--border); }
.baccalc-stat-icon { font-size: 16px; margin-bottom: 4px; }
.baccalc-stat-value { font-size: 15.5px; font-weight: 800; color: var(--text); word-break: break-word; }
.baccalc-stat-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); margin-top: 2px; }

.baccalc-breakdown-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 14px; }
.baccalc-breakdown-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.baccalc-table-wrap { overflow-x: auto; }
.baccalc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.baccalc-table th { text-align: left; font-weight: 700; color: var(--text-muted); padding: 6px 8px; border-bottom: 1.5px solid var(--border); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.baccalc-table td { padding: 8px; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 600; white-space: nowrap; }
.baccalc-table tr:last-child td { border-bottom: none; }
.baccalc-table tr.baccalc-table-total td { font-weight: 800; color: var(--blue); border-top: 2px solid var(--border); }

/* ---- Sobering timeline ---- */
.baccalc-timeline-card { background: var(--bg); border-radius: var(--radius-md); border: 1px solid var(--border); padding: 16px; margin-bottom: 14px; }
.baccalc-timeline-title { font-size: 12.5px; font-weight: 800; color: var(--text); margin-bottom: 14px; }
.baccalc-timeline-bars { display: flex; flex-direction: column; gap: 10px; }
.baccalc-timeline-row { display: grid; grid-template-columns: 90px 1fr 70px; gap: 10px; align-items: center; }
.baccalc-timeline-label { font-size: 11.5px; font-weight: 700; color: var(--text); }
.baccalc-timeline-track { background: var(--white); border: 1px solid var(--border); border-radius: 100px; height: 16px; overflow: hidden; }
.baccalc-timeline-fill { height: 100%; background: var(--grad); border-radius: 100px; transition: width 0.4s ease; }
.baccalc-timeline-val { font-size: 11.5px; font-weight: 800; color: var(--blue); text-align: right; }

.baccalc-actions-row { margin-bottom: 10px; }
.baccalc-save-btn { width: 100%; background: var(--grad); color: #fff; border: none; font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 800; border-radius: var(--radius-md); padding: 14px; cursor: pointer; box-shadow: var(--shadow-btn); }
.baccalc-export-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.baccalc-export-btn { background: var(--white); border: 1.5px solid var(--border); color: var(--text); font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; border-radius: var(--radius-sm); padding: 11px 6px; cursor: pointer; }
.baccalc-export-btn:hover { border-color: var(--blue); color: var(--blue); }

.baccalc-footer-note { font-size: 10.5px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* ---- Responsive ---- */
@media (max-width: 780px) {
    .baccalc-field-grid { grid-template-columns: 1fr; }
    .baccalc-stats { grid-template-columns: 1fr 1fr; }
    .baccalc-seg-toggle { flex-direction: column; }
    .baccalc-timeline-row { grid-template-columns: 70px 1fr 55px; }
}
