﻿/* ============================================================================
   iPROS Portal — Master Stylesheet
   Centralized styles for tables, forms, buttons, modals, and components.
   Follows the iPROS Design System specifications.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. CSS VARIABLES (Design Tokens)
   ---------------------------------------------------------------------------- */
:root {
    --tm-orange:        #ff751b;
    --tm-blue:          #1800e7;
    --tm-blue-hover:    #1E4A7A;
    --tm-dark-gray:     #06013A;
    --tm-light-gray:    #F5F5F5;
    --tm-sidebar-bg:    #FFFFFF;
    --tm-menu-text:     #2D3748;

    /* Text colors */
    --tm-text-primary:  #24292e;
    --tm-text-muted:    #586069;
    --tm-text-label:    #586069;

    /* Backgrounds */
    --tm-section-bg:    #e8f0f8;
    --tm-table-header:  #f8f9fa;
    --tm-recipient-th:  #f0f0f0;
    --tm-row-hover:     #f0f7ff;

    /* Borders */
    --tm-border-light:  #d1d5da;
    --tm-border-muted:  #dee2e6;
}


/* ----------------------------------------------------------------------------
   2. GLOBAL / BODY
   ---------------------------------------------------------------------------- */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    background-color: var(--tm-light-gray);
}


/* ----------------------------------------------------------------------------
   3. CARD STYLES
   ---------------------------------------------------------------------------- */

/* --- List / Index card header (h5 style) --- */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header {
    background-color: #1800e7;
    color: #fff;
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
    font-size: 1.25rem; /* ~20px, h5 equivalent */
}

/* --- Detail / Form card header (gradient) --- */
.card-header-gradient {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: #1800e7;
    color: #fff;
    border-radius: 10px 10px 0 0 !important;
}


/* ----------------------------------------------------------------------------
   4. FILTER / SEARCH SECTION
   ---------------------------------------------------------------------------- */
.filter-section {
    background-color: var(--tm-section-bg);
    border-left: 4px solid var(--tm-blue);
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 0 4px 4px 0;
}

.filter-section strong,
.filter-section .filter-title {
    color: var(--tm-blue);
    font-weight: 700;
}


/* ----------------------------------------------------------------------------
   5. FORM LABELS & INPUTS
   ---------------------------------------------------------------------------- */

/* Form labels — 13px / fw-medium (500) */
.form-label,
label.small,
label.form-label {
    font-size: 13px;
    font-weight: 500;
}

/* Form inputs — all sizes standardized to 13px */
.form-control,
.form-select,
.form-control-sm,
.form-select-sm {
    font-size: 13px;
}


/* ----------------------------------------------------------------------------
   6. SECTION HEADERS (Detail / Form views)
   ---------------------------------------------------------------------------- */
.section-header {
    background-color: var(--tm-section-bg);
    color: var(--tm-blue);
    border-left: 4px solid var(--tm-blue);
    padding: 10px 18px;
    margin-bottom: 18px;
    border-radius: 0 4px 4px 0;
    letter-spacing: 0.3px;
}

.section-header h6,
.section-header .section-title {
    margin: 0;
    color: var(--tm-blue);
    font-size: 14px;
    font-weight: 600;
}

.section-header i,
.section-header .fa,
.section-header .fas,
.section-header .far {
    font-size: 16px;
}

.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--tm-border-muted), transparent);
    margin: 24px 0;
}


/* ----------------------------------------------------------------------------
   7. INFO LABELS & VALUES (Detail views)
   ---------------------------------------------------------------------------- */
.info-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--tm-text-muted);
    flex: 0 0 200px;
}

.info-value {
    font-size: 13px;
    color: var(--tm-text-primary);
}

/* Ref badge (e.g. "CDR Ref No: …") */
.ref-badge {
    font-size: 13px;
    font-weight: 600;
    background-color: var(--tm-section-bg);
    color: var(--tm-blue);
    border-radius: 3px;
    padding: 4px 10px;
    display: inline-block;
}


/* ----------------------------------------------------------------------------
   8. REMARKS
   ---------------------------------------------------------------------------- */
.remarks-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--tm-text-primary);
}

.remarks-textarea,
textarea.form-control {
    font-size: 13px;
    border: 1px solid var(--tm-border-light);
    border-radius: 3px;
    min-height: 80px;
}


/* ----------------------------------------------------------------------------
   9. BUTTONS
   ---------------------------------------------------------------------------- */

/* Primary / Brand */
.btn-primary {
    background-color: var(--tm-blue);
    border-color: var(--tm-blue);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--tm-blue-hover);
    border-color: var(--tm-blue-hover);
    color: #fff;
}

/* Search / Filter buttons — 13px, uppercase, tracked */
.btn-search,
.btn-filter,
.btn-clear {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-radius: 6px;
}

/* Action buttons (Send to NA, Reject, Back, etc.) */
.btn-action {
    font-size: 14px;
    font-weight: 500;
    padding: 10px 24px;
    border-radius: 3px;
}

.btn-action i,
.btn-action .fa,
.btn-action .fas {
    font-size: 13px;
}

/* Reset / Clear button */
.btn-reset {
    background-color: #6259A4;
    border-color: #6259A4;
    color: #fff;
}

.btn-reset:hover {
    background-color: #4f4892;
    border-color: #4f4892;
    color: #fff;
}

/* Extra-small button */
.btn-xs {
    font-size: 12px;
    padding: 2px 8px;
    line-height: 1.5;
}


/* ----------------------------------------------------------------------------
   10. TABLES
   ---------------------------------------------------------------------------- */

/* Table header */
.table th {
    background-color: var(--tm-table-header);
    border-bottom: 2px solid var(--tm-blue);
    font-weight: normal;
    font-size: 13px;
}

/* Table body */
.table td {
    font-size: 13px;
    vertical-align: middle;
}

/* Table data links */
.table td a:not(.btn) {
    color: #1800e1 !important;
    text-decoration: none;
}
.table td a:not(.btn):hover {
    color: #1200b0 !important;
    text-decoration: underline;
}

/* Table spacing */
.table {
    margin-bottom: 0.5rem;
}

.table-responsive {
    margin-bottom: 0.25rem;
}

/* Resizable table — Pattern A (CSS-only resize handles) */
.resizable-table {
    table-layout: fixed;
    width: 100%;
}

.resizable-table th {
    position: relative;
    resize: horizontal;
    overflow: hidden;
    min-width: 60px;
    white-space: nowrap;
}

.resizable-table th::-webkit-resizer {
    display: none;
}

.resizable-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Resizable table — Pattern B (JS-driven column resize via wrapper) */
.table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.table-wrapper .resizable-table {
    table-layout: auto;
    width: auto;
    min-width: 100%;
}

.resizable-column {
    position: relative;
    padding-right: 20px !important;
    user-select: none;
    -webkit-user-select: none;
}

.resizable-column::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    cursor: col-resize;
}

/* Recipients table (email recipients etc.) */
.recipients-table th {
    background-color: var(--tm-recipient-th);
    font-weight: 600;
}

.recipients-table tbody tr:hover {
    background-color: var(--tm-row-hover);
}

/* "Select Email Recipients" title */
.recipients-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--tm-blue);
}


/* ----------------------------------------------------------------------------
   11. STATUS BADGES
   ---------------------------------------------------------------------------- */
.badge {
    font-weight: 700;
}

.badge-status {
    padding: 5px 10px;
    border-radius: 20px;
}

/* Badge color overrides — solid, 55% HSL lightness (slightly lighter than pure ~50%) */
.badge.bg-primary   { background-color: hsl(213, 98%, 55%) !important; color: #fff !important; } /* ACT */
.badge.bg-success   { background-color: hsl(152, 69%, 55%) !important; color: #fff !important; } /* COMPLETED */
.badge.bg-danger    { background-color: hsl(354, 70%, 55%) !important; color: #fff !important; } /* CANCEL/REJECT */
.badge.bg-warning   { background-color: hsl(45, 100%, 55%) !important; color: #212529 !important; } 
.badge.bg-consent   { background-color: hsl(60, 100%, 55%) !important; color: #212529 !important; } /* NA PENDING CONSENT */
.badge.bg-approval  { background-color: hsl(75, 100%, 55%) !important; color: #212529 !important; } /* NA PENDING APPROVAL */
.badge.bg-info      { background-color: hsl(188, 86%, 55%) !important; color: #212529 !important; } /* INFO */
.badge.bg-secondary { background-color: hsl(208,   7%, 55%) !important; color: #fff !important; } /* DRAFT */
.badge.bg-revert    { background-color: hsl(24,   100%, 55%) !important; color: #000 !important; } /* REVERTED */
.badge.bg-inter     { background-color: hsl(264,   100%, 55%) !important; color: #fff !important; } /* INTERCONNECT */
.badge.bg-offnet    { background-color: hsl(240,   100%, 55%) !important; color: #fff !important; } /* OFFNET */


/* ----------------------------------------------------------------------------
   12. FORM FIELD STATES (Read-only / Editable)
   ---------------------------------------------------------------------------- */
.read-only-field,
.readonly-field {
    background-color: #f8f9fa !important;
    border: 1px solid #e9ecef !important;
    color: var(--tm-text-primary);
    cursor: default;
}

.editable-field {
    border: 1px solid #007bff !important;
    background-color: #ffffff !important;
}

.editable-field-marker {
    border-left: 3px solid #ffc107;
    padding-left: 8px;
}

.editable-section {
    background-color: #fff9e6;
    border: 2px solid #ffc107;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.required-asterisk {
    color: #dc3545;
    font-weight: bold;
    margin-left: 2px;
}


/* ----------------------------------------------------------------------------
   13. MODALS (Theme modal)
   ---------------------------------------------------------------------------- */
.theme-modal {
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 24px rgba(46, 92, 154, 0.18);
    border: none;
    overflow: hidden;
}

.theme-modal-header {
    background: #1800e7;
    color: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 18px 24px 12px 24px;
    font-size: 1.25rem;
    font-weight: 600;
}

.theme-modal-footer {
    background: #f8f9fa;
    border-top: 1px solid #e5e5e5;
    padding: 16px 24px;
}

.theme-modal .modal-body {
    padding: 24px;
    font-size: 1.1rem;
    color: #333;
}

.theme-modal .btn-close {
    color: #fff !important;
    filter: brightness(1000%) invert(1);
    opacity: 1;
    font-size: 1rem;
    margin-right: 8px;
}

.btn-theme-cancel {
    background: #6c757d;
    color: #fff;
    border: 1px solid #6c757d;
    border-radius: 6px;
    padding: 8px 20px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.btn-theme-cancel:hover {
    background: var(--tm-blue);
    color: #fff;
}

.btn-theme-delete {
    background: #d9534f;
    color: #fff;
    border: 1px solid #d9534f;
    border-radius: 4px;
    padding: 8px 20px;
    font-weight: 500;
    margin-left: 8px;
    transition: background 0.2s, color 0.2s;
}

.btn-theme-delete:hover {
    background: #c9302c;
    color: #fff;
}


/* ----------------------------------------------------------------------------
   14. PAGINATION
   ---------------------------------------------------------------------------- */
.pagination {
    margin: 0;
}

.pagination-bar {
    background: #f8f9fa;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.pagination-info {
    font-size: 0.85rem;
    color: #6b7280;
    white-space: nowrap;
    line-height: 1.1;
}

.pagination .page-link {
    color: #495057;
    border: 1px solid var(--tm-border-muted);
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
    margin: 0 0.125rem;
    font-size: 0.875rem;
    line-height: 1.5;
    min-width: 36px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease-in-out;
}

.pagination .page-link:hover {
    color: #fff;
    background-color: var(--tm-blue);
    border-color: var(--tm-blue);
}

.pagination .page-item.active .page-link {
    background-color: var(--tm-blue);
    border-color: var(--tm-blue);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
    pointer-events: none;
    background-color: #fff;
    border-color: var(--tm-border-muted);
    opacity: 0.5;
}

/* Pagination stack layout */
.pagination-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

/* Table footer */
.table-footer-actions {
    margin-top: 0.5rem;
    padding-top: 0.25rem;
}

.table-footer-actions .form-select-sm,
#perPageSelect {
    height: 36px;
    font-size: 0.85rem;
}

/* Hide SVG pagination icons, use text arrows */
nav svg,
nav[role="navigation"] svg,
nav[aria-label] svg,
span[aria-label] svg,
a[aria-label] svg,
.inline-flex svg,
svg.w-5,
svg.h-5 {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -99999px !important;
    pointer-events: none !important;
}

.w-5 { width: 0 !important; }
.h-5 { height: 0 !important; }

span[aria-label*="Previous"] span:not([aria-current])::before,
a[aria-label*="Previous"]::before,
span[aria-label*="previous"] span:not([aria-current])::before,
a[aria-label*="previous"]::before {
    content: "\2039" !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    display: inline-block !important;
}

span[aria-label*="Next"] span:not([aria-current])::before,
a[aria-label*="Next"]::before,
span[aria-label*="next"] span:not([aria-current])::before,
a[aria-label*="next"]::before {
    content: "\203A" !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    display: inline-block !important;
}

nav[role="navigation"] a,
nav[role="navigation"] span {
    padding: 0.5rem 0.75rem !important;
    min-width: 2.5rem !important;
    text-align: center !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}


/* ----------------------------------------------------------------------------
   15. EDITABLE CELL (Inline edit pattern — admin file views)
   ---------------------------------------------------------------------------- */
.editable-cell {
    cursor: pointer;
    transition: background 0.15s;
}

.editable-cell:hover {
    border: 1px dashed var(--tm-blue);
    background-color: #f8f9fa;
}

.editable-cell.editing {
    background-color: #fff9e6;
}

.editable-input {
    width: 100%;
    border: 1px solid var(--tm-blue);
    border-radius: 3px;
    padding: 4px 8px;
    font-size: inherit;
}

.edit-indicator {
    color: var(--tm-blue);
    font-size: 12px;
}

.save-indicator {
    color: #28a745;
    font-size: 12px;
}

.error-indicator {
    color: #dc3545;
    font-size: 12px;
}


/* ----------------------------------------------------------------------------
   16. FORM VALIDATION (Shared)
   ---------------------------------------------------------------------------- */

/* Remove green validation styling from valid fields */
.was-validated .form-control:valid,
.was-validated .form-select:valid,
.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--tm-border-muted) !important;
    background-image: none !important;
    padding-right: 0.75rem !important;
}

.was-validated .form-control:valid:focus,
.was-validated .form-select:valid:focus,
.form-control.is-valid:focus,
.form-select.is-valid:focus {
    border-color: #86b7fe !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

.was-validated .form-check-input:valid,
.form-check-input.is-valid {
    border-color: var(--tm-border-muted) !important;
}

.was-validated .form-check-input:valid:checked,
.form-check-input.is-valid:checked {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.was-validated .form-check-input:valid:focus,
.form-check-input.is-valid:focus {
    border-color: #86b7fe !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

.was-validated .form-check-label,
.was-validated .form-label,
.form-check-input:valid ~ .form-check-label,
.form-check-input.is-valid ~ .form-check-label {
    color: inherit !important;
}

/* Invalid field styling */
.was-validated .form-control:invalid,
.was-validated .form-select:invalid,
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:invalid:focus,
.was-validated .form-select:invalid:focus,
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

.invalid-feedback {
    display: none;
    color: #dc3545;
    font-size: 0.875em;
    margin-top: 0.25rem;
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
    display: block;
}

.valid-feedback {
    display: none !important;
}

.was-validated .form-control:valid ~ .valid-feedback,
.was-validated .form-select:valid ~ .valid-feedback,
.form-control.is-valid ~ .valid-feedback,
.form-select.is-valid ~ .valid-feedback {
    display: none !important;
}


/* ----------------------------------------------------------------------------
   17. READ-ONLY FORM CONTROL
   ---------------------------------------------------------------------------- */
.form-control.bg-light {
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    min-height: 38px;
    cursor: default;
    color: #212529;
}


/* ----------------------------------------------------------------------------
   18. UTILITY CLASSES
   ---------------------------------------------------------------------------- */
.text-orange {
    color: var(--tm-orange);
}

.bg-orange {
    background-color: #0097A7 !important;
    color: #fff !important;
}

.blue-divider {
    border: 0;
    height: 2px;
    background-color: var(--tm-blue);
    margin: 16px 0;
}

.file-link {
    color: var(--tm-blue);
    text-decoration: none;
}

.file-link:hover {
    text-decoration: underline;
    color: var(--tm-blue-hover);
}

.radio-group-card {
    border: 1px solid var(--tm-border-muted);
    border-radius: 6px;
    padding: 12px 8px;
    transition: border-color 0.2s;
}

.radio-group-card:hover {
    border-color: var(--tm-blue);
}

/* ─── Email Recipients Table Checkboxes (all Circuit Management modules) ─── */
#emailRegistrationsTable input[type="checkbox"],
#emailRecipientsContainer input[type="checkbox"],
#selectAllEmails {
    width: 1.2em !important;
    height: 1.2em !important;
    cursor: pointer;
    border: 1px solid #dee2e6 !important;
    border-radius: 3px !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background-color: #fff !important;
    background-image: none !important;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
    vertical-align: middle;
}

#emailRegistrationsTable input[type="checkbox"]:checked,
#emailRecipientsContainer input[type="checkbox"]:checked,
#selectAllEmails:checked {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e") !important;
    background-size: 100% !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

#emailRegistrationsTable input[type="checkbox"]:focus,
#emailRecipientsContainer input[type="checkbox"]:focus,
#selectAllEmails:focus {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
    outline: none !important;
}

/* ─── Modal Email Recipients List ─── */
.modal-email-recipients-list {
    margin-top: 10px;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0;
}

.modal-email-recipients-list table {
    width: 100%;
    margin-bottom: 0;
    font-size: 12px;
}

.modal-email-recipients-list table th {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: #6c757d;
    padding: 6px 10px;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 1;
}

.modal-email-recipients-list table td {
    padding: 5px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #495057;
}

.modal-email-recipients-list table tr:last-child td {
    border-bottom: none;
}
