/* Site-specific styles that complement the theme */

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 80px;
}

/* Constrained-fluid layout: full-width up to 1280px, then centered */
.app-content {
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
}

/* Form focus states */
.btn:focus, 
.btn:active:focus, 
.btn-link.nav-link:focus, 
.form-control:focus, 
.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--primary-200, rgba(99, 102, 241, 0.3));
}

/* Tooltip enhancements */
.tooltip {
  max-width: 400px !important;
}

.tooltip-inner {
  max-width: 400px !important;
  min-width: 200px;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Smooth scrolling for the whole page */
html {
  scroll-behavior: smooth;
}

/* Selection color */
::selection {
  background: var(--primary-200, #c7d2fe);
  color: var(--primary-900, #312e81);
}

/* Link transitions */
a {
  transition: color 0.15s ease-in-out;
}

/* Responsive adjustments for mobile */
@media (max-width: 767px) {
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .stat-card .stat-value {
    font-size: 2rem;
  }
  
  .page-header .page-title {
    font-size: 1.5rem;
  }
  
  .action-btn-group {
    flex-direction: column;
  }
  
  .action-btn-group .btn {
    width: 100%;
  }
}

/* ── Tier badge (rounded rectangle, used in legend/display) ─────────── */

/* ── Tier badge (rounded rectangle, used everywhere) ─────────────────── */
.tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.6rem;
    border-radius: 0.35rem;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    border: 1.5px solid transparent;
    white-space: nowrap;
}
.tier-a            { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.tier-b            { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.tier-c            { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.tier-unclassified { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; }

/* ── Tier action buttons ─────────────────────────────────────────────── */
/* Inactive: small neutral outline. Active: full size with tier color.   */
/* The parent container must use align-items: center to keep them        */
/* vertically centered despite the size difference.                      */

.tier-btn-a,
.tier-btn-b,
.tier-btn-c,
.tier-btn-unclassified {
    background: transparent;
    color: #9ca3af;
    border: 1.5px solid #e5e7eb;
    font-weight: 700;
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    line-height: 1.2;
}

.tier-btn-a.active,
.tier-btn-b.active,
.tier-btn-c.active,
.tier-btn-unclassified.active {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
}

.tier-btn-a:hover  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.tier-btn-a.active { background: #d1fae5; color: #065f46; border-color: #6ee7b7; box-shadow: 0 0 0 2px rgba(6,95,70,0.15); }

.tier-btn-b:hover  { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.tier-btn-b.active { background: #dbeafe; color: #1e40af; border-color: #93c5fd; box-shadow: 0 0 0 2px rgba(30,64,175,0.15); }

.tier-btn-c:hover  { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.tier-btn-c.active { background: #fef3c7; color: #92400e; border-color: #fcd34d; box-shadow: 0 0 0 2px rgba(146,64,14,0.15); }

.tier-btn-unclassified:hover  { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; }
.tier-btn-unclassified.active { background: #f3f4f6; color: #6b7280; border-color: #d1d5db; box-shadow: 0 0 0 2px rgba(107,114,128,0.15); }

/* ── Sort bar ────────────────────────────────────────────────────────── */
.contact-sort-bar {
    border-bottom: 2px solid var(--gray-300, #d1d5db);
    background: var(--gray-50, #f9fafb);
    font-size: 0.8rem;
}

.contact-sort-label { color: var(--gray-500, #6b7280); font-weight: 500; }

.contact-sort-link { color: var(--gray-500, #6b7280); text-decoration: none; white-space: nowrap; }
.contact-sort-link:hover  { color: var(--primary-600, #4f46e5); }
.contact-sort-link.active { color: var(--primary-600, #4f46e5); font-weight: 600; }

/* Darker card borders for better contrast against page background */
.card { border-color: var(--gray-300, #d1d5db) !important; }

/* Secondary line inside stat cards (e.g. "Ignored: 12") */
.stat-secondary-line {
    font-size: 0.78rem;
    color: var(--gray-500, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* ── Contact list / rows (layout via Bootstrap row/col) ──────────────── */
/*
 * Desktop (≥lg): single Bootstrap row, 12 cols
 *   col-lg-3  name/email     col-lg-1  score   col-lg-2  date
 *   col-lg-1  overdue        col-lg-2  tier    col-lg-2  freq
 *   col-lg-1  actions  (order-lg-last → visually at end)
 *
 * Mobile (<lg): row 1 = identity (col) + actions (col-auto, right)
 *               w-100 line break
 *               row 2 = score / date / overdue / tier / freq  (all col-auto)
 */
.contact-list { display: flex; flex-direction: column; }

.contact-row { border-bottom: 1px solid var(--gray-300, #d1d5db); }
.contact-row:last-child { border-bottom: none; }

/* min-width:0 lets the name truncate with ellipsis inside a flex column */
.contact-row-identity { min-width: 0; }

.contact-row-name {
    color: inherit;
    text-decoration: none;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-row-name:hover { text-decoration: underline; }

.contact-row .contact-email     { font-size: 0.78rem; }
.contact-row .contact-last-date { font-size: 0.82rem; white-space: nowrap; }
.contact-row-overdue            { white-space: nowrap; }

/* Mobile-only labels (Score:, Last Contact:, Tier:, Frequency:) */
.contact-row-mobile-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--gray-500, #6b7280);
    white-space: nowrap;
}

/* Fixed-width score badge so all rows line up consistently on mobile */
@media (max-width: 991.98px) {
    .score-badge {
        min-width: 2.75rem;
        text-align: center;
    }

    /* Ensure dropdown arrow doesn't overlap the selected option text */
    .frequency-select {
        min-width: 7.5rem;
    }
}

/* Frequency select fills its col-lg-2 column on desktop */
@media (min-width: 992px) {
    .frequency-select { width: 100% !important; }
}

/* ── Classify sticky bulk action bar ────────────────────────────────── */
.bulk-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: var(--gray-900, #111827);
    color: #fff;
    padding: 0.75rem 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
}

.bulk-action-bar .btn-sm {
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
}

/* Print optimization */
@media print {
  body {
    margin-bottom: 0;
  }
}
