/* client-list.component.scss */

/* Client grid layout - 8 COLUMNS: User ID, Name, Email, Contact, Status, Machine ID, Refillers, Details */
.client-grid {
    // Default: All 8 columns visible on XL screens
    grid-template-columns: 140px 2fr 2fr 1.5fr 1fr 1.5fr 1.5fr 80px;
    
    // Ensure all items are vertically centered
    > div {
        display: flex;
        align-items: center;
    }

    @media (max-width: 1279px) { // xl breakpoint - hide Machines and Refillers
        grid-template-columns: 140px 2fr 2fr 1.5fr 1fr 80px;
    }

    @media (max-width: 1023px) { // lg breakpoint - hide Status and Contact
        grid-template-columns: 140px 2fr 2fr 80px;
    }

    @media (max-width: 767px) { // md breakpoint - hide User ID
        grid-template-columns: 2fr 2fr 80px;
    }

    @media (max-width: 639px) { // sm breakpoint - hide Email
        grid-template-columns: 1fr 80px;
    }
}

/* Machine and Refiller columns - already centered by parent grid item */
.client-grid > div:nth-child(6),
.client-grid > div:nth-child(7) {
    /* Machine ID in monospace */
    .font-mono {
        font-family: 'Courier New', monospace;
    }
    
    /* Refiller names in medium weight */
    .font-medium {
        font-weight: 500;
    }
    
    /* For multiple items, use flex-col but still centered */
    > div {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
}

/* Material form field customizations */
.fuse-mat-dense {
    .mat-mdc-form-field-subscript-wrapper {
        display: none;
    }

    .mat-mdc-form-field-infix {
        min-height: 40px;
    }
}

.fuse-mat-rounded {
    .mat-mdc-form-field-flex {
        border-radius: 20px;
        background-color: rgba(0, 0, 0, 0.04);
        border: none;
    }

    &.mat-focused .mat-mdc-form-field-flex {
        background-color: rgba(0, 0, 0, 0.06);
    }
}

/* Icon size utilities */
.icon-size-5 {
    width: 20px;
    height: 20px;
    font-size: 20px;
}

.icon-size-4 {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

.icon-size-3 {
    width: 14px;
    height: 14px;
    font-size: 14px;
}

/* Avatar styles */
.client-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
}

/* Status badge styles */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    
    &.active,
    &.online {
        background-color: #dcfce7;
        color: #166534;
    }
    
    &.inactive,
    &.offline {
        background-color: #f3f4f6;
        color: #374151;
    }
    
    &.maintenance {
        background-color: #fef3c7;
        color: #92400e;
    }
}

/* Machine card styles */
.machine-card {
    background: #ffffff;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;

    &:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        border-color: #3b82f6;
    }
}

/* Refiller card styles */
.refiller-card {
    background: #f0fdf4;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #bbf7d0;
    transition: all 0.2s ease;

    &:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        border-color: #22c55e;
    }
}

/* Empty state styles */
.empty-state {
    text-align: center;
    padding: 32px;
    background-color: #f9fafb;
    border-radius: 8px;
    border: 2px dashed #d1d5db;

    mat-icon {
        font-size: 48px;
        width: 48px;
        height: 48px;
        color: #9ca3af;
        margin-bottom: 8px;
    }

    p {
        color: #6b7280;
        font-size: 14px;
        margin: 8px 0 0 0;
    }
}

/* Details panel */
.details-panel {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Section headers in details */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;

    h4 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #1f2937;
    }

    mat-icon {
        font-size: 20px;
        width: 20px;
        height: 20px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .machine-card {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;

        &:hover {
            border-color: #60a5fa;
        }
    }

    .refiller-card {
        background: #064e3b;
        border-color: #059669;
        color: #f0fdf4;

        &:hover {
            border-color: #10b981;
        }
    }

    .empty-state {
        background-color: #1f2937;
        border-color: #4b5563;

        p {
            color: #9ca3af;
        }
    }

    .details-panel {
        background: #1f2937;
        color: #f9fafb;
    }

    .section-header {
        border-bottom-color: #374151;

        h4 {
            color: #f9fafb;
        }
    }

    .fuse-mat-rounded .mat-mdc-form-field-flex {
        background-color: rgba(255, 255, 255, 0.06);
    }

    .fuse-mat-rounded.mat-focused .mat-mdc-form-field-flex {
        background-color: rgba(255, 255, 255, 0.08);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .client-grid {
        gap: 8px;
        padding: 12px 16px;
    }

    .machine-card,
    .refiller-card {
        padding: 12px;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.machine-card,
.refiller-card {
    animation: slideIn 0.3s ease-out;
}

/* Badge animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-badge span {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Hover effects */
.client-grid > div {
    transition: background-color 0.2s ease;
}

.client-grid > div:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Focus states for accessibility */
.mat-mdc-button:focus,
.mat-mdc-raised-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .status-badge {
        border: 2px solid currentColor;
    }
    
    .machine-card,
    .refiller-card {
        border-width: 2px;
    }
}

/* Print styles */
@media print {
    .mat-mdc-button,
    .mat-paginator,
    .search-input {
        display: none;
    }

    .details-panel {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Loading states */
.loading-overlay {
    position: relative;
    
    &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(255, 255, 255, 0.8);
        z-index: 10;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
    }

    &.loading::after {
        opacity: 1;
        pointer-events: all;
    }
}

/* Count badge special styles */
.count-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    
    mat-icon {
        font-size: 12px;
        width: 12px;
        height: 12px;
    }
}

/* Grid responsiveness helper */
@media (max-width: 1279px) {
    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}