/* table-styles.css - Professional styling for Sales App table */

/* Container for the table */
.sales-table-container {
    width: 100%;
    height: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ag-Grid theme customizations */
.ag-theme-alpine {
    --ag-header-height: 40px;
    --ag-header-foreground-color: #333;
    --ag-header-background-color: #f5f5f5;
    --ag-header-cell-hover-background-color: #e8e8e8;
    --ag-odd-row-background-color: #fcfcfc;
    --ag-row-hover-color: #e7f3ff;
    --ag-selected-row-background-color: #cce7ff;
    --ag-range-selection-border-color: #0084ff;
    --ag-cell-horizontal-border: #e0e0e0;
    --ag-row-border-color: #e0e0e0;
    --ag-font-size: 13px;
    --ag-row-height: 35px;
}

/* Header styling */
.ag-theme-alpine .ag-header {
    border-bottom: 2px solid #ddd;
    background: linear-gradient(to bottom, #f8f8f8, #f0f0f0);
}

.ag-theme-alpine .ag-header-cell {
    font-weight: 600;
    color: #333;
    border-right: 1px solid #ddd;
}

.ag-theme-alpine .ag-header-cell:hover {
    background-color: #e8e8e8;
}

/* Row styling */
.ag-theme-alpine .ag-row {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.1s ease;
}

.ag-theme-alpine .ag-row:hover {
    background-color: #f0f7ff !important;
}

.ag-theme-alpine .ag-row-selected {
    background-color: #e3f2fd !important;
    border-color: #2196f3;
}

/* Cell styling */
.ag-theme-alpine .ag-cell {
    border-right: 1px solid #f0f0f0;
    padding: 6px 8px;
    line-height: 1.4;
}

.ag-theme-alpine .ag-cell:focus {
    border: 2px solid #2196f3 !important;
    outline: none;
    background-color: #f0f7ff;
}

/* Editing cell styling */
.ag-theme-alpine .ag-cell-edit-input {
    border: none;
    background: white;
    padding: 4px 6px;
    font-size: 13px;
    box-shadow: 0 0 0 2px #2196f3;
}

/* Selection range styling */
.ag-theme-alpine .ag-cell-range-selected {
    background-color: rgba(33, 150, 243, 0.1) !important;
}

.ag-theme-alpine .ag-cell-range-selected-1 {
    background-color: rgba(33, 150, 243, 0.2) !important;
}

/* Phone number cell specific styling */
.phone-cell {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px !important;
}

.phone-cell .phone-number {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.phone-cell .call-button {
    margin-left: 8px;
    padding: 2px 6px;
    border: 1px solid #28a745;
    background-color: #28a745;
    color: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.phone-cell .call-button:hover {
    background-color: #218838;
    transform: scale(1.05);
}

/* Empty cell styling */
.empty-cell {
    color: #999 !important;
    font-style: italic !important;
}

/* Scrollbar styling */
.ag-theme-alpine .ag-body-horizontal-scroll {
    height: 12px;
}

.ag-theme-alpine .ag-body-vertical-scroll {
    width: 12px;
}

.ag-theme-alpine .ag-scrollbar-thumb {
    background-color: #c0c0c0;
    border-radius: 6px;
}

.ag-theme-alpine .ag-scrollbar-thumb:hover {
    background-color: #a0a0a0;
}

/* Loading overlay */
.ag-theme-alpine .ag-overlay-loading-wrapper {
    background-color: rgba(255, 255, 255, 0.9);
}

.ag-theme-alpine .ag-overlay-loading-center {
    color: #666;
    font-size: 14px;
}

/* Context menu styling */
.ag-theme-alpine .ag-menu {
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: white;
}

.ag-theme-alpine .ag-menu-option {
    padding: 8px 12px;
    font-size: 13px;
    transition: background-color 0.1s ease;
}

.ag-theme-alpine .ag-menu-option:hover {
    background-color: #f5f5f5;
}

/* Filter panel styling */
.ag-theme-alpine .ag-filter {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ag-theme-alpine .ag-filter-header-container {
    background-color: #f8f8f8;
    border-bottom: 1px solid #ddd;
    padding: 8px 12px;
    font-weight: 600;
}

/* Selection checkbox styling */
.ag-theme-alpine .ag-checkbox-input-wrapper {
    width: 16px;
    height: 16px;
    border: 1px solid #ccc;
    border-radius: 2px;
}

.ag-theme-alpine .ag-checkbox-input-wrapper.ag-checked {
    background-color: #2196f3;
    border-color: #2196f3;
}

/* Resize handle styling */
.ag-theme-alpine .ag-header-cell-resize {
    width: 4px;
    background-color: transparent;
}

.ag-theme-alpine .ag-header-cell-resize:hover {
    background-color: #2196f3;
}

/* Sort icon styling */
.ag-theme-alpine .ag-header-icon {
    color: #666;
}

.ag-theme-alpine .ag-sort-ascending-icon,
.ag-theme-alpine .ag-sort-descending-icon {
    color: #2196f3;
}

/* Performance optimizations */
.sales-table-container * {
    box-sizing: border-box;
}

.ag-theme-alpine .ag-cell {
    contain: layout style;
}

/* Responsive behavior */
@media (max-width: 768px) {
    .ag-theme-alpine {
        --ag-font-size: 12px;
        --ag-row-height: 32px;
        --ag-header-height: 36px;
    }

    .ag-theme-alpine .ag-cell {
        padding: 4px 6px;
    }
}

/* High DPI support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .ag-theme-alpine .ag-header-cell,
    .ag-theme-alpine .ag-cell {
        border-width: 0.5px;
    }
}

/* Focus improvements for accessibility */
.ag-theme-alpine .ag-cell:focus,
.ag-theme-alpine .ag-header-cell:focus {
    outline: 2px solid #2196f3;
    outline-offset: -2px;
}

/* Print styles */
@media print {
    .sales-table-container {
        border: none;
        box-shadow: none;
    }

    .ag-theme-alpine .ag-cell,
    .ag-theme-alpine .ag-header-cell {
        border: 1px solid #000 !important;
        background: white !important;
    }
}

/* Animation for smooth interactions */
.ag-theme-alpine .ag-cell,
.ag-theme-alpine .ag-row {
    transition: background-color 0.1s ease, border-color 0.1s ease;
}

/* Custom scrollbar for better UX */
.ag-theme-alpine .ag-body-viewport::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.ag-theme-alpine .ag-body-viewport::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 6px;
}

.ag-theme-alpine .ag-body-viewport::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 6px;
}

.ag-theme-alpine .ag-body-viewport::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Error state styling */
.table-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #dc3545;
    font-size: 16px;
    font-weight: 500;
}

/* Loading state styling */
.table-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    font-size: 16px;
}

.table-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}