/* ============================================================
   TenderGlobal Card Standard v2
   Default.aspx Architecture + Premium Styling + Responsive
   ============================================================
   Source of Truth: Default.aspx 5-zone card layout
   ============================================================ */

/* ===== CSS TOKENS ===== */
:root {
    --tg2-brand: #2c8a94;
    --tg2-brand-dark: #1a6b73;
    --tg2-brand-light: #f0fdfa;
    --tg2-text: #1e293b;
    --tg2-muted: #64748b;
    --tg2-light: #94a3b8;
    --tg2-border: #e2e8f0;
    --tg2-surface: #ffffff;
    --tg2-bg: #f8fafc;
    --tg2-radius: 12px;
    --tg2-warning: #f59e0b;
    --tg2-danger: #dc2626;
    --tg2-success: #22c55e;
}

/* ===== CARD CONTAINER ===== */
.tg2-card {
    background: var(--tg2-surface);
    border: 1px solid var(--tg2-border);
    border-radius: var(--tg2-radius);
    margin-bottom: 12px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.tg2-card:hover {
    border-color: rgba(44, 138, 148, 0.35);
    box-shadow: 0 4px 20px rgba(44, 138, 148, 0.08);
}
/* Right accent bar on hover (RTL) */
.tg2-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--tg2-brand), var(--tg2-brand-dark));
    border-radius: 0 var(--tg2-radius) var(--tg2-radius) 0;
    opacity: 0;
    transition: opacity 0.25s;
}
[dir="ltr"] .tg2-card::after {
    right: auto;
    left: 0;
    border-radius: var(--tg2-radius) 0 0 var(--tg2-radius);
}
.tg2-card:hover::after { opacity: 1; }

/* Inner flex: sidebar + details */
.tg2-card-inner {
    display: grid;
    grid-template-columns: auto 1fr;
    padding: 16px 20px 14px;
}

/* ===== ZONE 5: SIDEBAR ICON BADGES ===== */
.tg2-sidebar {
    grid-row: 3 / span 2;
    grid-column: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 4px 12px;
    border-left: 1px solid #e2e8f0;
    margin-left: 16px;
    flex-shrink: 0;
    align-self: stretch;
}
[dir="ltr"] .tg2-sidebar {
    border-left: none;
    border-right: 1px solid #e2e8f0;
    padding: 8px 12px 4px 12px;
    margin-left: 0;
    margin-right: 16px;
}
.tg2-icon-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tg2-bg);
    border: 1px solid var(--tg2-border);
    transition: all 0.2s;
}
.tg2-icon-badge:hover {
    background: var(--tg2-brand-light);
    border-color: rgba(44, 138, 148, 0.3);
}
.tg2-icon-badge img { width: 16px; height: 16px; }
.tg2-icon-badge.badge-hidden { display: none !important; }

/* ===== MAIN DETAILS AREA ===== */
.tg2-details {
    display: contents;
}

/* ===== ZONE 1: HEADER ===== */
.tg2-header {
    grid-row: 1;
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}
.tg2-title-group { flex: 1; min-width: 0; }
.tg2-title {
    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 2px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.tg2-title a {
    color: var(--tg2-text);
    text-decoration: none;
    transition: color 0.2s;
}
.tg2-title a:hover { color: var(--tg2-brand); }

/* Status dot */
.tg2-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tg2-success);
    flex-shrink: 0;
    margin-top: 7px;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}
.tg2-status-dot.status-expired { background: var(--tg2-danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }
.tg2-status-dot.status-soon { background: var(--tg2-warning); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); }

/* Publisher */
.tg2-publisher {
    font-size: 13px;
    color: var(--tg2-brand);
    font-weight: 600;
    font-style: italic;
    padding-right: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
[dir="ltr"] .tg2-publisher { padding-right: 0; padding-left: 16px; }
.tg2-publisher a { color: inherit; text-decoration: none; }
.tg2-publisher a:hover { text-decoration: underline; }

/* Favorite star */
.tg2-star-btn {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--tg2-border) !important;
    border-radius: 10px !important;
    background: var(--tg2-surface) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: var(--tg2-light);
    transition: all 0.2s;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    box-shadow: none !important;
    padding: 0;
}
.tg2-star-btn:hover {
    border-color: var(--tg2-warning) !important; color: var(--tg2-warning) !important;
    background: #fffbeb !important;
    transform: none !important;
}
.tg2-star-btn.is-favorite,
.tg2-star-btn.active {
    border-color: #f59e0b !important;
    color: #f59e0b !important;
    background: #fffbeb !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12) !important;
    border-radius: 10px !important;
}
.tg2-star-btn.active:hover {
    background: #fef3c7 !important;
    transform: none !important;
}
.tg2-star-btn .tf-star-icon {
    color: inherit !important;
    font-size: 16px;
}
.tg2-star-btn.active .tf-star-icon,
.tg2-star-btn.is-favorite .tf-star-icon {
    color: #f59e0b !important;
}
.tg2-star-btn .tf-star-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    white-space: nowrap;
    font-size: 11px;
    background: #1f2937;
    color: #fff !important;
    padding: 4px 8px;
    border-radius: 6px;
    z-index: 100;
    transition: opacity 0.15s, transform 0.15s;
}
.tg2-star-btn:hover .tf-star-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.tg2-star-btn.is-favorite i,
.tg2-star-btn.active i { font-weight: 900; }

/* ===== ZONE 2: TGID + TYPE TAGS ===== */
.tg2-first-row {
    grid-row: 2;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}
.tg2-tid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #f0fdfa, #e0f7fa);
    border: 1px solid rgba(44, 138, 148, 0.2);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}
.tg2-tid-label {
    color: var(--tg2-brand);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tg2-tid-number {
    color: var(--tg2-brand-dark);
    font-size: 13px;
    font-weight: 800;
}
.tg2-tid-type {
    color: var(--tg2-muted);
    font-size: 10px;
}
.tg2-divider {
    color: #cbd5e1;
    font-size: 14px;
    margin: 0 2px;
}
/* Tags */
.tg2-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
}
.tg2-tag-tender { background: #fef2e8; color: #c2410c; border: 1px solid #fed7aa; }
.tg2-tag-status { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.tg2-tag-repost { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.tg2-tag-free { background: #ede9fe; color: #7c3aed; border: 1px solid #c4b5fd; }
.tg2-tag-award { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.tg2-tag-exclusive { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== ZONE 3: DATES + PROGRESS + FLAG ===== */
.tg2-second-row {
    grid-row: 3;
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}
.tg2-date-block {
    flex: 0 0 auto;
    min-width: 130px;
    padding: 0 16px;
}
.tg2-date-block:first-child { padding-right: 0; }
[dir="ltr"] .tg2-date-block:first-child { padding-right: 16px; padding-left: 0; }
.tg2-date-label {
    font-size: 11px;
    color: var(--tg2-brand);
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}
.tg2-date-value {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

/* Deadline section */
.tg2-deadline-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 0 16px;
}
.tg2-deadline-relative {
    display: block;
    font-size: 11px;
    margin-top: 1px;
}
.tg2-deadline-relative.tender-active { color: var(--tg2-success) !important; }
.tg2-deadline-relative.tender-urgent { color: var(--tg2-warning) !important; }
.tg2-deadline-relative.tender-expired { color: #94a3b8 !important; }

/* Progress Circle */
.tg2-progress-circle {
    width: 56px;
    height: 56px;
    position: relative;
    flex-shrink: 0;
}
.tg2-progress-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.tg2-progress-bg {
    fill: none;
    stroke: var(--tg2-border);
    stroke-width: 2.5;
    transition: stroke 0.4s;
}
.tg2-progress-fill {
    fill: none;
    stroke: var(--tg2-success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 88;
    stroke-dashoffset: 22;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.4s;
}
.tg2-progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    line-height: 1;
    color: var(--tg2-success);
    transition: color 0.4s;
    overflow: hidden;
    border-radius: 50%;
}
.tg2-progress-num {
    font-size: 17px;
    font-weight: 900;
    letter-spacing: -0.5px;
}
.tg2-progress-label {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.85;
    margin-top: 1px;
}
/* Urgency color classes */
.tg2-progress-text.status-safe { color: #22c55e; }
.tg2-progress-text.status-warning { color: #f59e0b; }
.tg2-progress-text.status-danger { color: #ef4444; }
.tg2-progress-text.status-expired { color: #94a3b8; }
/* Expired state: slightly smaller to fit "0 / End" in circle */
.tg2-progress-num.tg2-expired { font-size: 13px; }
.tg2-progress-label.tg2-expired { font-size: 6.5px; letter-spacing: 0; }


/* Country flag */
.tg2-location {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: auto;
    padding: 0 16px;
}
[dir="ltr"] .tg2-location { margin-right: 0; margin-left: auto; }
.tg2-flag {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--tg2-border);
}

/* ===== ZONE 4: CATEGORIES + ACTIONS ===== */
.tg2-third-row {
    grid-row: 4;
    grid-column: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.tg2-category-area {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.tg2-cat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--tg2-brand-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tg2-brand);
    font-size: 14px;
    flex-shrink: 0;
    border: 1px solid rgba(44, 138, 148, 0.15);
}
.tg2-cat-content { flex: 1; min-width: 0; }
.tg2-cat-parent {
    font-size: 11.5px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
}
.tg2-cat-children {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.tg2-cat-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: var(--tg2-bg);
    border: 1px solid var(--tg2-border);
    border-radius: 6px;
    font-size: 11px;
    color: #475569;
    text-decoration: none;
    transition: all 0.2s;
}
.tg2-cat-tag:hover { border-color: var(--tg2-brand); color: var(--tg2-brand); background: var(--tg2-brand-light); }
.tg2-cat-count {
    font-weight: 700;
    color: var(--tg2-brand);
    font-size: 11px;
}

/* Action buttons */
.tg2-action-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.tg2-btn-details {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--tg2-brand), var(--tg2-brand-dark));
    color: #fff;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}
.tg2-btn-details:hover {
    background: linear-gradient(135deg, var(--tg2-brand-dark), #155a63);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 138, 148, 0.3);
    color: #fff;
}
.tg2-btn-external {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--tg2-border);
    border-radius: 10px;
    background: var(--tg2-surface);
    color: var(--tg2-light);
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
}
.tg2-btn-external:hover { border-color: var(--tg2-brand); color: var(--tg2-brand); }

/* ===== DELETE BUTTON (MyFavorite) ===== */
.tg2-btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--tg2-surface);
    color: var(--tg2-danger);
    border: 1.5px solid #fecaca;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}
.tg2-btn-delete:hover { background: #fef2f2; border-color: var(--tg2-danger); color: var(--tg2-danger); }

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
    .tg2-second-row { flex-wrap: wrap; gap: 8px; }
    .tg2-date-block { min-width: auto; }
}
@media (max-width: 768px) {
    .tg2-card-inner { flex-direction: column; }
    .tg2-sidebar {
        flex-direction: row;
        border-left: none;
        border-top: 1px solid #e2e8f0;
        margin-left: 0;
        padding: 10px 0 0;
        justify-content: center;
    }
    [dir="ltr"] .tg2-sidebar { border-right: none; margin-right: 0; }
    .tg2-second-row { flex-direction: column; gap: 10px; }
    .tg2-date-block { padding: 0 !important; }
    .tg2-deadline-section { padding: 0 !important; }
    .tg2-location { padding: 0 !important; margin-right: 0; }
    .tg2-third-row { flex-direction: column; }
    .tg2-action-btns { justify-content: flex-start; }
    .tg2-publisher { white-space: normal; }
    /* Progress circle ~20% smaller on mobile */
    .tg2-progress-circle { width: 44px; height: 44px; }
    .tg2-progress-num { font-size: 13px; }
    .tg2-progress-label { font-size: 7px; }
}
@media (max-width: 480px) {
    .tg2-card-inner { padding: 12px 14px 10px; }
    .tg2-title { font-size: 14px; }
    .tg2-publisher { font-size: 12px; }
    .tg2-first-row { gap: 4px; }
    .tg2-tid { font-size: 11px; padding: 3px 8px; }
    .tg2-tid-number { font-size: 12px; }
    .tg2-tag { font-size: 10px; padding: 3px 7px; }
    .tg2-btn-details { font-size: 12px; padding: 7px 16px; }
}
