/**
 * Custom Styles for Fadak Channel Management
 */

/* Root Variables */
:root {
    --primary-color: #3B82F6;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --danger-color: #EF4444;
    --info-color: #6366F1;
    --dark-color: #1F2937;
    --light-color: #F3F4F6;
}

/* Body & Layout */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #F9FAFB;
    min-height: 100vh;
}

/* Navigation */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.nav-link {
    transition: all 0.3s ease;
}

.nav-link:hover {
    transform: translateY(-2px);
}

.nav-link.active {
    font-weight: 600;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.card-header {
    background-color: white;
    border-bottom: 2px solid var(--light-color);
    font-weight: 600;
}

/* Stats Cards */
.stat-card {
    padding: 1.5rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563EB 100%);
    color: white;
    text-align: center;
}

.stat-card.success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #D97706 100%);
}

.stat-card.danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #DC2626 100%);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Tables */
.table {
    background-color: white;
}

.table thead th {
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--dark-color);
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: var(--light-color);
}

/* Badges */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
}

/* Buttons */
.btn {
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.btn-icon {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Form Controls */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 0.2rem rgba(239, 68, 68, 0.25);
}

/* Search Bar */
.search-bar {
    position: relative;
}

.search-bar input {
    padding-left: 2.5rem;
}

.search-bar i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6B7280;
}

/* Filter Section */
.filter-section {
    background-color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.product-card {
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.2s;
}

.product-card:hover {
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transform: translateY(-4px);
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--light-color);
}

.product-info {
    padding: 1rem;
}

.product-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-price {
    font-size: 1.25rem;
    color: var(--primary-color);
    font-weight: 700;
}

.product-stock {
    font-size: 0.875rem;
    color: #6B7280;
}

.product-stock.low {
    color: var(--danger-color);
    font-weight: 600;
}

/* Channel Status Icons */
.channel-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.channel-icon {
    font-size: 1rem;
}

.channel-icon.connected {
    color: var(--success-color);
}

.channel-icon.disconnected {
    color: #9CA3AF;
}

/* Tooltip Enhancement */
.tooltip-icon {
    cursor: help;
    color: var(--info-color);
    margin-left: 0.25rem;
}

/* Loading States */
.skeleton-loader {
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-row {
    height: 60px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Toast Container */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* Bulk Actions Toolbar */
.bulk-actions-toolbar {
    position: sticky;
    top: 0;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 100;
    display: none;
}

.bulk-actions-toolbar.show {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Inline Order Details */
.order-details-inline {
    background-color: var(--light-color);
    padding: 1rem;
    border-left: 4px solid var(--primary-color);
    margin-top: 0.5rem;
}

.order-item {
    padding: 0.5rem;
    border-bottom: 1px solid #E5E7EB;
}

.order-item:last-child {
    border-bottom: none;
}

.inventory-warning {
    color: var(--danger-color);
    font-weight: 600;
}

/* Channel Health Bar */
.health-bar {
    height: 30px;
    background-color: #E5E7EB;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.health-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--primary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    transition: width 0.3s ease;
}

.health-error-badge {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--danger-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
}

/* Charts Container */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

/* Action Required Section */
.action-required-card {
    border-left: 4px solid var(--warning-color);
}

/* Low Stock Warning */
.low-stock-badge {
    background-color: var(--danger-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Checkbox in table */
.table input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* Hover Card (Popover style) */
.hover-card {
    position: absolute;
    background-color: white;
    border: 1px solid #E5E7EB;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    min-width: 200px;
    display: none;
}

.hover-card.show {
    display: block;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    #toastContainer {
        right: 10px;
        left: 10px;
        top: 10px;
    }
    
    .bulk-actions-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .navbar, .filter-section, .btn, .bulk-actions-toolbar {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Utility Classes */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sticky-top-custom {
    position: sticky;
    top: 70px;
    z-index: 50;
}
