﻿/* ── Override Bootstrap Primary Color to Match Navbar (scoped to Rules page only) ── */
.rules-page {
    --bs-primary: #235d9e;
    --bs-primary-rgb: 35, 93, 158;
}

.nav-tab-btn {
    border-radius: 5px;
    padding: 0.4rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease-in-out;
}

/* Badge specific color definitions based on your original hex codes */
.badge-all.tab-inactive { background-color: rgba(13, 110, 253, 0.1); color: #0d6efd; }
.badge-all.tab-active { background-color: #fff; color: #0d6efd; }

.badge-validation.tab-inactive { background-color: #f5f3ff; color: #a855f7; }
.badge-validation.tab-active { background-color: #fff; color: #a855f7; }

.badge-audit.tab-inactive { background-color: #f0fdf4; color: #22c55e; }
.badge-audit.tab-active { background-color: #fff; color: #22c55e; }

.badge-quarterly.tab-inactive { background-color: #fff7ed; color: #f97316; }
.badge-quarterly.tab-active { background-color: #fff; color: #f97316; }

/* Filter Panel Styling */
.filter-panel {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
    border-color: #e9ecef !important;
}

/* Crew filter dropdown — portal approach (same as .crew-dropdown-portal in
   calendar.css): position:fixed escapes every ancestor overflow/stacking
   context so the menu can never be clipped behind later components. */
.rule-crew-dropdown-portal {
    position: fixed !important;
    top: auto;
    left: auto;
    margin-top: 2px;
    min-width: 180px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 99999;
}

.search-input-group {
    background-color: #f8f9fa !important;
    border-radius: 0.5rem;
    overflow: hidden;
}

.search-input-group:focus-within {
    background-color: #f1f3f5 !important;
}

.search-input-group .form-control::placeholder {
    font-size: 0.875rem;
    color: #6c757d;
}

.filter-select {
    background-color: #f8f9fa !important;
    border: none !important;
    color: #212529;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 2.25rem 0.5rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.filter-select:hover, .filter-select:focus {
    background-color: #f1f3f5 !important;
    outline: none;
}

.filter-select:focus {
    box-shadow: none !important;
}

/* Drawer Base Variables/Overlays */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Base Panel */
.drawer-panel {
    position: fixed;
    top: 0; bottom: 0;
    width: 600px;
    max-width: 100vw;
    background: white;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* Right Sliding fixed layout */
.drawer-panel.right { transform: translateX(100%); right: 0; }
.drawer-panel.right.open { transform: translateX(0); }

/* Layout Grid Details */
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #eaeaea;
    border-top: 4px solid #0078d4;
}
.drawer-header h3 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.drawer-header .subtitle { color: #666; font-size: 0.875rem; }
.close-btn { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: #666; }

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.drawer-footer {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-top: 1px solid #eaeaea;
    background: #fdfdfd;
}

/* Specific Component Form Styling matching screenshots */
.section-title { font-size: 1.15rem; font-weight: 600; margin: 1.5rem 0 1rem 0; }
.form-section h5 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.875rem; }
.form-control { width: 100%; padding: 0.6rem; border: 1px solid #ccc; border-radius: 4px; font-size: 0.875rem;}
.form-control:disabled { background-color: #f5f5f5; cursor: not-allowed; }
.required { color: #d13438; }
.char-count { text-align: right; font-size: 0.75rem; color: #888; margin-top: 0.25rem; }

/* Radio Buttons layout */
.radio-options { display: flex; flex-direction: column; gap: 0.5rem;}
.radio-box {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem;
    border: 1px solid #ccc; border-radius: 4px; cursor: pointer; transition: 0.2s;
}
.radio-box.active { border-color: #0078d4; background-color: #f3f9fd; }

.complex-radio-group { display: flex; flex-direction: column; gap: 0.75rem; }
.complex-radio { border: 1px solid #ccc; border-radius: 6px; padding: 1rem; transition: 0.2s; }
.complex-radio.active { border-color: #0078d4; background-color: #f3f9fd;}
.radio-header { display: flex; align-items: flex-start; gap: 0.75rem; cursor: pointer; margin-bottom: 0px;}
.radio-content strong { display: block; font-size: 0.95rem; font-weight: 600; }
.radio-content span { display: block; font-size: 0.8rem; color: #666; margin-top: 0.2rem; }
.checkbox-wrapper { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; padding-left: 1.8rem; font-size: 0.875rem; }

.system-rule-banner {
    display: flex; gap: 1rem; padding: 1rem; background: #fbfbfb; border: 1px solid #e1e1e1; border-radius: 4px;
    margin: 1rem 0; color: #333;
}
.system-rule-banner i { font-size: 1.2rem; color: #555; }
.banner-text strong { display: block; font-size: 0.9rem; }
.banner-text span { font-size: 0.85rem; color: #666; }

/* Buttons (scoped to Rules page) */
.rules-page .btn { padding: 0.5rem 1.25rem; border-radius: 4px; font-weight: 600; cursor: pointer; border: none;}
.rules-page .btn-primary { background-color: var(--bs-primary) !important; color: #fff !important; border-color: var(--bs-primary) !important; }
.rules-page .btn-primary:hover,
.rules-page .btn-primary:focus,
.rules-page .btn-primary:active {
    background-color: #1a4875 !important;
    border-color: #1a4875 !important;
    color: #fff !important;
}
.rules-page .btn-primary:disabled {
    background-color: #E5E7EB !important;
    border-color: #E5E7EB !important;
    color: #9CA3AF !important;
    opacity: 1 !important;
    cursor: not-allowed;
}

.rules-page .rule-save-btn:disabled {
    background-color: #E5E7EB !important;
    border-color: #E5E7EB !important;
    color: #9CA3AF !important;
    opacity: 1 !important;
    cursor: not-allowed;
}

.rules-page .btn-outline { border: 1px solid #ccc; background: white; color: #333; }
.rules-page .btn-outline:hover { background: #f3f3f3; }

/* ── Stat Pills ─────────────────────────────────────────── */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: 999px !important;
    border: 1.5px solid #e2e8f0;
    background: #ffffff;
    font-size: 0.875rem;
    font-weight: 400;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.stat-pill strong {
    font-weight: 700;
    color: #1e293b;
    margin-left: 2px;
}

.stat-pill:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.stat-pill:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* ── Active variants ────────────────────────────────────── */
.stat-pill--active-all {
    border: 2px solid #1e293b !important;
    background: #f8fafc;
    color: #1e293b;
    font-weight: 600;
}

.stat-pill--active-success {
    border: 2px solid #22c55e !important;
    background: #f0fdf4;
    color: #166534;
}

.stat-pill--active-secondary {
    border: 2px solid #94a3b8 !important;
    background: #f8fafc;
    color: #475569;
}

.stat-pill--active-danger {
    border: 2px solid #ef4444 !important;
    background: #fef2f2;
    color: #991b1b;
}

.stat-pill--active-warning {
    border: 2px solid #f59e0b !important;
    background: #fffbeb;
    color: #92400e;
}

/* ── Description tooltip link ───────────────────────────── */
.rule-description-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--bs-primary);
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: none;
    position: relative;
}

.rule-description-link:hover {
    text-decoration: underline;
}

.rule-description-link[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #1e293b;
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    max-width: 280px;
    white-space: normal;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ── Rule list hover highlight ──────────────────────────── */
.rule-list-item:hover {
    background-color: #f8fafc;
}

.rule-list-item:last-child {
    border-bottom: none !important;
}

/* ── Trigger Type Selector ─────────────────────────────────── */
.trigger-card {
    background-color: #ffffff;
    border-color: #dee2e6 !important;
    transition: border-color 0.15s, background-color 0.15s;
}

.trigger-card--info {
    border-color: #0d6efd !important;
    background-color: #ffffff;
}

.trigger-card--warning {
    border-color: #dee2e6 !important;
    background-color: #fffbeb;
}

.trigger-card--danger {
    border-color: #dee2e6 !important;
    background-color: #fff1f0;
}

/* ── Rule list item typography ──────────────────────────── */
.rule-item-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #1e293b;
}

.rule-item-meta {
    font-size: 0.875rem;
    color: #64748b;
}

.rule-trigger-badge {
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
    padding: 2px 8px;
}

.rule-trigger-badge--approval {
    background-color: #fee2e2;
    color: #b91c1c;
}

.rule-trigger-badge--warning {
    background-color: #fef3c7;
    color: #92400e;
}

/* ── Rule accordion row typography ──────────────────────── */
.rule-accordion-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.01em;
}

/* ── Fix: app.css .btn { background: white } overrides Bootstrap btn variants ── */
.btn-danger {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #fff !important;
}
.btn-danger:hover {
    background-color: #bb2d3b !important;
    border-color: #b02a37 !important;
    color: #fff !important;
}

/* NOTE: btn-primary color for the Rules page is themed via .rules-page rules above. */

.btn-outline-secondary {
    background: transparent !important;
    border: 1px solid #6c757d !important;
    color: #6c757d !important;
}
.btn-outline-secondary:hover {
    background-color: #6c757d !important;
    color: #fff !important;
}

/* ── Always-visible ⋮ action button on rule rows ────────── */
.btn-light {
    background-color: #f8f9fa !important;
    color: #212529 !important;
}
.btn-light:hover {
    background-color: #e2e6ea !important;
}

/* ── Category Selector ──────────────────────────────────── */
.category-row:hover {
    background-color: #f8fafc;
}

.category-row--selected {
    background-color: #f0f4ff;
}

.category-rename-btn {
    opacity: 0;
    transition: opacity 0.15s;
}

.category-row:hover .category-rename-btn {
    opacity: 1;
}

.category-selector-dropdown {
    position: absolute;
    left: -1px;
    right: -1px;
    z-index: 200;
    border: 1px solid #dee2e6;
    border-top: none;
}

.category-selector-input-active {
    border-color: #7c3aed;
}

.category-add-btn {
    color: #7c3aed;
    font-size: 0.85rem;
}

.category-btn-primary {
    background-color: #7c3aed !important;
    border-color: #7c3aed !important;
}

.category-suggestions-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 300;
    max-height: 160px;
    overflow-y: auto;
}

.category-keys-list {
    max-height: 220px;
    overflow-y: auto;
}

/* ── Message Selector ───────────────────────────────────── */
.msg-row {
    cursor: pointer;
    font-size: 0.875rem;
}

.msg-row:hover {
    background-color: #f8fafc;
}

.msg-row--selected {
    background-color: #f0f4ff;
}

.msg-rewrite-btn {
    opacity: 0;
    transition: opacity 0.15s;
    font-size: 0.75rem;
}

.msg-row:hover .msg-rewrite-btn,
.msg-row--selected .msg-rewrite-btn {
    opacity: 1;
}

.msg-selector-trigger {
    min-height: 40px;
}

.msg-selector-dropdown {
    position: absolute;
    left: -1px;
    right: -1px;
    z-index: 200;
    border: 1px solid #dee2e6;
    border-top: none;
}

.msg-selector-list {
    max-height: 240px;
    overflow-y: auto;
}

.msg-add-btn {
    color: #7c3aed;
    font-size: 0.85rem;
}

.msg-char-count {
    font-size: 0.7rem;
}

/* US-format (MM/DD/YYYY) date input: hide native locale text, show overlay */
.us-date-input input[type="date"] {
    color: transparent;
}

.us-date-input .us-date-display {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    white-space: nowrap;
}

.us-date-input input[type="date"]:focus {
    color: inherit;
}

.us-date-input input[type="date"]:focus + .us-date-display {
    display: none;
}

.us-date-input input[type="date"]:disabled + .us-date-display {
    opacity: 0.65;
}

/* ── Toggle Switch Blue Theme (matching navbar, scoped to Rules page) ── */
.rules-page .form-check-input:checked {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
}

.rules-page .form-check-input:focus {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25) !important;
}
