@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #0b0f19;
    --bg-card: #151c2c;
    --bg-input: #1e293b;
    --border-color: #2e3e5c;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --danger-color: #f43f5e;
    --warning-color: #f59e0b;
    --info-color: #0ea5e9;
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ------------------------------------------------------------------
   Bootstrap 5.3 dark-mode alignment.
   The layout sets <html data-bs-theme="dark">, which flips every stock
   Bootstrap component (tables, form-selects, dropdowns, modals, the
   *-subtle badge utilities) to its dark variant. This block re-points
   Bootstrap's dark palette at our custom tokens so those stock elements
   blend with the hand-styled -custom components instead of rendering in
   Bootstrap's default slate. Loaded after bootstrap.min.css, so it wins.
   ------------------------------------------------------------------ */
[data-bs-theme="dark"] {
    --bs-body-bg: var(--bg-main);
    --bs-body-color: var(--text-primary);
    --bs-emphasis-color: var(--text-primary);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-secondary);
    --bs-secondary-bg: var(--bg-input);
    --bs-tertiary-bg: var(--bg-input);
    --bs-border-color: var(--border-color);
    --bs-heading-color: var(--text-primary);
    --bs-card-bg: var(--bg-card);
    --bs-card-color: var(--text-primary);
    --bs-link-color-rgb: 99, 102, 241;
    --bs-link-hover-color-rgb: 79, 70, 229;
}

/* Stock tables (17 views use plain .table, not .table-custom): keep text
   readable and let the card/body surface show through. */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
}

/* Stock form-select / form-control that don't use the -custom classes. */
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-control {
    background-color: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Navbar */
.navbar-custom {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.8rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.navbar-brand-custom {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    background: linear-gradient(135deg, #a5b4fc, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link-custom {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 6px;
    transition: var(--transition);
}

.nav-link-custom:hover, .nav-link-custom.active {
    color: var(--text-primary) !important;
    background-color: var(--bg-input);
}

/* Container Wrapper */
.main-wrapper {
    flex: 1;
    padding: 2.5rem 1.5rem;
}

/* Cards */
.card-custom {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.8rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card-custom-hover:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 0 15px 35px -5px rgba(99, 102, 241, 0.15);
}

/* Buttons */
.btn-primary-custom {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    color: white;
}

.btn-secondary-custom {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-secondary-custom:hover {
    background-color: var(--border-color);
    color: white;
}

.btn-danger-custom {
    background-color: var(--danger-color);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-danger-custom:hover {
    background-color: #e11d48;
}

/* Badges */
.badge-custom {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    border-radius: 50px;
    text-transform: uppercase;
}

.badge-received { background-color: rgba(14, 165, 233, 0.15); color: var(--info-color); border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-processing { background-color: rgba(245, 158, 11, 0.15); color: var(--warning-color); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-processed { background-color: rgba(16, 185, 129, 0.15); color: var(--success-color); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-sent { background-color: rgba(99, 102, 241, 0.15); color: var(--primary-color); border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-failed { background-color: rgba(244, 63, 94, 0.15); color: var(--danger-color); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-partial { background-color: rgba(245, 158, 11, 0.15); color: var(--warning-color); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-retried { background-color: rgba(14, 165, 233, 0.15); color: var(--info-color); border: 1px solid rgba(14, 165, 233, 0.3); }

.badge-active { background-color: rgba(16, 185, 129, 0.15); color: var(--success-color); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-inactive { background-color: rgba(148, 163, 184, 0.15); color: var(--text-secondary); border: 1px solid rgba(148, 163, 184, 0.3); }

/* Form Elements */
.form-control-custom {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary) !important;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    transition: var(--transition);
}

.form-control-custom:focus {
    background-color: var(--bg-input);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    outline: none;
}

.form-label-custom {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

/* Wizard Stepper */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    position: relative;
}

.wizard-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 4%;
    right: 4%;
    height: 3px;
    background-color: var(--border-color);
    z-index: 1;
}

.wizard-step {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 20%;
}

.wizard-step-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 3px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: var(--transition);
}

.wizard-step.active .wizard-step-circle {
    border-color: var(--primary-color);
    color: var(--text-primary);
    background-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.wizard-step.completed .wizard-step-circle {
    border-color: var(--success-color);
    color: white;
    background-color: var(--success-color);
}

.wizard-step-label {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    transition: var(--transition);
}

.wizard-step.active .wizard-step-label {
    color: var(--text-primary);
}

.wizard-step.completed .wizard-step-label {
    color: var(--success-color);
}

.wizard-content-panel {
    display: none;
}

.wizard-content-panel.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tables */
.table-custom {
    color: var(--text-primary) !important;
}

.table-custom th {
    background-color: #1a2336 !important;
    border-bottom: 2px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem !important;
}

.table-custom td {
    background-color: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1rem !important;
    vertical-align: middle !important;
}

.table-custom tbody tr:hover td {
    background-color: #1b2438 !important;
}

/* Code Editor & Payload blocks */
.code-editor-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.code-editor-header {
    background-color: #1a2336;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-editor-title {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.code-textarea {
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    background-color: #0b0f19 !important;
    color: #e2e8f0 !important;
    border: none !important;
    border-radius: 0 !important;
    resize: vertical;
    padding: 1rem;
    line-height: 1.5;
}

.payload-preview {
    font-family: monospace;
    font-size: 0.85rem;
    background-color: #0b0f19;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: #38bdf8;
    overflow-x: auto;
    max-height: 400px;
    white-space: pre-wrap;
}

/* Statistics Widgets */
.stat-widget {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

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

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.2rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Spreadsheet Grid View */
.sheet-container {
    overflow: auto;
    max-height: calc(100vh - 280px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.sheet-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.sheet-table th {
    position: sticky;
    top: 0;
    background-color: #1a2336;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    z-index: 10;
    font-size: 0.85rem;
    white-space: nowrap;
}

.sheet-table td {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: #e2e8f0;
    white-space: nowrap;
}

.sheet-table tr:hover td {
    background-color: #1e293b;
}

.alert-custom {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 1rem 1.5rem;
}

.alert-success-custom {
    border-color: rgba(16, 185, 129, 0.4);
    background-color: rgba(16, 185, 129, 0.05);
}

.alert-danger-custom {
    border-color: rgba(244, 63, 94, 0.4);
    background-color: rgba(244, 63, 94, 0.05);
}

/* Shared in-app dialogs replace native alert / confirm / prompt popups. */
.app-dialog .modal-dialog {
    max-width: 520px;
}

.app-dialog-content {
    background: linear-gradient(145deg, #182135, var(--bg-card));
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.app-dialog-heading {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.app-dialog-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.16);
    border: 1px solid rgba(99, 102, 241, 0.32);
    font-size: 1.25rem;
}

.app-dialog[data-tone="danger"] .app-dialog-icon {
    color: #fda4af;
    background: rgba(244, 63, 94, 0.14);
    border-color: rgba(244, 63, 94, 0.32);
}

.app-dialog[data-tone="warning"] .app-dialog-icon {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.32);
}

.app-dialog[data-tone="info"] .app-dialog-icon {
    color: #7dd3fc;
    background: rgba(14, 165, 233, 0.14);
    border-color: rgba(14, 165, 233, 0.32);
}

.app-dialog[data-tone="success"] .app-dialog-icon {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.32);
}

.app-dialog-actions {
    gap: 0.75rem;
}

@media (max-width: 575.98px) {
    .app-dialog .modal-dialog {
        margin: 1rem;
    }

    .app-dialog-actions .btn {
        flex: 1;
    }
}
