/* =====================================================================
   AOX Dynamic Redirect Manager - Modern Admin Stylesheet
   Clean, responsive, fast-loading design
   ===================================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;
    
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fef3c7;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 60px;
}

/* ---------------------------------------------------------------------
   Header & Navigation
   --------------------------------------------------------------------- */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.nav-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.nav-domain {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-page);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-family: monospace;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---------------------------------------------------------------------
   Layout & Container
   --------------------------------------------------------------------- */
.container {
    max-width: 1240px;
    margin: 28px auto 0;
    padding: 0 20px;
}

/* ---------------------------------------------------------------------
   Metric Summary Cards
   --------------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-info .stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-info .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }

/* ---------------------------------------------------------------------
   Toolbar & Action Area
   --------------------------------------------------------------------- */
.toolbar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.search-box {
    position: relative;
    min-width: 260px;
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background-color: var(--bg-page);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s ease;
}

.search-box input:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 14px;
    pointer-events: none;
}

.filter-select {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background-color: var(--bg-page);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
}

.filter-select:focus {
    border-color: var(--primary);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px 0 rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 3px 6px 0 rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-page);
    border-color: #cbd5e1;
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm {
    padding: 5px 10px;
    font-size: 13px;
    border-radius: 5px;
}

.btn-icon {
    padding: 6px;
    border-radius: var(--radius-sm);
    line-height: 1;
}

/* ---------------------------------------------------------------------
   Table Styles
   --------------------------------------------------------------------- */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

thead {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

th {
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background-color: #fcfdfe;
}

/* Code Cell */
.code-badge-wrapper {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.code-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    font-size: 15px;
    color: var(--primary);
    text-decoration: none;
}

.code-pill:hover {
    text-decoration: underline;
}

.permanent-url {
    font-size: 11px;
    color: var(--text-light);
    font-family: monospace;
    white-space: nowrap;
}

/* Destination URL input inside row */
.url-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 440px;
    width: 100%;
}

.url-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
    background: #fff;
}

.url-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.url-input.saved-highlight {
    border-color: var(--success);
    background-color: var(--success-bg);
}

/* Status Badges & Toggle */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
}

.status-pill.active {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
}

.status-pill.blocked {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.status-pill:hover {
    opacity: 0.85;
    transform: scale(0.98);
}

/* Scan Pill */
.scan-count-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    background: #f1f5f9;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    font-family: monospace;
}

/* Row Actions */
.row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
}
.modal-close-btn:hover { color: var(--text-main); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* QR Code Display Container */
.qr-preview-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #f8fafc;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

#modal-qr-canvas {
    background: #ffffff;
    padding: 14px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: inline-block;
}

#modal-qr-canvas canvas, #modal-qr-canvas svg {
    display: block;
}

.qr-link-display {
    width: 100%;
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.qr-link-input {
    flex: 1;
    padding: 8px 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: monospace;
    color: var(--text-main);
}

/* Form Groups in Modals */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.form-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ---------------------------------------------------------------------
   Toast Notifications
   --------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10000;
}

.toast {
    background: #1e293b;
    color: #f8fafc;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 250px;
}

.toast.success { background: #065f46; border-left: 4px solid #34d399; }
.toast.error   { background: #991b1b; border-left: 4px solid #f87171; }
.toast.info    { background: #1e293b; border-left: 4px solid #60a5fa; }

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------------------------------------------------------------------
   Empty State & Utility
   --------------------------------------------------------------------- */
.empty-state {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }
    .toolbar-card {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-left, .toolbar-right {
        width: 100%;
    }
    .search-box {
        min-width: 100%;
    }
    .url-input-group {
        max-width: 220px;
    }
}
