/* ==========================================================================
   Flecom Tracking — Frontend
   v2.0.0 — All values driven by CSS custom properties injected in <head>
   ========================================================================== */

:root {
    --ft-primary: #2c3d50;
    --ft-primary-light: #3d5269;
    --ft-primary-dark: #1a2a3a;
    --ft-accent: #dc9814;
    --ft-accent-light: #f0b84a;
    --ft-accent-glow: rgba(220, 152, 20, 0.3);
    --ft-bg: #f0f2f5;
    --ft-bg-subtle: #f8f9fb;
    --ft-card-bg: rgba(255, 255, 255, 0.85);
    --ft-card-border: rgba(255, 255, 255, 0.6);
    --ft-text: #1a1a2e;
    --ft-text-muted: #6b7280;
    --ft-text-light: #9ca3af;
    --ft-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ft-heading: var(--ft-font);
    --ft-radius: 16px;
    --ft-radius-sm: 10px;
    --ft-radius-xs: 6px;
    --ft-speed: 0.3s;
    --ft-max-w: 800px;
    --ft-white: #fff;
    --ft-border: rgba(0,0,0,0.08);
    --ft-shadow: 0 8px 32px rgba(0,0,0,0.08);
    --ft-success: #10b981;
    --ft-info: #3b82f6;
    --ft-warning: #f59e0b;
    --ft-danger: #ef4444;
}

/* --- Base --- */
/* Hide WP page title on tracking page (plugin has its own) */
.page-template-default .ft-tracker ~ .entry-title,
.ft-tracker-page .entry-title,
.ft-tracker-page .page-title,
.ft-tracker-page h1.entry-title,
.ft-tracker-page article > header,
body.page .ft-tracker-wrap .entry-title,
.ft-tracker + .entry-title,
.has-ft-tracker .entry-title { display: none !important; }

.ft-tracker {
    font-family: var(--ft-font); color: var(--ft-text);
    max-width: var(--ft-max-w); margin: 0 auto; padding: 24px 16px 80px;
    width: 100%;
    -webkit-font-smoothing: antialiased;
}
.ft-tracker *, .ft-tracker *::before, .ft-tracker *::after { box-sizing: border-box; }

/* --- Dark class (for toggle mode) --- */
.ft-tracker.ft-dark {
    --ft-bg:#0f1117;--ft-bg-subtle:#1a1c25;--ft-text:#e5e7eb;--ft-text-muted:#9ca3af;--ft-text-light:#6b7280;
    --ft-border:rgba(255,255,255,0.08);--ft-card-bg:rgba(30,33,43,0.85);--ft-card-border:rgba(255,255,255,0.1);
    --ft-shadow:0 8px 32px rgba(0,0,0,0.3);--ft-white:#1e212b;
}

/* --- Hero --- */
.ft-hero {
    background: var(--ft-card-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--ft-card-border); border-radius: var(--ft-radius);
    padding: 44px 32px 36px; box-shadow: var(--ft-shadow);
    animation: ft-up var(--ft-speed) ease-out; text-align: center;
}
.ft-hero-top { display: flex; justify-content: center; align-items: center; position: relative; margin-bottom: 16px; }

/* Logo */
.ft-logo-wrap { animation: ft-float 3s ease-in-out infinite; }
.ft-logo { max-height: 52px; max-width: 200px; width: auto; object-fit: contain; }
.ft-logo-letter {
    width: 52px; height: 52px; border-radius: var(--ft-radius-sm);
    background: var(--ft-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; font-family: var(--ft-heading);
}

/* Dark toggle */
.ft-dark-toggle {
    position: absolute; right: 0; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--ft-bg-subtle); border: 1px solid var(--ft-border);
    color: var(--ft-text-muted); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--ft-speed);
}
.ft-dark-toggle:hover { color: var(--ft-accent); border-color: var(--ft-accent); }

.ft-title { font-size: 28px; font-weight: 700; color: var(--ft-primary); margin: 0 0 8px; font-family: var(--ft-heading); letter-spacing: -0.02em; }
.ft-subtitle { font-size: 15px; color: var(--ft-text-muted); margin: 0 0 32px; line-height: 1.5; }

/* --- Form --- */
.ft-form { max-width: 560px; margin: 0 auto; }
.ft-form-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; margin-bottom: 20px; }
.ft-field { text-align: left; }
.ft-label { display: block; font-size: 13px; font-weight: 600; color: var(--ft-text); margin-bottom: 6px; }
.ft-opt { font-weight: 400; color: var(--ft-text-light); font-size: 12px; }
.ft-iw { position: relative; }
.ft-ii { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ft-text-light); display: flex; pointer-events: none; transition: color var(--ft-speed); z-index: 1; }
.ft-input {
    /* 16px is a hard floor for text-entry controls: iOS Safari zooms the
       viewport on focus below it and never zooms back out. */
    width: 100%; padding: 12px 14px 12px 46px !important; font-size: 16px; font-family: var(--ft-font);
    color: var(--ft-text); background: var(--ft-bg-subtle); border: 1.5px solid var(--ft-border);
    border-radius: var(--ft-radius-sm); outline: none; transition: all var(--ft-speed);
}
.ft-input::placeholder { color: var(--ft-text-light); }
.ft-input:focus { border-color: var(--ft-accent); box-shadow: 0 0 0 2px var(--color-accent-muted); background: var(--ft-white); }

/* --- Button --- */
.ft-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 14px 28px; font-size: 15px; font-weight: 600; font-family: var(--ft-font);
    color: #fff; background: linear-gradient(135deg, var(--ft-primary), var(--ft-primary-light));
    border: none; border-radius: var(--ft-radius-sm); cursor: pointer; position: relative; overflow: hidden;
    transition: all var(--ft-speed);
}
.ft-btn::before { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, var(--ft-accent), var(--ft-accent-light)); opacity: 0; transition: opacity var(--ft-speed); }
.ft-btn:hover::before { opacity: 1; }
.ft-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.ft-btn-t, .ft-btn-l { position: relative; z-index: 1; }
.ft-btn-l { display: none; }
.ft-btn.ft-loading .ft-btn-t { display: none; }
.ft-btn.ft-loading .ft-btn-l { display: flex; }
.ft-btn.ft-loading { pointer-events: none; opacity: 0.85; }

.ft-spin { animation: ft-spin 0.8s linear infinite; }
@keyframes ft-spin { to { transform: rotate(360deg); } }

/* --- Results --- */
.ft-results { margin-top: 24px; }

/* --- Order Card --- */
.ft-card-order {
    background: var(--ft-card-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--ft-card-border); border-radius: var(--ft-radius);
    padding: 32px; margin-bottom: 24px; box-shadow: var(--ft-shadow);
    opacity: 0; transform: translateY(20px); animation: ft-up 0.5s ease-out forwards;
}
.ft-card-order:nth-child(2) { animation-delay: 0.1s; }
.ft-card-order:nth-child(3) { animation-delay: 0.2s; }

/* --- Header --- */
.ft-oh { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--ft-border); }
.ft-oid { font-size: 20px; font-weight: 700; color: var(--ft-primary); margin: 0 0 4px; font-family: var(--ft-heading); }
.ft-odate { font-size: 13px; color: var(--ft-text-muted); }
.ft-ostatus { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 20px; }
.ft-s-processing { background: rgba(59,130,246,0.1); color: var(--ft-info); }
.ft-s-completed, .ft-s-shipped { background: rgba(16,185,129,0.1); color: var(--ft-success); }
.ft-s-on-hold { background: rgba(245,158,11,0.1); color: var(--ft-warning); }

/* --- Timeline --- */
.ft-tl { margin-bottom: 24px; }
.ft-tl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ft-tl-stage { font-size: 14px; font-weight: 600; color: var(--ft-accent); }
.ft-tl-est { font-size: 12px; color: var(--ft-text-muted); }

/* Progress */
.ft-tl-bar { position: relative; height: 6px; background: var(--ft-border); border-radius: 3px; margin: 16px 0 12px; overflow: visible; }
.ft-tl-fill { height: 100%; background: linear-gradient(90deg, var(--ft-primary), var(--ft-accent)); border-radius: 3px; transition: width 1.5s cubic-bezier(.4,0,.2,1); position: relative; width: 0; }
.ft-tl-fill::after {
    content: ''; position: absolute; right: -1px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; background: var(--ft-accent); border-radius: 50%;
    box-shadow: 0 0 0 4px var(--ft-accent-glow), 0 2px 8px rgba(0,0,0,0.15);
    animation: ft-pulse 2s ease-in-out infinite;
}
.ft-tl-pkg { position: absolute; top: -28px; left: 0; z-index: 2; transition: left 1.5s cubic-bezier(.4,0,.2,1); filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15)); }

/* Nodes */
.ft-tl-nodes { display: flex; justify-content: space-between; margin-top: 8px; }
.ft-nd { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }

/* Node: dots */
.ft-nd-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ft-border); border: 2px solid var(--ft-bg-subtle); transition: all var(--ft-speed); z-index: 1; }
.ft-nd-active .ft-nd-dot { background: var(--ft-accent); box-shadow: 0 0 0 4px var(--ft-accent-glow); animation: ft-pulse 2s ease-in-out infinite; }
.ft-nd-done .ft-nd-dot { background: var(--ft-success); border-color: var(--ft-success); }

/* Node: icons */
.ft-nd-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--ft-border); display: flex; align-items: center; justify-content: center; font-size: 13px; transition: all var(--ft-speed); }
.ft-nd-active .ft-nd-icon { background: var(--ft-accent); color: #fff; box-shadow: 0 0 0 4px var(--ft-accent-glow); animation: ft-pulse 2s ease-in-out infinite; }
.ft-nd-done .ft-nd-icon { background: var(--ft-success); color: #fff; }

/* Node: numbers */
.ft-nd-num { width: 24px; height: 24px; border-radius: 50%; background: var(--ft-border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--ft-text-light); transition: all var(--ft-speed); }
.ft-nd-active .ft-nd-num { background: var(--ft-accent); color: #fff; box-shadow: 0 0 0 4px var(--ft-accent-glow); animation: ft-pulse 2s ease-in-out infinite; }
.ft-nd-done .ft-nd-num { background: var(--ft-success); color: #fff; }

.ft-nd-lbl { font-size: 10px; color: var(--ft-text-light); text-align: center; line-height: 1.3; max-width: 72px; transition: color var(--ft-speed); }
.ft-nd-active .ft-nd-lbl, .ft-nd-done .ft-nd-lbl { color: var(--ft-text); font-weight: 600; }

/* --- Tracking detail --- */
.ft-td { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 20px; background: var(--ft-bg-subtle); border-radius: var(--ft-radius-sm); margin-bottom: 20px; }
.ft-td-label { font-size: 12px; color: var(--ft-text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.ft-td-num { font-size: 14px; font-weight: 600; font-family: 'SF Mono','Fira Code',monospace; color: var(--ft-text); }
.ft-td-acts { display: flex; gap: 8px; flex-wrap: wrap; }

.ft-copy {
    display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; font-size: 12px; font-weight: 500; font-family: var(--ft-font);
    color: var(--ft-text-muted); background: var(--ft-white); border: 1px solid var(--ft-border); border-radius: var(--ft-radius-xs);
    cursor: pointer; transition: all var(--ft-speed);
}
.ft-copy:hover { color: var(--ft-accent); border-color: var(--ft-accent); }
.ft-copy.ft-copied { color: var(--ft-success); border-color: var(--ft-success); }

.ft-track-link {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; font-size: 13px; font-weight: 600; font-family: var(--ft-font);
    color: #fff; background: var(--ft-primary); border: none; border-radius: var(--ft-radius-xs);
    cursor: pointer; text-decoration: none; transition: all var(--ft-speed);
}
.ft-track-link:hover { background: var(--ft-accent); transform: translateY(-1px); box-shadow: 0 4px 12px var(--ft-accent-glow); color: #fff; text-decoration: none; }

/* --- Items --- */
.ft-items { margin-bottom: 20px; }
.ft-sec-t { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ft-text-muted); margin-bottom: 12px; }

.ft-it { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--ft-border); }
.ft-it:last-child { border-bottom: none; }
.ft-it-img { width: 52px; height: 52px; border-radius: var(--ft-radius-xs); object-fit: cover; background: var(--ft-bg-subtle); flex-shrink: 0; }
.ft-it-ph { width: 52px; height: 52px; border-radius: var(--ft-radius-xs); background: var(--ft-bg-subtle); display: flex; align-items: center; justify-content: center; color: var(--ft-text-light); flex-shrink: 0; }
.ft-it-info { flex: 1; min-width: 0; }
.ft-it-name { font-size: 14px; font-weight: 500; color: var(--ft-text); margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-it-qty { font-size: 12px; color: var(--ft-text-muted); }
.ft-it-price { font-size: 14px; font-weight: 600; color: var(--ft-text); flex-shrink: 0; }

/* --- Shipping --- */
.ft-ship { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--ft-bg-subtle); border-radius: var(--ft-radius-xs); margin-bottom: 20px; font-size: 13px; color: var(--ft-text-muted); }

/* --- Footer --- */
.ft-of { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; border-top: 1px solid var(--ft-border); }
.ft-of-label { font-size: 13px; color: var(--ft-text-muted); }
.ft-of-val { font-size: 18px; font-weight: 700; color: var(--ft-primary); font-family: var(--ft-heading); }

/* --- Empty --- */
.ft-empty { text-align: center; padding: 48px 24px; animation: ft-up 0.5s ease-out; }
.ft-empty-icon { color: var(--ft-text-light); margin-bottom: 16px; }
.ft-empty-t { font-size: 20px; font-weight: 700; color: var(--ft-text); margin: 0 0 8px; font-family: var(--ft-heading); }
.ft-empty-p { font-size: 14px; color: var(--ft-text-muted); line-height: 1.6; margin: 0; }

.ft-error {
    text-align: center; padding: 24px; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.15);
    border-radius: var(--ft-radius-sm); color: var(--ft-danger); font-size: 14px; font-weight: 500;
    animation: ft-up 0.3s ease-out; margin-top: 24px;
}

/* --- Help --- */
.ft-help { margin-top: 40px; animation: ft-up 0.6s ease-out 0.3s both; }
.ft-help-card {
    display: flex; align-items: flex-start; gap: 16px; padding: 24px;
    background: var(--ft-card-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--ft-card-border); border-radius: var(--ft-radius); box-shadow: var(--ft-shadow);
}
.ft-help-icon { flex-shrink: 0; color: var(--ft-accent); margin-top: 2px; }
.ft-help-title { font-size: 16px; font-weight: 700; color: var(--ft-text); margin: 0 0 4px; font-family: var(--ft-heading); }
.ft-help-text { font-size: 16px; color: var(--ft-text-muted); margin: 0 0 12px; line-height: 1.5; }
.ft-help-link { font-size: 13px; font-weight: 600; color: var(--ft-accent); text-decoration: none; transition: color var(--ft-speed); }
.ft-help-link:hover { color: var(--ft-accent-light); text-decoration: underline; }

/* --- Footer text --- */
.ft-footer-text { text-align: center; margin-top: 32px; font-size: 13px; color: var(--ft-text-muted); line-height: 1.6; }

/* --- Confetti --- */
.ft-confetti { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9999; }

/* --- Delivered --- */
.ft-delivered .ft-oh {
    background: linear-gradient(135deg, rgba(16,185,129,0.05), rgba(220,152,20,0.05));
    border-radius: var(--ft-radius-sm); padding: 16px 20px; margin: -8px -8px 20px;
}
.ft-delivered .ft-oid { color: var(--ft-success); }
.ft-cel { display: inline-block; animation: ft-shake 0.6s ease-in-out; font-size: 24px; margin-left: 8px; }

/* --- Animations --- */
@keyframes ft-up { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ft-pulse { 0%,100%{box-shadow:0 0 0 0 var(--ft-accent-glow);}50%{box-shadow:0 0 0 8px rgba(220,152,20,0);} }
@keyframes ft-float { 0%,100%{transform:translateY(0);}50%{transform:translateY(-6px);} }
@keyframes ft-shake { 0%,100%{transform:rotate(0)}10%{transform:rotate(-8deg)}20%{transform:rotate(8deg)}30%{transform:rotate(-5deg)}40%{transform:rotate(5deg)}50%{transform:rotate(0)} }

/* --- Responsive --- */
@media (max-width: 640px) {
    .ft-tracker { padding: 16px 12px 60px; }
    .ft-hero { padding: 32px 20px 28px; }
    .ft-title { font-size: 22px; }
    .ft-form-row { grid-template-columns: 1fr; gap: 12px; }
    .ft-card-order { padding: 24px 20px; }
    .ft-oh { flex-direction: column; gap: 8px; }
    .ft-td { flex-direction: column; align-items: flex-start; }
    .ft-td-acts { width: 100%; }
    .ft-track-link { flex: 1; justify-content: center; }
    .ft-nd-lbl { font-size: 9px; max-width: 56px; }
    .ft-tl-head { flex-direction: column; align-items: flex-start; gap: 4px; }
    .ft-it { gap: 10px; }
    .ft-it-img, .ft-it-ph { width: 44px; height: 44px; }
}

/* --- Print --- */
@media print {
    .ft-hero,.ft-help,.ft-confetti,.ft-track-link,.ft-copy,.ft-btn,.ft-dark-toggle,.ft-footer-text { display: none !important; }
    .ft-tracker { max-width: 100%; padding: 0; }
    .ft-card-order { box-shadow: none; border: 1px solid #ddd; backdrop-filter: none; break-inside: avoid; opacity: 1 !important; transform: none !important; animation: none !important; }
    .ft-tl-fill::after, .ft-nd-active .ft-nd-dot, .ft-nd-active .ft-nd-icon, .ft-nd-active .ft-nd-num { animation: none !important; }
}

/* --- A11y --- */
.ft-tracker *:focus-visible { outline: 2px solid var(--ft-accent); outline-offset: 2px; }
.ft-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
