/* ═══════════════════════════════════════════════════════
   3CHEM DEALER PORTAL — PUBLIC CSS
   ═══════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────── */
:root {
    --tc-red:       #cc0000;
    --tc-red-dark:  #a50000;
    --tc-red-light: #fff5f5;
    --tc-gray-50:   #f8f9fb;
    --tc-gray-100:  #f1f3f6;
    --tc-gray-200:  #e2e6ed;
    --tc-gray-500:  #8b909e;
    --tc-gray-700:  #4a4f5e;
    --tc-dark:      #1a1d2e;
    --tc-white:     #ffffff;
    --tc-font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --tc-radius:    10px;
    --tc-shadow:    0 12px 50px rgba(0,0,0,.22);
}

/* ── Red Button ────────────────────────────────────── */
.tchem-open-btn {
    display: inline-flex;
    align-items: center;
    background: var(--tc-red);
    color: #fff !important;
    border: none;
    border-radius: 6px;
    padding: 11px 24px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--tc-font);
    cursor: pointer;
    letter-spacing: .3px;
    box-shadow: 0 3px 14px rgba(204,0,0,.38);
    transition: background .2s, transform .15s, box-shadow .2s;
    text-decoration: none;
}
.tchem-open-btn:hover {
    background: var(--tc-red-dark);
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(204,0,0,.45);
}
.tchem-open-btn:active { transform: translateY(0); }

/* ── Overlay ───────────────────────────────────────── */
.tchem-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,12,24,.72);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
    animation: tcFadeIn .2s ease;
}
@keyframes tcFadeIn { from { opacity:0 } to { opacity:1 } }

/* Body lock when dashboard open */
body.tchem-dashboard-open { overflow: hidden; }

/* ── Modal Wrap ────────────────────────────────────── */
.tchem-modal-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: tcSlideUp .25s ease;
}
@keyframes tcSlideUp { from { opacity:0; transform:translateY(20px) } to { opacity:1; transform:translateY(0) } }

/* ── Login Box ─────────────────────────────────────── */
.tchem-login-box {
    background: var(--tc-white);
    border-radius: var(--tc-radius);
    box-shadow: var(--tc-shadow);
    width: 100%;
    max-width: 420px;
    padding: 32px 28px 24px;
    position: relative;
}

.tchem-logo {
    text-align: center;
    margin-bottom: 20px;
}
.tchem-logo h2 {
    font-size: 32px;
    font-weight: 900;
    color: var(--tc-red);
    margin: 0;
    line-height: 1;
    font-family: var(--tc-font);
}
.tchem-logo h2 span { color: var(--tc-dark); }
.tchem-logo p { margin: 4px 0 0; font-size: 12px; color: var(--tc-gray-500); letter-spacing: .5px; }

.tchem-close-btn {
    position: absolute;
    top: 14px; right: 16px;
    background: var(--tc-gray-100);
    border: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--tc-gray-700);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.tchem-close-btn:hover { background: var(--tc-gray-200); }

.tchem-form-title { margin: 0 0 18px; font-size: 17px; font-weight: 700; color: var(--tc-dark); text-align: center; }

/* ── Forms ─────────────────────────────────────────── */
.tchem-form-group { margin-bottom: 14px; }
.tchem-form-group label {
    display: block; margin-bottom: 5px;
    font-size: 13px; font-weight: 600; color: var(--tc-gray-700);
}
.tchem-form-group input[type=text],
.tchem-form-group input[type=password] {
    width: 100%; box-sizing: border-box;
    padding: 10px 14px; border: 1.5px solid var(--tc-gray-200);
    border-radius: 7px; font-size: 14px; font-family: var(--tc-font);
    outline: none; transition: border-color .2s, box-shadow .2s;
    background: #fff;
}
.tchem-form-group input:focus {
    border-color: var(--tc-red);
    box-shadow: 0 0 0 3px rgba(204,0,0,.1);
}
.tchem-pw-wrap { position: relative; }
.tchem-pw-wrap input { padding-right: 42px; }
.tchem-eye {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--tc-gray-500); padding: 3px;
    display: flex; align-items: center;
}
.tchem-eye:hover { color: var(--tc-red); }
.tchem-hint { margin: 12px 0 0; font-size: 11px; color: var(--tc-gray-500); text-align: center; }

/* ── Alerts ────────────────────────────────────────── */
.tchem-alert {
    padding: 10px 14px; border-radius: 6px;
    font-size: 13px; margin-bottom: 12px;
}
.tchem-alert-error   { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6cb; }
.tchem-alert-success { background: #f0fff4; color: #1a7a3c; border: 1px solid #b2dfcc; }
.tchem-alert-info    { background: #fff8e1; color: #856404; border: 1px solid #ffe08a; }

/* ── Buttons ───────────────────────────────────────── */
.tchem-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: 7px; font-size: 14px; font-weight: 600;
    cursor: pointer; border: none; font-family: var(--tc-font);
    transition: background .18s, transform .12s, box-shadow .18s;
    text-decoration: none; white-space: nowrap;
}
.tchem-btn-full   { width: 100%; margin-top: 6px; }
.tchem-btn-primary {
    background: var(--tc-red); color: #fff;
    box-shadow: 0 2px 10px rgba(204,0,0,.28);
}
.tchem-btn-primary:hover { background: var(--tc-red-dark); transform: translateY(-1px); }
.tchem-btn-outline {
    background: #fff; color: var(--tc-red);
    border: 2px solid var(--tc-red);
}
.tchem-btn-outline:hover { background: var(--tc-red-light); }
.tchem-btn-logout {
    background: rgba(255,255,255,.15); color: #fff;
    border: 1.5px solid rgba(255,255,255,.4);
    font-size: 13px; padding: 7px 14px;
}
.tchem-btn-logout:hover { background: rgba(255,255,255,.28); }

/* ═══════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════ */
.tchem-dashboard {
    position: fixed; inset: 0; z-index: 10000000;
    background: var(--tc-gray-50);
    display: flex; flex-direction: column;
    font-family: var(--tc-font);
    overflow: hidden;
    animation: tcFadeIn .18s ease;
}

/* Header */
.tchem-dash-header {
    margin-top: 40px !important;
    background: var(--tc-red);
    padding: 12px 24px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,.14);
    flex-shrink: 0;
}
.tchem-dash-logo { font-size: 20px; font-weight: 900; color: #fff; }
.tchem-dash-logo span { color: rgba(255,255,255,.7); }
.tchem-dash-logo small { font-size: 12px; font-weight: 400; opacity: .8; margin-left: 6px; }
.tchem-dash-right { display: flex; align-items: center; gap: 14px; }
.tchem-welcome-text { font-size: 13px; color: rgba(255,255,255,.9); }
.tchem-welcome-text strong { color: #fff; }

/* Body */
.tchem-dash-body {
    flex: 1; overflow-y: auto; padding: 20px 24px;
    display: flex; flex-direction: column; gap: 20px;
}

/* Footer */
.tchem-dash-footer {
    background: var(--tc-white); border-top: 1px solid var(--tc-gray-200);
    padding: 10px 24px; text-align: center; flex-shrink: 0;
}
.tchem-dash-footer p { margin: 0; font-size: 12px; color: var(--tc-gray-500); }
.tchem-dash-footer a { color: var(--tc-red); text-decoration: none; font-weight: 600; }
.tchem-dash-footer a:hover { text-decoration: underline; }

/* ── Section Card ──────────────────────────────────── */
.tchem-charts-row,
.tchem-filters-wrap,
#tchem-stock-result,
#tchem-stock-empty,
#tchem-stock-loading {
    background: var(--tc-white);
    border: 1px solid var(--tc-gray-200);
    border-radius: var(--tc-radius);
    padding: 18px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

/* ── Pie Charts ────────────────────────────────────── */
.tchem-charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tchem-chart-card h3 {
    margin: 0 0 12px; font-size: 13px; font-weight: 700;
    color: var(--tc-gray-700); text-align: center; text-transform: uppercase; letter-spacing: .4px;
    padding-bottom: 8px; border-bottom: 2px solid var(--tc-red);
}
.tchem-chart-inner {
    position: relative; max-width: 260px; margin: 0 auto;
}
.tchem-chart-inner canvas { width: 100% !important; height: auto !important; }
.tchem-chart-empty {
    text-align: center; padding: 40px 0; color: var(--tc-gray-500); font-size: 13px;
}

/* ── Filters ───────────────────────────────────────── */
.tchem-filters-wrap {
    display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end;
}
.tchem-filter-group { display: flex; flex-direction: column; gap: 5px; }
.tchem-filter-group > label {
    font-size: 11px; font-weight: 700; color: var(--tc-gray-500);
    text-transform: uppercase; letter-spacing: .5px;
}
.tchem-filter-group select {
    padding: 8px 12px; border: 1.5px solid var(--tc-gray-200);
    border-radius: 6px; font-size: 13px; font-family: var(--tc-font);
    outline: none; cursor: pointer;
    transition: border-color .15s;
}
.tchem-filter-group select:focus { border-color: var(--tc-red); }
.tchem-date-picker {
    padding: 8px 12px; border: 1.5px solid var(--tc-gray-200);
    border-radius: 6px; font-size: 13px; font-family: var(--tc-font);
    background: #fff; color: var(--tc-dark);
    cursor: pointer; width: 150px; outline: none;
    transition: border-color .15s;
}
.tchem-date-picker:focus {
    border-color: var(--tc-red);
    box-shadow: 0 0 0 3px rgba(204,0,0,.1);
}
.tchem-radio-group { display: flex; gap: 14px; align-items: center; }
.tchem-radio-label { font-size: 13px; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.tchem-disabled    { opacity: .45; cursor: not-allowed; }
.tchem-filter-btns { flex-direction: row !important; align-items: flex-end; gap: 10px; }

/* ── Stock Table ───────────────────────────────────── */
.tchem-table-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px; flex-wrap: wrap; gap: 6px;
}
.tchem-table-meta span { font-size: 13px; font-weight: 600; color: var(--tc-dark); }
.tchem-table-count     { font-size: 12px; color: var(--tc-gray-500); font-weight: 400 !important; }
.tchem-table-wrap { overflow-x: auto; border-radius: 7px; border: 1px solid var(--tc-gray-200); }
.tchem-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tchem-table thead th {
    background: var(--tc-dark); color: #fff;
    padding: 10px 12px; text-align: left; font-weight: 600; white-space: nowrap;
}
.tchem-table tbody tr { border-bottom: 1px solid var(--tc-gray-200); }
.tchem-table tbody tr:hover { background: var(--tc-red-light); }
.tchem-table tbody td { padding: 8px 12px; color: var(--tc-dark); }
.tchem-total-row td { background: var(--tc-gray-100); border-top: 2px solid var(--tc-gray-200); padding: 9px 12px; }
.tchem-qty { text-align: right !important; font-variant-numeric: tabular-nums; }

.tchem-loading { text-align: center; padding: 32px; color: var(--tc-gray-500); font-size: 14px; }
.tchem-empty   { text-align: center; padding: 32px; color: var(--tc-gray-500); font-size: 14px; background: var(--tc-gray-100) !important; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .tchem-dash-header  { padding: 10px 14px; }
    .tchem-dash-body    { padding: 12px 14px; }
    .tchem-welcome-text { display: none; }
    .tchem-charts-row   { grid-template-columns: 1fr; }
    .tchem-filters-wrap { flex-direction: column; align-items: flex-start; }
    .tchem-filter-btns  { flex-direction: row !important; }
    .tchem-table thead th, .tchem-table tbody td { padding: 7px 9px; font-size: 12px; }
    .tchem-login-box { padding: 24px 18px 20px; }
}
@media (max-width: 480px) {
    .tchem-overlay { align-items: flex-end; padding: 0; }
    .tchem-login-box { border-radius: 14px 14px 0 0; max-width: 100%; }
}

/* ═══════════════════════════════════════════════════
   MOBILE TOUCH & RESPONSIVE FIXES v1.3.0
   ═══════════════════════════════════════════════════ */

/* Touch fix — all clickable elements */
.tchem-open-btn,
.tchem-btn,
.tchem-close-btn,
.tchem-eye,
.tchem-radio-label,
#btn-retrieve,
#btn-download-pdf,
#tchem-login-btn,
#tchem-logout-btn,
#tchem-change-pass-btn {
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Prevent iOS input zoom */
@media (max-width: 768px) {
    .tchem-form-group input[type=text],
    .tchem-form-group input[type=password],
    .tchem-filter-group select,
    .tchem-date-picker {
        font-size: 16px !important;
    }
}

/* ── Mobile 768px ── */
@media (max-width: 768px) {

    /* Login box — bottom sheet */
    .tchem-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .tchem-modal-wrap {
        align-items: flex-end;
        width: 100%;
    }
    .tchem-login-box {
        border-radius: 18px 18px 0 0;
        max-width: 100%;
        width: 100%;
        padding: 24px 20px 32px;
        max-height: 92vh;
        overflow-y: auto;
    }

    /* Dashboard header */
    .tchem-dash-header {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .tchem-dash-logo { font-size: 17px; }
    .tchem-welcome-text { display: none; }
    .tchem-btn-logout { font-size: 12px; padding: 6px 12px; }

    /* Dashboard body */
    .tchem-dash-body { padding: 12px 12px; gap: 12px; }

    /* Pie charts — stack */
    .tchem-charts-row { grid-template-columns: 1fr !important; gap: 12px; }
    .tchem-chart-inner { max-width: 240px; }

    /* Filters — stack */
    .tchem-filters-wrap {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
    }
    .tchem-filter-group { width: 100%; }
    .tchem-filter-group select,
    .tchem-date-picker { width: 100%; padding: 10px 12px; }
    .tchem-radio-group { gap: 20px; }
    .tchem-radio-label { font-size: 14px; }

    /* Buttons full width on mobile */
    #btn-retrieve,
    #btn-download-pdf {
        width: 100%;
        padding: 12px;
        font-size: 14px;
        margin-top: 4px;
    }

    /* Stock table scroll */
    .tchem-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tchem-table { min-width: 500px; }
    .tchem-table thead th,
    .tchem-table tbody td { padding: 7px 8px; font-size: 11px; }

    /* Footer */
    .tchem-dash-footer { padding: 10px 14px; }
    .tchem-dash-footer p { font-size: 11px; }
}

/* ── Small Mobile 480px ── */
@media (max-width: 480px) {
    .tchem-login-box { padding: 20px 16px 28px; }
    .tchem-logo h2 { font-size: 26px; }
    .tchem-logo p { font-size: 11px; }
    .tchem-form-title { font-size: 16px; }
    .tchem-open-btn { font-size: 13px; padding: 9px 16px; }
    .tchem-dash-logo { font-size: 15px; }
    .tchem-chart-inner { max-width: 200px; }
}

/* ═══════════════════════════════════════════
   CRITICAL MOBILE FIX — ELEMENTOR OVERRIDE
   ═══════════════════════════════════════════ */
#tchem-open-btn,
.tchem-open-btn {
    position: relative !important;
    z-index: 99999 !important;
    pointer-events: all !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    display: inline-flex !important;
}
#tchem-overlay {
    z-index: 9999999 !important;
}
