/**
 * Vet AI Credit Manager — Styles
 * File: assets/css/vai-credit.css
 * Works for both WP Admin panel and front-end shortcode
 */

/* ================================================================
   RESET & BASE
================================================================ */
.vai-wrap * {
    box-sizing: border-box;
}
.vai-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
    max-width: 1400px;
}
.vai-wrap.vai-frontend {
    max-width: 100%;
    padding: 0 4px;
}

/* ================================================================
   HEADER
================================================================ */
.vai-admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 14px;
    padding: 22px 28px;
    margin-bottom: 24px;
    color: #fff;
    flex-wrap: wrap;
    gap: 16px;
}
.vai-admin-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.vai-logo {
    font-size: 36px;
    line-height: 1;
}
.vai-admin-header h1,
.vai-admin-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}
.vai-admin-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.85;
    color: #fff;
}

/* ================================================================
   STATS BAR
================================================================ */
.vai-stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.vai-stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 18px 22px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    text-align: center;
    transition: transform 0.15s, box-shadow 0.15s;
}
.vai-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.vai-stat-card.vai-stat-highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}
.vai-stat-card.vai-stat-highlight .vai-stat-value,
.vai-stat-card.vai-stat-highlight .vai-stat-label {
    color: #fff;
}
.vai-stat-value {
    font-size: 26px;
    font-weight: 800;
    color: #4c1d95;
    line-height: 1.1;
}
.vai-stat-label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    font-weight: 500;
}

/* ================================================================
   CREDIT PROGRESS BAR
================================================================ */
.vai-credit-bar-wrap {
    background: #fff;
    border-radius: 12px;
    padding: 18px 24px;
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.vai-credit-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 10px;
}
.vai-credit-bar-bg {
    background: #f3f4f6;
    border-radius: 999px;
    height: 14px;
    overflow: hidden;
}
.vai-credit-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s ease;
}
.vai-credit-bar-fill.ok      { background: linear-gradient(90deg, #34d399, #059669); }
.vai-credit-bar-fill.warning { background: linear-gradient(90deg, #fbbf24, #d97706); }
.vai-credit-bar-fill.danger  { background: linear-gradient(90deg, #f87171, #dc2626); }

/* ================================================================
   PANELS
================================================================ */
.vai-panel {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 24px;
    overflow: hidden;
}
.vai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    flex-wrap: wrap;
    gap: 12px;
}
.vai-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
}

/* ================================================================
   FORM PANEL
================================================================ */
.vai-form-panel {
    background: #fff;
    border-radius: 14px;
    border: 2px solid #c4b5fd;
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(102,126,234,0.12);
}
.vai-form-panel h3 {
    margin: 0 0 20px;
    font-size: 16px;
    font-weight: 700;
    color: #4c1d95;
}
.vai-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.vai-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vai-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}
.vai-form-group .req {
    color: #dc2626;
}
.vai-form-group input,
.vai-form-group select {
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
    width: 100%;
}
.vai-form-group input:focus,
.vai-form-group select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(118,75,162,0.12);
}
.vai-form-group small {
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.4;
}
.vai-key-wrap {
    display: flex;
    gap: 8px;
}
.vai-key-wrap input {
    flex: 1;
}
.vai-toggle-key {
    background: #f3f4f6;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 0 10px;
    cursor: pointer;
    font-size: 16px;
    color: #6b7280;
    transition: background 0.15s;
    flex-shrink: 0;
}
.vai-toggle-key:hover {
    background: #e5e7eb;
}
.vai-form-actions {
    display: flex;
    gap: 10px;
}

/* ================================================================
   BUTTONS
================================================================ */
.vai-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}
.vai-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}
.vai-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.vai-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff !important;
}
.vai-btn-secondary {
    background: #f3f4f6;
    color: #374151 !important;
    border: 1px solid #e5e7eb;
}
.vai-btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}
.vai-btn-danger {
    background: #fef2f2;
    color: #dc2626 !important;
    border: 1px solid #fecaca;
}
.vai-btn-danger:hover:not(:disabled) {
    background: #fee2e2;
}
.vai-btn-warning {
    background: #fffbeb;
    color: #d97706 !important;
    border: 1px solid #fde68a;
}
.vai-btn-warning:hover:not(:disabled) {
    background: #fef3c7;
}
.vai-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
}

/* ================================================================
   FILTERS ROW
================================================================ */
.vai-log-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.vai-log-filters select,
.vai-log-filters input[type="date"] {
    padding: 6px 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
    background: #fff;
}
.vai-log-filters select:focus,
.vai-log-filters input:focus {
    outline: none;
    border-color: #764ba2;
}
.vai-search-input {
    padding: 7px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
    min-width: 200px;
}
.vai-search-input:focus {
    outline: none;
    border-color: #764ba2;
}

/* ================================================================
   TABLES
================================================================ */
.vai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.vai-table th {
    background: #f9fafb;
    padding: 11px 16px;
    text-align: left;
    font-weight: 700;
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.vai-table td {
    padding: 11px 16px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #374151;
}
.vai-table tr:last-child td {
    border-bottom: none;
}
.vai-table tr:hover td {
    background: #faf5ff;
}
.vai-table code {
    background: #f3f4f6;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    color: #4c1d95;
}
.vai-key-mask {
    color: #9ca3af !important;
    letter-spacing: 1px;
}
.vai-action-btns {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    align-items: center;
}
.vai-preview-cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #9ca3af;
    font-style: italic;
    font-size: 12px;
    cursor: help;
}
.vai-log-table th,
.vai-log-table td {
    padding: 9px 14px;
}

/* ================================================================
   ROLE BADGE
================================================================ */
.vai-role-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: #ede9fe;
    color: #5b21b6;
    white-space: nowrap;
}

/* ================================================================
   MINI PROGRESS BAR (in directors table)
================================================================ */
.vai-mini-bar {
    margin-top: 5px;
    height: 5px;
    background: #f3f4f6;
    border-radius: 999px;
    overflow: hidden;
    max-width: 100px;
}
.vai-mini-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}
.vai-mini-fill.ok      { background: #34d399; }
.vai-mini-fill.warning { background: #fbbf24; }
.vai-mini-fill.danger  { background: #f87171; }

/* ================================================================
   LOADING & EMPTY
================================================================ */
.vai-loading-msg {
    text-align: center;
    padding: 32px 20px;
    color: #9ca3af;
    font-size: 14px;
}
.vai-loading-msg::before {
    content: '⏳ ';
}
.vai-empty-msg {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
}
.vai-empty-msg::before {
    content: '📭 ';
}

/* ================================================================
   PAGINATION
================================================================ */
.vai-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    flex-wrap: wrap;
}
.vai-page-btn {
    padding: 6px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}
.vai-page-btn:hover:not(:disabled):not(.active) {
    border-color: #764ba2;
    color: #764ba2;
}
.vai-page-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
    cursor: default;
}
.vai-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ================================================================
   TOAST NOTIFICATION
================================================================ */
.vai-toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 999999;
    padding: 13px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    max-width: 380px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    animation: vaiSlideUp 0.25s ease;
}
@keyframes vaiSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.vai-toast-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.vai-toast-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.vai-toast-info    { background: #ede9fe; color: #4c1d95; border: 1px solid #c4b5fd; }

/* ================================================================
   ERROR BOX
================================================================ */
.vai-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 14px;
}

/* ================================================================
   MISC
================================================================ */
.vai-muted {
    color: #9ca3af;
}

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 768px) {
    .vai-admin-header {
        padding: 18px 18px;
    }
    .vai-admin-header h1,
    .vai-admin-header h2 {
        font-size: 18px;
    }
    .vai-panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .vai-log-filters {
        width: 100%;
    }
    .vai-log-filters select,
    .vai-log-filters input {
        flex: 1;
        min-width: 0;
    }
    .vai-table th:nth-child(5),
    .vai-table td:nth-child(5),
    .vai-table th:nth-child(6),
    .vai-table td:nth-child(6) {
        display: none;
    }
    .vai-form-grid {
        grid-template-columns: 1fr;
    }
    .vai-action-btns {
        flex-direction: column;
        align-items: flex-start;
    }
    .vai-toast {
        bottom: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .vai-stats-bar {
        grid-template-columns: 1fr 1fr;
    }
    .vai-stat-value {
        font-size: 20px;
    }
}

/* ================================================================
   ADVANCED FRONTEND ADDITIONS
================================================================ */

/* Stat icon inside card */
.vai-stat-card .vai-stat-icon {
    font-size: 20px;
    margin-bottom: 6px;
    display: block;
}

/* Danger variant for remaining card */
.vai-stat-card.vai-stat-danger {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fca5a5;
}
.vai-stat-card.vai-stat-danger .vai-stat-value { color: #dc2626; }
.vai-stat-card.vai-stat-danger .vai-stat-label { color: #ef4444; }

/* Credit bar sub-label */
.vai-credit-bar-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
    text-align: right;
}

/* Two-column panel row */
.vai-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
@media (max-width: 900px) {
    .vai-two-col { grid-template-columns: 1fr; }
}

/* Panel hint text */
.vai-panel-hint {
    font-size: 12px;
    color: #9ca3af;
    font-style: italic;
}

/* Breakdown table */
.vai-breakdown-table th,
.vai-breakdown-table td {
    padding: 10px 14px;
}
.vai-row-alt td { background: #faf5ff; }

/* Chart container */
.vai-chart-wrap {
    padding: 16px 20px 20px;
    position: relative;
    height: 220px;
}
.vai-chart-wrap canvas {
    width: 100% !important;
}

/* Preview button */
.vai-btn-preview {
    background: #ede9fe !important;
    color: #5b21b6 !important;
    border: 1px solid #c4b5fd !important;
}
.vai-btn-preview:hover:not(:disabled) {
    background: #ddd6fe !important;
}

/* Preview modal */
.vai-preview-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.vai-preview-modal {
    background: #fff;
    border-radius: 14px;
    max-width: 680px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: vaiSlideUp 0.25s ease;
}
.vai-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.vai-preview-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}
.vai-preview-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}
.vai-preview-close:hover { background: rgba(255,255,255,0.35); }
.vai-preview-body {
    padding: 22px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.75;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Pagination info text */
.vai-page-info {
    font-size: 12px;
    color: #9ca3af;
    margin-left: 8px;
    align-self: center;
}

/* Frontend toast positioned inside wrapper */
.vai-frontend #vai-fe-toast.vai-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
}