/* ============================================
   EWT CRM - Custom Branding Stylesheet
   ============================================ */

:root {
    --ewt-primary: #0d47a1;
    --ewt-primary-dark: #08306b;
    --ewt-secondary: #ff6f00;
    --ewt-secondary-light: #fff3e0;
    --ewt-success: #2e7d32;
    --ewt-danger: #c62828;
    --ewt-warning: #f57f17;
    --ewt-info: #0277bd;
    --ewt-light-bg: #f5f7fa;
    --ewt-sidebar-width: 240px;
    --ewt-navbar-height: 56px;
}

/* ---------- NAVBAR ---------- */
.ewt-navbar {
    background: var(--ewt-primary);
    height: var(--ewt-navbar-height);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1030;
}

/* ---------- SIDEBAR ---------- */
.ewt-sidebar {
    width: var(--ewt-sidebar-width);
    min-height: calc(100vh - var(--ewt-navbar-height));
    background: #fff;
    border-right: 1px solid #e0e0e0;
    padding-top: 16px;
    position: fixed;
    top: var(--ewt-navbar-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1020;
    transition: transform 0.3s ease;
}

.ewt-sidebar .nav-link {
    color: #555;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 0;
    transition: all 0.2s;
}

.ewt-sidebar .nav-link:hover {
    background: var(--ewt-secondary-light);
    color: var(--ewt-secondary);
}

.ewt-sidebar .nav-link.active {
    background: #e3f2fd;
    color: var(--ewt-primary);
    font-weight: 600;
    border-right: 3px solid var(--ewt-primary);
}

.ewt-sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.ewt-sidebar .nav-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 12px 16px;
}

.ewt-sidebar .nav-header {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
}

/* ---------- SIDEBAR SUBMENU ---------- */
.ewt-sidebar .sidebar-arrow {
    font-size: 0.6rem;
    transition: transform 0.3s ease;
}

.ewt-sidebar .nav-link.collapsed .sidebar-arrow {
    transform: rotate(-90deg);
}

.ewt-sidebar .nav-link:not(.collapsed) .sidebar-arrow {
    transform: rotate(0deg);
}

.ewt-sidebar .sidebar-submenu {
    border-left: 2px solid #e3f2fd;
    margin-left: 16px !important;
    padding: 4px 0;
}

.ewt-sidebar .sidebar-submenu .nav-link {
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 400;
    gap: 8px;
}

.ewt-sidebar .sidebar-submenu .nav-link i {
    width: 16px;
    font-size: 0.8rem;
}

.ewt-sidebar .sidebar-submenu .nav-link.active {
    background: #e3f2fd;
    color: var(--ewt-primary);
    font-weight: 600;
    border-right: 2px solid var(--ewt-primary);
}

.ewt-sidebar .sidebar-submenu .nav-link:hover {
    background: #f5f5f5;
    color: var(--ewt-primary);
}

/* ---------- MAIN CONTENT ---------- */
.ewt-main {
    margin-left: var(--ewt-sidebar-width);
    padding: 24px;
    width: calc(100% - var(--ewt-sidebar-width));
    min-height: calc(100vh - var(--ewt-navbar-height));
    background: var(--ewt-light-bg);
}

/* ---------- STAT CARDS ---------- */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #eee;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-card .stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #888;
    font-weight: 500;
    margin-top: 4px;
}

/* ---------- PAGE HEADERS ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

/* ---------- LEAD ROW STATES ---------- */
.lead-row-invalid {
    background-color: #ffcdd2 !important;
}

.lead-row-invalid td {
    background-color: #ffcdd2 !important;
}

@keyframes blink-row {
    0%, 100% { background-color: #fff3e0; }
    50% { background-color: #ffe0b2; }
}

.lead-row-blink {
    animation: blink-row 1.5s ease-in-out infinite;
}

.lead-row-blink td {
    animation: blink-row 1.5s ease-in-out infinite;
}

/* ---------- CATEGORY BADGES ---------- */
.badge-student {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-tutor {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-invalid {
    background: #ffcdd2;
    color: #c62828;
}

.badge-didnotpick {
    background: #fff3e0;
    color: #e65100;
}

.badge-unassigned {
    background: #f5f5f5;
    color: #757575;
}

.badge-assigned {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-called {
    background: #fff3e0;
    color: #e65100;
}

.badge-completed {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ---------- CUSTOM BUTTONS ---------- */
.btn-ewt-primary {
    background: var(--ewt-primary);
    color: #fff;
    border: none;
}

.btn-ewt-primary:hover {
    background: var(--ewt-primary-dark);
    color: #fff;
}

.btn-ewt-secondary {
    background: var(--ewt-secondary);
    color: #fff;
    border: none;
}

.btn-ewt-secondary:hover {
    background: #e65100;
    color: #fff;
}

/* ---------- CARDS ---------- */
.ewt-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #eee;
    padding: 24px;
}

/* ---------- COMMENT PANEL ---------- */
.comment-panel {
    position: fixed;
    right: -400px;
    top: var(--ewt-navbar-height);
    width: 400px;
    height: calc(100vh - var(--ewt-navbar-height));
    background: #fff;
    border-left: 1px solid #e0e0e0;
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    z-index: 1050;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.comment-panel.open {
    right: 0;
}

.comment-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comment-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.comment-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid #eee;
}

.comment-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f5f5f5;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-author {
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
}

.comment-time {
    font-size: 0.75rem;
    color: #999;
}

.comment-text {
    font-size: 0.9rem;
    color: #555;
    margin-top: 4px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 991.98px) {
    .ewt-sidebar {
        transform: translateX(-100%);
    }

    .ewt-sidebar.show {
        transform: translateX(0);
    }

    .ewt-main {
        margin-left: 0;
        width: 100%;
    }
}

/* ---------- SELECT2 FIXES ---------- */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
}

/* ---------- DATATABLE TWEAKS ---------- */
table.dataTable {
    font-size: 0.9rem;
}

table.dataTable th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
}

/* ---------- PIPELINE STEPPER ---------- */
.pipeline-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
    gap: 0;
}

.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 140px;
}

.pipeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: calc(50% + 18px);
    width: calc(100% - 36px);
    height: 3px;
    background: #dee2e6;
    z-index: 0;
}

.pipeline-step.completed:not(:last-child)::after {
    background: #059669;
}

.pipeline-step.active:not(:last-child)::after {
    background: linear-gradient(90deg, #0d47a1 50%, #dee2e6 50%);
}

.step-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    z-index: 1;
    border: 3px solid #dee2e6;
    background: #fff;
    color: #9ca3af;
    transition: all 0.3s;
}

.pipeline-step.completed .step-circle {
    background: #059669;
    border-color: #059669;
    color: #fff;
}

.pipeline-step.active .step-circle {
    background: var(--ewt-primary);
    border-color: var(--ewt-primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(13,71,161,0.2);
    animation: stepPulse 2s ease-in-out infinite;
}

@keyframes stepPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(13,71,161,0.2); }
    50% { box-shadow: 0 0 0 8px rgba(13,71,161,0.1); }
}

.pipeline-step.pending .step-circle {
    background: #f9fafb;
}

.step-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #9ca3af;
    margin-top: 6px;
    text-align: center;
    white-space: nowrap;
}

.pipeline-step.completed .step-label { color: #059669; }
.pipeline-step.active .step-label { color: var(--ewt-primary); font-weight: 700; }

/* Pipeline responsive */
@media (max-width: 768px) {
    .pipeline-step { max-width: 80px; }
    .step-circle { width: 28px; height: 28px; font-size: 0.65rem; }
    .step-label { font-size: 0.6rem; }
}

/* ---------- WORKFLOW SECTIONS ---------- */
.workflow-section {
    border-left: 3px solid transparent;
    transition: border-color 0.3s;
}

.workflow-section.section-active {
    border-left-color: var(--ewt-primary);
}

.workflow-section .section-toggle {
    cursor: pointer;
    user-select: none;
}

.workflow-section .section-toggle .toggle-icon {
    transition: transform 0.3s;
}

.workflow-section .section-toggle.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* ---------- DETAIL CHIPS ---------- */
.detail-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.78rem;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.detail-chip i { font-size: 0.7rem; color: #6b7280; }
.detail-chip strong { font-weight: 600; }

/* ---------- STICKY SIDEBAR ---------- */
.workflow-sidebar {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.workflow-sidebar::-webkit-scrollbar { width: 4px; }
.workflow-sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ---------- INLINE ACTION ROW ---------- */
.tutor-action-row {
    background: #f8fafc;
    border-top: 1px dashed #e5e7eb;
}

.tutor-action-row td {
    padding: 8px 12px !important;
}

/* ---------- TOAST ---------- */
.ewt-toast {
    min-width: 300px;
}

/* ---------- FORM LEGIBILITY (Task 74, prompt-CRM-20) ----------
   Placeholders are hints, not data. They were rendering at the same size and
   weight as real values, so a form full of examples read as a form full of
   entries. Hints are now smaller and much fainter; entered data keeps normal
   size and colour, and field labels are slightly larger so they lead the eye. */

.form-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.35rem;
}

/* Typed/selected values stay full strength */
.form-control,
.form-select {
    color: #212529;
}

/* Placeholder hints — smaller, much fainter.
   Task 74 redux (prompt-CRM-21): on phones these were still rendering at
   near-full prominence (page-level styles and mobile UA defaults were
   winning), so the rules are now !important and sized in px. */
.form-control::placeholder,
.form-select::placeholder,
textarea.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    font-size: 12px !important;
    font-weight: 400 !important;
    color: #c3c9cf !important;
    opacity: 1 !important;     /* Firefox dims placeholders by default */
}
.form-control::-webkit-input-placeholder,
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder { font-size: 12px !important; color: #c3c9cf !important; }
.form-control::-moz-placeholder,
input::-moz-placeholder { font-size: 12px !important; color: #c3c9cf !important; opacity: 1 !important; }

/* Task 78 (prompt-CRM-21) — availability rows on the tutor forms: the default
   09:00 AM / 06:00 PM read like real entries. Rows stay faint until the day's
   checkbox is ticked (JS toggles .avail-active on the row). */
.avail-time {
    color: #c3c9cf;
    font-size: 0.85rem;
}
.avail-active .avail-time {
    color: #212529;
    font-size: 1rem;
}

/* A <select> still showing its "-- Select --" option is a hint too */
.form-select:has(option[value=""]:checked) {
    color: #b6bdc4;
}
.form-select option { color: #212529; }
.form-select option[value=""] { color: #b6bdc4; }

/* Select2 (subject/school pickers) */
.select2-container--bootstrap-5 .select2-selection__placeholder {
    font-size: 0.85em;
    color: #b6bdc4;
}

/* Helper text under a field — guidance, so quieter than the value */
.form-text {
    font-size: 0.78rem;
    color: #9aa3ab;
}

/* Task 89 (prompt-CRM-24) — phones: keep every top-bar icon inside the blue
   bar. They used to wrap onto a second row below it, white on the white page. */
@media (max-width: 575.98px) {
    .ewt-navbar .container-fluid {
        flex-wrap: nowrap;
        padding-left: 0.25rem;
        padding-right: 0.5rem;
    }
    .ewt-navbar #sidebarToggle { margin-right: 0.25rem !important; padding-left: 0.25rem; padding-right: 0.25rem; }
    .ewt-navbar .navbar-brand { margin-right: 0.25rem; }
    .ewt-navbar .navbar-brand img { height: 30px; }
    .ewt-navbar .ms-auto { flex-shrink: 0; }
    .ewt-navbar .ms-auto > * { margin-right: 0.35rem !important; }
    .ewt-navbar .ms-auto > :last-child { margin-right: 0 !important; }
}
