/**
 * Kuiba XForm Agent Dashboard Styles
 * Mobile-first responsive design
 */

/* Container */
.kuiba-agent-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Header */
.kuiba-dashboard-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.kuiba-dashboard-header h2 {
    margin: 0 0 10px 0;
    color: #2271b1;
    font-size: 28px;
}

.kuiba-dashboard-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.stat-item {
    font-size: 14px;
    color: #666;
}

/* Factboxes */
.kuiba-dashboard-factboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.factbox {
    background: white;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #2271b1;
    border-radius: 6px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.factbox:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.factbox-icon {
    font-size: 28px;
    line-height: 1;
}

.factbox-content {
    flex: 1;
}

.factbox-value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    line-height: 1.2;
}

.factbox-label {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    font-weight: 500;
}

.factbox-sublabel {
    font-size: 11px;
    color: #2271b1;
    margin-top: 2px;
    font-weight: 600;
}

/* Filters */
.kuiba-dashboard-filters {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.kuiba-filters-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.kuiba-filters-form select,
.kuiba-filters-form input[type="search"] {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 150px;
}

.kuiba-filters-form input[type="search"] {
    flex: 1;
    min-width: 200px;
}

/* Buttons */
.kuiba-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.kuiba-btn-primary {
    background-color: #2271b1;
    color: white;
}

.kuiba-btn-primary:hover {
    background-color: #135e96;
}

.kuiba-btn-secondary {
    background-color: #f0f0f0;
    color: #333;
}

.kuiba-btn-secondary:hover {
    background-color: #ddd;
}

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

/* Entry Cards */
.kuiba-dashboard-entries {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kuiba-entry-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.2s ease;
}

.kuiba-entry-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kuiba-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.kuiba-card-customer {
    flex: 1;
}

.kuiba-card-customer strong {
    font-size: 16px;
    color: #333;
    display: block;
    margin-bottom: 5px;
}

.kuiba-card-customer a {
    color: #2271b1;
    text-decoration: none;
    font-size: 13px;
}

.kuiba-card-customer a:hover {
    text-decoration: underline;
}

.kuiba-status-badge {
    padding: 4px 12px;
    border-radius: 4px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.kuiba-card-body {
    margin-bottom: 15px;
}

.kuiba-card-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.kuiba-meta-item {
    font-size: 13px;
    color: #666;
}

.kuiba-meta-item strong {
    color: #333;
}

.kuiba-card-notes {
    margin-top: 12px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 13px;
}

.kuiba-card-notes strong {
    display: block;
    margin-bottom: 5px;
    color: #333;
}

.kuiba-card-notes p {
    margin: 0;
    color: #666;
    line-height: 1.5;
}

.kuiba-card-footer {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.kuiba-card-footer .kuiba-btn {
    flex: 1;
    text-align: center;
    padding: 8px 15px;
    font-size: 13px;
}

/* No Entries State */
.kuiba-no-entries {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.kuiba-no-entries p {
    font-size: 16px;
}

/* Error State */
.kuiba-dashboard-error {
    padding: 20px;
    background: #fce4e4;
    border: 1px solid #cc0000;
    border-radius: 4px;
    color: #cc0000;
}

/* Pagination */
.kuiba-dashboard-pagination {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.kuiba-dashboard-pagination .page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #2271b1;
    transition: all 0.2s ease;
}

.kuiba-dashboard-pagination .page-numbers:hover {
    background: #f0f0f0;
}

.kuiba-dashboard-pagination .page-numbers.current {
    background: #2271b1;
    color: white;
    border-color: #2271b1;
}

/* Modal */
.kuiba-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
}

.kuiba-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99999;
}

.kuiba-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 100000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.kuiba-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

.kuiba-modal-close:hover {
    color: #333;
}

.kuiba-modal-content h3 {
    margin: 0 0 20px 0;
    color: #2271b1;
}

/* Modal Form */
.kuiba-form-group {
    margin-bottom: 20px;
}

.kuiba-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.kuiba-form-group input[type="text"],
.kuiba-form-group input[type="number"],
.kuiba-form-group input[type="date"],
.kuiba-form-group select,
.kuiba-form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.kuiba-form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.kuiba-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* Entry Details */
.kuiba-entry-detail {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.kuiba-entry-detail:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.kuiba-entry-detail label {
    display: block;
    font-weight: 600;
    color: #666;
    font-size: 13px;
    margin-bottom: 5px;
}

.kuiba-entry-detail .value {
    color: #333;
    font-size: 14px;
}

/* Interest Badges */
.kuiba-interest-badge {
    display: inline-block;
    padding: 4px 12px;
    margin: 2px 4px 2px 0;
    background: #e0f2ff;
    border: 1px solid #b3d9ff;
    border-radius: 16px;
    color: #2271b1;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Toast Notifications */
.kuiba-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 100001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.kuiba-toast.success {
    border-left: 4px solid #00a32a;
}

.kuiba-toast.error {
    border-left: 4px solid #cc0000;
}

/* Loading State */
.kuiba-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.kuiba-loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .kuiba-agent-dashboard {
        padding: 15px;
    }

    .kuiba-dashboard-header h2 {
        font-size: 24px;
    }

    .kuiba-dashboard-factboxes {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }

    .factbox {
        padding: 12px;
    }

    .factbox-icon {
        font-size: 24px;
    }

    .factbox-value {
        font-size: 20px;
    }

    .kuiba-dashboard-entries {
        grid-template-columns: 1fr;
    }

    .kuiba-filters-form {
        flex-direction: column;
        align-items: stretch;
    }

    .kuiba-filters-form select,
    .kuiba-filters-form input[type="search"] {
        width: 100%;
    }

    .kuiba-modal-content {
        width: 95%;
        padding: 20px;
    }

    .kuiba-form-actions {
        flex-direction: column;
    }

    .kuiba-form-actions .kuiba-btn {
        width: 100%;
    }
}
