/* ==========================================================================
   ANTI-GRAVITY V3.2 — RADAR COMPONENTS
   Cards, Tables, Badges, Buttons, Forms, Toasts, Modals, Skeletons
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. KPI METRIC CARDS
   -------------------------------------------------------------------------- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-card {
    background: var(--surface-bg);
    padding: 18px;
    border-radius: var(--radius-box);
    box-shadow: var(--shadow-v3);
    border: 0;
    transition: transform var(--transition-fast);
}

.metric-card:hover {
    transform: translateY(-1px);
}

.metric-title {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.metric-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin: 4px 0;
    line-height: 1.2;
}

.metric-trend {
    font-size: 11px;
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-trend.up { color: var(--accent-green); }
.metric-trend.down { color: var(--accent-red); }
.metric-trend.neutral { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   2. PANEL CARDS
   -------------------------------------------------------------------------- */
.panel-card {
    background: var(--surface-bg);
    border-radius: var(--radius-box);
    box-shadow: var(--shadow-v3);
    overflow: visible;
    border: 0;
    position: relative;
}

.panel-card:has(.filter-bar),
.panel-filter-card {
    overflow: visible !important;
    position: relative;
    z-index: 30;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline);
    gap: 12px;
    flex-wrap: wrap;
}

.panel-header h2 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.panel-header h2 i {
    color: var(--accent-cyan);
    font-size: 14px;
}

.panel-body {
    padding: 20px;
}

.panel-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --------------------------------------------------------------------------
   3. DATA TABLES
   -------------------------------------------------------------------------- */
.data-table-container {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th {
    background: var(--surface-deep);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline);
    white-space: nowrap;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--hairline);
    color: #cbd5e1;
    font-size: 13px;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--surface-card);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
}

.data-table-empty i {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* --------------------------------------------------------------------------
   4. BADGES
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-btn);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border: 0;
}

.badge-success { background: #064e3b; color: #34d399; }
.badge-warning { background: #78350f; color: #fbbf24; }
.badge-danger  { background: #7f1d1d; color: #fca5a5; }
.badge-info    { background: #0c4a6e; color: #7dd3fc; }
.badge-neutral { background: var(--surface-card); color: var(--text-secondary); }

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-btn);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 0;
    transition: all var(--transition-base);
    white-space: nowrap;
    user-select: none;
    line-height: 1.4;
}

.btn:active {
    transform: translateY(1px);
}

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

/* Primary */
.btn-primary {
    background: var(--accent-blue);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-blue-hover);
}

/* Success */
.btn-success {
    background: var(--accent-green-dark);
    color: #fff;
}
.btn-success:hover:not(:disabled) {
    background: #166534;
}

/* Danger */
.btn-danger {
    background: var(--accent-red-dark);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: #991b1b;
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-card);
    color: #fff;
}

/* Size Variants */
.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

/* --------------------------------------------------------------------------
   6. FORM INPUTS
   -------------------------------------------------------------------------- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.form-input {
    background: var(--surface-card);
    border: 0;
    padding: 10px 14px;
    border-radius: var(--radius-btn);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 13px;
    outline: none;
    transition: box-shadow var(--transition-base);
    width: 100%;
}

.form-input:focus {
    box-shadow: var(--focus-ring);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-textarea {
    background: var(--surface-card);
    border: 0;
    padding: 10px 14px;
    border-radius: var(--radius-btn);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    transition: box-shadow var(--transition-base);
    resize: vertical;
    min-height: 100px;
    width: 100%;
    line-height: 1.6;
}

.form-textarea:focus {
    box-shadow: var(--focus-ring);
}

.form-textarea::placeholder {
    color: var(--text-muted);
    font-family: var(--font-main);
}

.form-input-search {
    background: var(--surface-card);
    border: 0;
    padding: 8px 12px;
    border-radius: var(--radius-btn);
    color: #fff;
    font-size: 12px;
    outline: none;
    transition: box-shadow var(--transition-base);
    min-width: 180px;
}

.form-input-search:focus {
    box-shadow: var(--focus-ring);
}

.form-select {
    background: var(--surface-card);
    border: 0;
    padding: 10px 14px;
    border-radius: var(--radius-btn);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    width: 100%;
    transition: box-shadow var(--transition-base);
}

.form-select:focus {
    box-shadow: var(--focus-ring);
}

.form-select option {
    background-color: var(--surface-bg, #0f172a);
    color: var(--text-primary, #f8fafc);
    padding: 8px 12px;
}

/* ==========================================================================
   ANTI-GRAVITY UNIVERSAL CUSTOM DROPDOWN (v3.2 Spec)
   Zero-border, tactile mechanical feedback, 180deg chevron, .select-check
   ========================================================================== */
.ag-dropdown {
    position: relative;
    width: 100%;
    user-select: none;
}

.ag-dropdown.is-open,
.ag-dropdown:has(.ag-dropdown-trigger.open) {
    z-index: 1050;
}

.ag-dropdown.compact {
    max-width: 200px;
}

.ag-dropdown-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface-card, #1e293b);
    color: var(--text-primary, #e2e8f0);
    padding: 10px 14px;
    border-radius: var(--radius-btn, 6px);
    border: 0 !important;
    box-shadow: var(--shadow-v3);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-base);
}

.ag-dropdown.compact .ag-dropdown-trigger {
    padding: 8px 12px;
    font-size: 12px;
}

.ag-dropdown-trigger:hover {
    background: var(--surface-hover, #334155);
}

.ag-dropdown-trigger:active {
    transform: translateY(1px);
}

.ag-dropdown-trigger-label {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.ag-dropdown-trigger-icon {
    font-size: 12px;
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.ag-dropdown-chevron {
    font-size: 11px;
    color: var(--text-muted);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    margin-left: 6px;
}

.ag-dropdown-trigger.open .ag-dropdown-chevron {
    transform: rotate(180deg);
    color: var(--accent-cyan);
}

.ag-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(340px, 92vw);
    background: var(--surface-bg, #0f172a);
    box-shadow: var(--shadow-v3-dropdown);
    border-radius: var(--radius-box, 6px);
    z-index: 1060;
    padding: 6px;
    display: none;
    max-height: 280px;
    overflow-y: auto;
    border: 0 !important;
}

.ag-dropdown.menu-right .ag-dropdown-menu,
.ag-dropdown-menu.menu-right {
    left: auto !important;
    right: 0 !important;
}

.ag-dropdown-menu.dropup,
.ag-dropdown.dropup .ag-dropdown-menu {
    top: auto;
    bottom: calc(100% + 6px);
}

.ag-dropdown-menu.show {
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: fadeIn 0.15s ease-out;
}

.ag-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-btn, 6px);
    color: var(--text-secondary, #94a3b8);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ag-dropdown-item:hover {
    background: var(--surface-hover, #334155);
    color: #fff;
}

.ag-dropdown-item.active {
    background: var(--surface-hover, #334155);
    color: var(--accent-cyan, #38bdf8);
    font-weight: 600;
}

.ag-dropdown-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ag-dropdown-item-icon {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.ag-dropdown-item.active .ag-dropdown-item-icon {
    color: var(--accent-cyan);
}

.ag-dropdown-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ag-dropdown-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-card);
    color: var(--text-muted);
}

.select-check {
    display: none;
    font-size: 11px;
    color: var(--accent-cyan);
}

.select-check.visible {
    display: inline-block;
}

/* Range Slider */
.form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--surface-card);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-cyan);
    border-radius: var(--radius-btn);
    cursor: pointer;
    border: 0;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.4);
}

.form-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-cyan);
    border-radius: var(--radius-btn);
    cursor: pointer;
    border: 0;
}

.form-hint {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-card);
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: background var(--transition-base);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: var(--text-muted);
    border-radius: 3px;
    transition: all var(--transition-base);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: #fff;
}

/* --------------------------------------------------------------------------
   7. TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--surface-bg);
    box-shadow: var(--shadow-v3-modal);
    border-radius: var(--radius-box);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-main);
    font-size: 13px;
    min-width: 280px;
    max-width: 420px;
    color: var(--text-primary);
    animation: slide-in-right 0.3s ease;
    pointer-events: all;
    border-left: 3px solid var(--text-muted);
}

.toast.toast-removing {
    animation: slide-out-right 0.3s ease forwards;
}

.toast-success { border-left-color: var(--accent-green); }
.toast-error   { border-left-color: var(--accent-red); }
.toast-info    { border-left-color: var(--accent-cyan); }
.toast-warning { border-left-color: var(--accent-amber); }

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--accent-green); }
.toast-error .toast-icon   { color: var(--accent-red); }
.toast-info .toast-icon    { color: var(--accent-cyan); }
.toast-warning .toast-icon { color: var(--accent-amber); }

.toast-message {
    flex: 1;
    min-width: 0;
}

.toast-close {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 4px;
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: #fff;
}

@media (max-width: 480px) {
    .toast-container {
        bottom: 70px;
        right: 12px;
        left: 12px;
    }
    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* --------------------------------------------------------------------------
   8. MODALS
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.2s ease;
    padding: 16px;
}

.modal-backdrop.modal-removing {
    animation: fade-out 0.2s ease forwards;
}

.modal-dialog {
    background: var(--surface-bg);
    border-radius: var(--radius-box);
    box-shadow: var(--shadow-v3-modal);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    border: 0;
    display: flex;
    flex-direction: column;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: var(--surface-card);
    border: 0;
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.modal-close:hover {
    color: #fff;
    background: var(--surface-hover);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .form-group + .form-group {
    margin-top: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--hairline);
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   9. SKELETON LOADERS
   -------------------------------------------------------------------------- */
.skeleton {
    background: var(--surface-card);
    border-radius: var(--radius-btn);
    overflow: hidden;
    position: relative;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-text {
    height: 14px;
    width: 60%;
    margin-bottom: 8px;
}

.skeleton-text-sm {
    height: 10px;
    width: 40%;
}

.skeleton-text-full {
    height: 14px;
    width: 100%;
    margin-bottom: 8px;
}

.skeleton-box {
    height: 80px;
    width: 100%;
}

.skeleton-metric {
    height: 100px;
    width: 100%;
    border-radius: var(--radius-box);
}

.skeleton-row {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--hairline);
}

.skeleton-cell {
    height: 14px;
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   10. PAGINATION
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}

.pagination-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-btn);
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover {
    background: var(--surface-card);
    color: #fff;
}

.pagination-btn.active {
    background: var(--accent-blue);
    color: #fff;
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-info {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 8px;
}

/* --------------------------------------------------------------------------
   11. INFO BANNER
   -------------------------------------------------------------------------- */
.info-banner {
    background: var(--surface-card);
    border-radius: var(--radius-box);
    padding: 14px 18px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 0;
    border-left: 3px solid var(--accent-cyan);
}

.info-banner i {
    color: var(--accent-cyan);
    font-size: 14px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   12. FILTER BAR
   -------------------------------------------------------------------------- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    z-index: 30;
    overflow: visible;
}

.filter-bar .form-input-search {
    flex: 1;
    min-width: 200px;
}

/* --------------------------------------------------------------------------
   13. TAB BAR
   -------------------------------------------------------------------------- */
.tab-bar {
    display: flex;
    gap: 2px;
    background: var(--surface-deep);
    padding: 4px;
    border-radius: var(--radius-box);
    overflow-x: auto;
}

.tab-btn {
    padding: 7px 14px;
    border-radius: var(--radius-btn);
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    background: var(--surface-card);
    color: var(--accent-cyan);
    box-shadow: var(--shadow-v3);
}

/* --------------------------------------------------------------------------
   14. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    max-width: 360px;
    margin: 0 auto 20px;
    line-height: 1.6;
}
