/* =================================================================
   Custom Order Tracker — WoodMart-compatible · Premium Design
   Hooks into WoodMart CSS variables where available.
   ================================================================= */

/* ── Design tokens (WoodMart-aware) ──────────────────────────────
   We read WoodMart's own vars if they exist, otherwise fall back
   to our premium standalone palette.                              */
.cot-wrap {
    /* Accent — read WoodMart primary, fall back to deep charcoal-graphite */
    --cot-accent:         var(--wd-primary-color, #1a1a2e);
    --cot-accent-hover:   var(--wd-primary-color-hover, #16213e);

    /* Surfaces */
    --cot-bg:             #ffffff;
    --cot-bg-subtle:      #f8f8f6;
    --cot-bg-muted:       #f2f1ef;

    /* Borders */
    --cot-border:         #e8e6e1;
    --cot-border-strong:  #d4d0c8;

    /* Text */
    --cot-text:           #1c1917;
    --cot-text-secondary: #6b6560;
    --cot-text-muted:     #a09a93;

    /* Success (timeline done) */
    --cot-success:        #2d6a4f;
    --cot-success-light:  #d8f3dc;

    /* Danger */
    --cot-danger:         #9b2335;
    --cot-danger-light:   #fce8ec;

    /* Warning */
    --cot-warning:        #92400e;
    --cot-warning-light:  #fef3c7;

    /* Shadows */
    --cot-shadow-sm:      0 1px 3px 0 rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.04);
    --cot-shadow-md:      0 4px 12px 0 rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
    --cot-shadow-lg:      0 10px 30px -4px rgba(0,0,0,.10), 0 4px 8px -4px rgba(0,0,0,.06);

    /* Radius */
    --cot-radius:         12px;
    --cot-radius-sm:      8px;
    --cot-radius-xs:      5px;

    /* Spacing */
    --cot-gap:            28px;
}

/* ── Box model ─────────────────────────────────────────────────── */
.cot-wrap,
.cot-wrap * {
    box-sizing: border-box;
}

/* ── Wrapper ───────────────────────────────────────────────────── */
.cot-wrap {
    max-width: 820px;
    margin: 32px auto;
    font-family: inherit;
    color: var(--cot-text);
}

/* =================================================================
   CARD — shared
   ================================================================= */
.cot-card {
    background: var(--cot-bg);
    border: 1px solid var(--cot-border);
    border-radius: var(--cot-radius);
    box-shadow: var(--cot-shadow-md);
    overflow: hidden;
}

.cot-card + .cot-card {
    margin-top: 20px;
}

/* =================================================================
   SEARCH / FORM CARD
   ================================================================= */
.cot-card--search {
    padding: var(--cot-gap);
}

.cot-title {
    margin: 0 0 6px;
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--cot-text);
    line-height: 1.25;
}

.cot-subtitle {
    margin: 0 0 22px;
    font-size: 0.875rem;
    color: var(--cot-text-secondary);
}

/* ── Form fields ──────────────────────────────────────────────── */
.cot-field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.cot-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--cot-text);
    text-transform: uppercase;
}

.cot-field input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--cot-border-strong);
    border-radius: var(--cot-radius-sm);
    background: var(--cot-bg-subtle);
    font: inherit;
    font-size: 0.9375rem;
    color: var(--cot-text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.cot-field input::placeholder {
    color: var(--cot-text-muted);
}

.cot-field input:hover {
    border-color: #b8b3ab;
    background: var(--cot-bg);
}

.cot-field input:focus {
    outline: none;
    border-color: var(--cot-accent);
    background: var(--cot-bg);
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.08);
}

/* ── Submit button ────────────────────────────────────────────── */
.cot-form-footer {
    margin-top: 18px;
}

.cot-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: 0;
    border-radius: var(--cot-radius-sm);
    background: var(--cot-accent);
    color: #fff;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
    box-shadow: 0 2px 8px rgba(26,26,46,.18);
}

.cot-btn:hover {
    background: var(--cot-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26,26,46,.22);
}

.cot-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(26,26,46,.16);
}

.cot-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.cot-btn.loading .cot-btn-text { display: none; }
.cot-btn.loading .cot-spinner  { display: block; }

.cot-spinner {
    display: none;
    width: 17px;
    height: 17px;
    animation: cot-spin 0.7s linear infinite;
}

@keyframes cot-spin { to { transform: rotate(360deg); } }

/* ── Error ────────────────────────────────────────────────────── */
.cot-error {
    margin-top: 14px;
    padding: 12px 16px;
    background: var(--cot-danger-light);
    border: 1px solid #f5c6cf;
    border-left: 3px solid var(--cot-danger);
    border-radius: var(--cot-radius-xs);
    color: var(--cot-danger);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* =================================================================
   RESULT CARD
   ================================================================= */
.cot-card--result {
    padding: 0;
}

/* ── Card header band ─────────────────────────────────────────── */
.cot-result-header {
    padding: 22px var(--cot-gap);
    background: var(--cot-bg-subtle);
    border-bottom: 1px solid var(--cot-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.cot-order-id {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--cot-text);
    line-height: 1.3;
}

.cot-order-id span {
    color: var(--cot-text-secondary);
    font-weight: 500;
}

/* ── Status badge ─────────────────────────────────────────────── */
.cot-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    border: 1.5px solid transparent;
}

.cot-badge--processing,
.cot-badge--pending,
.cot-badge--shipped {
    background: #eef0ff;
    color: #3730a3;
    border-color: #c7d2fe;
}

.cot-badge--on-hold {
    background: var(--cot-warning-light);
    color: var(--cot-warning);
    border-color: #fde68a;
}

.cot-badge--completed {
    background: var(--cot-success-light);
    color: var(--cot-success);
    border-color: #b7e4c7;
}

.cot-badge--cancelled,
.cot-badge--refunded {
    background: var(--cot-danger-light);
    color: var(--cot-danger);
    border-color: #f5c6cf;
}

/* ── Meta row (date / estimated) ──────────────────────────────── */
.cot-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 28px;
    padding: 14px var(--cot-gap);
    border-bottom: 1px solid var(--cot-border);
    font-size: 0.875rem;
    color: var(--cot-text-secondary);
}

.cot-meta-row strong {
    color: var(--cot-text);
    font-weight: 600;
}

/* =================================================================
   TIMELINE
   ================================================================= */
.cot-timeline-wrap {
    padding: 28px var(--cot-gap);
    border-bottom: 1px solid var(--cot-border);
}

.cot-timeline-label {
    margin: 0 0 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cot-text-muted);
}

.cot-timeline {
    display: flex;
    align-items: flex-start;
    position: relative;
}

/* Connector track behind all steps */
.cot-timeline::before {
    content: "";
    position: absolute;
    top: 13px;
    left: 13px;
    right: 13px;
    height: 2px;
    background: var(--cot-border-strong);
    z-index: 0;
}

/* Green fill — set via inline style width from JS, OR use done overlay */
.cot-timeline-track {
    position: absolute;
    top: 13px;
    left: 13px;
    height: 2px;
    background: var(--cot-success);
    z-index: 1;
    transition: width 0.6s ease;
    border-radius: 2px;
}

/* ── Each step ──────────────────────────────────────────────────── */
.cot-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 0 6px;
}

/* Dot */
.cot-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--cot-border-strong);
    background: var(--cot-bg);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    z-index: 2;
}

/* Done — filled with success colour + check mark */
.cot-step-dot--done {
    border-color: var(--cot-success);
    background: var(--cot-success);
    box-shadow: 0 0 0 4px rgba(45,106,79,.12);
}

.cot-step-dot--done::after {
    content: "";
    display: block;
    width: 9px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

/* Active — accent ring */
.cot-step-dot--active {
    border-color: var(--cot-accent);
    background: var(--cot-accent);
    box-shadow: 0 0 0 4px rgba(26,26,46,.10);
}

.cot-step-dot--active::after {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

/* Pending — empty */
.cot-step-dot--pending {
    border-color: var(--cot-border-strong);
    background: var(--cot-bg-muted);
}

/* Labels */
.cot-step-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--cot-text);
    line-height: 1.3;
    letter-spacing: 0.005em;
}

.cot-step-title--muted {
    color: var(--cot-text-muted);
    font-weight: 500;
}

.cot-step-meta {
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--cot-text-muted);
    line-height: 1.3;
}

/* =================================================================
   ORDER ITEMS
   ================================================================= */
.cot-section {
    padding: 22px var(--cot-gap);
    border-bottom: 1px solid var(--cot-border);
}

.cot-section:last-child {
    border-bottom: none;
}

.cot-section-title {
    margin: 0 0 16px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cot-text-muted);
}

.cot-items {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cot-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 12px;
    background: var(--cot-bg-subtle);
    border: 1px solid var(--cot-border);
    border-radius: var(--cot-radius-sm);
    transition: border-color 0.15s;
}

.cot-item:hover {
    border-color: var(--cot-border-strong);
}

.cot-item-img,
.cot-item-img-placeholder {
    width: 60px;
    height: 60px;
    border-radius: var(--cot-radius-xs);
    object-fit: cover;
    background: var(--cot-bg-muted);
    border: 1px solid var(--cot-border);
    flex-shrink: 0;
}

.cot-item-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cot-text-muted);
    font-size: 1.375rem;
}

.cot-item-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--cot-text);
    margin-bottom: 3px;
    line-height: 1.35;
}

.cot-item-meta {
    font-size: 0.8125rem;
    color: var(--cot-text-secondary);
}

.cot-item-right {
    text-align: right;
}

.cot-item-price {
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--cot-text);
}

.cot-item-qty {
    font-size: 0.8125rem;
    color: var(--cot-text-muted);
    margin-top: 2px;
}

/* =================================================================
   PAYMENT / DELIVERY / SUMMARY
   ================================================================= */
.cot-dual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
}

.cot-dual-grid .cot-block:first-child {
    border-right: 1px solid var(--cot-border);
}

.cot-block {
    padding: 22px var(--cot-gap);
}

.cot-block-title {
    margin: 0 0 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cot-text-muted);
}

.cot-block p {
    margin: 0 0 5px;
    font-size: 0.9rem;
    color: var(--cot-text-secondary);
    white-space: pre-line;
    line-height: 1.6;
}

.cot-block p:last-child { margin-bottom: 0; }

/* ── Order summary ────────────────────────────────────────────── */
.cot-summary-block {
    padding: 22px var(--cot-gap);
    background: var(--cot-bg-subtle);
    border-top: 1px solid var(--cot-border);
}

.cot-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--cot-text-secondary);
    margin-bottom: 9px;
    line-height: 1.4;
}

.cot-summary-row:last-child { margin-bottom: 0; }

.cot-summary-row--total {
    border-top: 1px solid var(--cot-border-strong);
    padding-top: 12px;
    margin-top: 4px;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--cot-text);
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 680px) {
    .cot-wrap { --cot-gap: 18px; }

    .cot-field-row { grid-template-columns: 1fr; }

    /* ── Result header ─── */
    .cot-result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* ── Timeline → vertical ─── */
    .cot-timeline {
        flex-direction: column;
        align-items: flex-start;
        gap: 0;
    }

    .cot-timeline::before {
        top: 14px;
        left: 13px;
        bottom: 14px;
        right: auto;
        width: 2px;
        height: auto;
    }

    .cot-timeline-track {
        display: none; /* simpler on mobile */
    }

    .cot-step {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
        padding: 0;
        padding-bottom: 20px;
        width: 100%;
        gap: 14px;
    }

    .cot-step:last-child { padding-bottom: 0; }

    .cot-step-dot { margin-bottom: 0; flex-shrink: 0; }

    .cot-step-body { display: flex; flex-direction: column; padding-top: 5px; }

    /* ── Dual grid → stack ─── */
    .cot-dual-grid {
        grid-template-columns: 1fr;
    }

    .cot-dual-grid .cot-block:first-child {
        border-right: none;
        border-bottom: 1px solid var(--cot-border);
    }

    /* ── Items ─── */
    .cot-item { grid-template-columns: 52px 1fr; }
    .cot-item-right { grid-column: 2; text-align: left; }
}

@media (max-width: 420px) {
    .cot-title { font-size: 1.25rem; }
    .cot-order-id { font-size: 1rem; }
}
