/* ============================================================================
   SuperApp Portal Custom Additions
   Enhances dashboard.css with Modals, Drawers, Filter Bars, and Tags
   Adapted from Bayon Portal
   ============================================================================ */

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

/* Global Button Font Family Rule */
button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.btn,
.btn-primary,
.btn-outline,
.btn-success,
.btn-danger,
.btn-info,
.btn-sm,
.btn-icon,
.refresh-btn,
.logout-btn,
.page-btn,
.social-button,
.back-btn {
    font-family: 'Kantumruy Pro', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

/* Accessibility: Focus visible outlines */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip to main content link (accessibility) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* Filter Bar */
.filter-bar {
    background: white;
    border-radius: var(--card-radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 58, 92, 0.15);
}

.form-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background-color: white;
    outline: none;
    cursor: pointer;
}

/* Data Table */
.data-table-container {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.portal-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    user-select: none;
    white-space: nowrap;
}


.portal-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.portal-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Sticky header for data-table (whitelist page) */
.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
    user-select: none;
    white-space: nowrap;
}

/* Column resize handle */
.portal-table thead th .resize-handle,
.data-table thead th .resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    z-index: 11;
}

.portal-table thead th .resize-handle:hover,
.portal-table thead th .resize-handle.active,
.data-table thead th .resize-handle:hover,
.data-table thead th .resize-handle.active {
    background: #0284c7;
    opacity: 0.5;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #def7ec;
    color: #03543f;
}

.badge-danger {
    background: #fde8e8;
    color: #9b1c1c;
}

.badge-info {
    background: #e1effe;
    color: #1e429f;
}

/* Provider Icon */
.provider-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    background: #f1f5f9;
    flex-shrink: 0;
}

.provider-icon-fallback {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 4px;
    color: #64748b;
    font-size: 12px;
    flex-shrink: 0;
}

.provider-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Action Buttons */
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
}

.action-btns {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #64748b;
}

.pagination-controls {
    display: flex;
    gap: 6px;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    color: #334155;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: var(--primary);
}

/* Modal Backdrop & Dialog */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-dialog {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.2s ease-out;
}

.modal-dialog.modal-lg {
    max-width: 800px;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
}

.modal-close:hover {
    color: #1e293b;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

/* Tags Input / Display */
.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    min-height: 44px;
    margin-bottom: 12px;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e2e8f0;
    color: #1e293b;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
}

.tag-remove {
    cursor: pointer;
    color: #ef4444;
    font-weight: bold;
}

.tag-remove:hover {
    color: #b91c1c;
}

/* Switch */
.switch-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
}

.switch-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Loading & Alerts */
.toast-alert {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    background: #1e293b;
    color: white;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    display: none;
    font-size: 13px;
    animation: slideUp 0.3s ease;
}

.toast-alert.success {
    background: #10b981;
}

.toast-alert.error {
    background: #ef4444;
}

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

/* Progress Bar (portal-custom override) */
.progress-bar-container {
    background: #e2e8f0;
    border-radius: 9999px;
    height: 8px;
    min-width: 80px;
    overflow: hidden;
    position: relative;
    margin-top: 4px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s ease-in-out;
}

.progress-bar-fill.high {
    background: linear-gradient(90deg, #10b981, #059669);
}

.progress-bar-fill.medium {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.progress-bar-fill.low {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}
/* Table Card (for whitelist page) */
.table-card {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Word-break for ID columns */
.id-cell {
    word-break: break-all;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: #334155;
}
/* ============================================================================
   Static Content Pages (Term & Condition, Privacy Policy)
   ============================================================================ */

/* View Toggle (Mobile / Desktop) */
.view-toggle {
    display: inline-flex;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 8px;
}

.view-toggle-btn {
    border: none !important;
    border-radius: 0 !important;
    background: white !important;
    color: #64748b !important;
    padding: 5px 12px !important;
    font-size: 12px !important;
    transition: all 0.2s;
}

.view-toggle-btn:hover {
    background: #f1f5f9 !important;
    color: #334155 !important;
}

.view-toggle-btn.active {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

/* Static Content Container — Desktop view (side by side) */
.static-content-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
}

/* Mobile view (stacked, with phone frame) */
.static-content-container.mobile-view {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.static-content-container.mobile-view .static-content-panel {
    max-width: 375px;
    margin: 0 auto;
    border: 1px solid #e2e8f0;
    position: relative;
}

.static-content-container.mobile-view .static-content-panel::before {
    content: '📱 Mobile Preview';
    display: block;
    text-align: center;
    padding: 8px 0;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 12px;
}

.static-content-container.mobile-view .html-content,
.static-content-container.mobile-view .html-editor {
    font-size: 13px;
    line-height: 1.7;
}

.static-content-container.mobile-view .html-content h1 { font-size: 20px; }
.static-content-container.mobile-view .html-content h2 { font-size: 17px; }
.static-content-container.mobile-view .html-content h3 { font-size: 15px; }

/* Desktop view (full width panels) */
.static-content-container.desktop-view {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.static-content-container.desktop-view .static-content-panel {
    max-width: none;
    border: none;
}

.static-content-container.desktop-view .static-content-panel::before {
    content: none;
    display: none;
}

.static-content-panel {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.static-content-panel h2 {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
    color: var(--primary);
}

/* HTML content typography */
.html-content {
    line-height: 1.8;
    color: #334155;
    font-size: 14px;
}
.html-content h1 { font-size: 24px; margin: 20px 0 12px; color: #1e293b; }
.html-content h2 { font-size: 20px; margin: 16px 0 10px; color: #1e293b; }
.html-content h3 { font-size: 17px; margin: 14px 0 8px; color: #334155; }
.html-content p { margin: 0 0 12px; }
.html-content ul, .html-content ol { margin: 0 0 12px; padding-left: 24px; }
.html-content li { margin: 4px 0; }
.html-content a { color: var(--primary); text-decoration: underline; }

/* HTML Editor */
.html-editor {
    min-height: 400px;
    padding: 16px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    outline: none;
    line-height: 1.8;
    font-size: 14px;
    overflow-y: auto;
}

.editor-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: #f1f5f9;
    border-radius: 6px 6px 0 0;
    border: 1px solid #cbd5e1;
    border-bottom: none;
}

.editor-toolbar button {
    width: 32px;
    height: 32px;
    border: none;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #475569;
}

.editor-toolbar button:hover {
    background: var(--primary);
    color: white;
}

/* Static content meta info bar */
.static-content-meta {
    display: flex;
    gap: 24px;
    padding: 12px 20px;
    background: #f8fafc;
    border-radius: 8px;
    margin: 0 20px 0 20px;
    font-size: 13px;
    color: #64748b;
}

.static-content-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Static content page header */
.static-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px 16px 20px;
}

.static-content-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.static-content-header .action-btns {
    display: flex;
    gap: 8px;
}

/* Title input in edit mode */
.static-title-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    outline: none;
}

.static-title-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 58, 92, 0.15);
}