/**
 * Audit Trail CSS
 * Styling for the inventory audit trail interface
 */

/* Main Container */
.audit-trail-container {
    width: 100%;
    max-width: none;
    padding: 20px;
    background: #f8fafc;
    min-height: 500px;
    box-sizing: border-box;
}

/* Filters Section */
.audit-filters {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    margin-bottom: 15px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    flex: 1;
}

.filter-group label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
    font-size: 14px;
}

.filter-select,
.filter-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: end;
    margin-left: auto;
}

.filter-actions .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

/* Statistics Section */
.audit-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 5px;
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

.stat-note {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    font-style: italic;
    line-height: 1.2;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator span {
    color: #6b7280;
    font-size: 16px;
}

/* Timeline Section */
.audit-timeline {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    max-height: 600px;
    overflow-y: auto;
}

/* Stock Movement Table Styles */
.audit-timeline {
    padding: 0;
    max-height: none;
    overflow: visible;
}

.audit-timeline table {
    font-size: 14px;
}

.audit-timeline th {
    font-weight: 600;
    background-color: #f9fafb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.audit-timeline td {
    vertical-align: top;
}

.audit-timeline tr:hover {
    background-color: #f8fafc;
}

/* Stock level indicators */
.stock-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.stock-level.low {
    background-color: #fef2f2;
    color: #dc2626;
}

.stock-level.medium {
    background-color: #fefce8;
    color: #ca8a04;
}

.stock-level.high {
    background-color: #f0fdf4;
    color: #16a34a;
}

/* Transaction type badges in table */
.audit-timeline .type-badge {
    font-size: 11px;
    padding: 3px 8px;
}

/* Responsive table */
@media (max-width: 1024px) {
    .audit-timeline {
        overflow-x: auto;
    }
    
    .audit-timeline table {
        min-width: 800px;
    }
}

@media (max-width: 768px) {
    .audit-timeline table {
        font-size: 12px;
    }
    
    .audit-timeline th,
    .audit-timeline td {
        padding: 8px 6px;
    }
}

.timeline-item {
    display: flex;
    position: relative;
    padding: 15px 0;
    border-bottom: 1px solid #f3f4f6;
}

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

.timeline-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    margin-right: 15px;
    margin-top: 5px;
    flex-shrink: 0;
    position: relative;
}

.timeline-item.sale .timeline-marker {
    background: #ef4444;
}

.timeline-item.transfer .timeline-marker {
    background: #10b981;
}

.timeline-item.adjustment .timeline-marker {
    background: #f59e0b;
}

.timeline-item.return .timeline-marker {
    background: #8b5cf6;
}

.timeline-item.restock .timeline-marker {
    background: #06b6d4;
}

.timeline-content {
    flex: 1;
    min-width: 0;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.transaction-type {
    font-weight: 600;
    color: #1f2937;
    font-size: 16px;
}

.transaction-time {
    color: #6b7280;
    font-size: 14px;
    white-space: nowrap;
}

.timeline-body {
    color: #4b5563;
}

.transaction-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.detail-item {
    font-size: 14px;
    line-height: 1.4;
}

.detail-item strong {
    color: #374151;
    font-weight: 600;
}

.quantity.positive {
    color: #10b981;
    font-weight: 600;
}

.quantity.negative {
    color: #ef4444;
    font-weight: 600;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    color: #1f2937;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-state p {
    color: #6b7280;
    font-size: 16px;
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .audit-trail-container {
        padding: 15px;
    }
    
    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        min-width: auto;
    }
    
    .filter-actions {
        margin-left: 0;
        justify-content: stretch;
    }
    
    .filter-actions .btn {
        flex: 1;
    }
    
    .audit-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .transaction-details {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .audit-stats {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .audit-timeline {
        padding: 15px;
    }
    
    .timeline-item {
        padding: 12px 0;
    }
    
    .timeline-marker {
        width: 10px;
        height: 10px;
        margin-right: 12px;
    }
}

/* Audit Trail Styles for POS Admin Dashboard */

/* Filter Information Banner Styles */
.filter-info-banner {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filter-info-banner i {
    color: #6b7280;
    font-size: 16px;
}

.filter-info-banner small {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-top: 2px;
}

/* Audit Trail Specific Styles */
.audit-card {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.audit-card:hover {
    border-left-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.audit-card.sale {
    border-left-color: #ef4444;
}

.audit-card.transfer {
    border-left-color: #10b981;
}

.audit-card.adjustment {
    border-left-color: #f59e0b;
}

/* Timeline Styles */
.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    left: -6px;
    top: 20px;
    border: 3px solid white;
    box-shadow: 0 0 0 1px #e5e7eb;
    z-index: 10;
}

.timeline-dot.sale {
    background-color: #ef4444;
}

.timeline-dot.transfer {
    background-color: #10b981;
}

.timeline-dot.adjustment {
    background-color: #f59e0b;
}

/* Timeline line */
.timeline-container {
    position: relative;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #e5e7eb 0%, #e5e7eb 100%);
    z-index: 1;
}

/* Stock Change Indicators */
.stock-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 14px;
}

.stock-increase {
    color: #10b981;
}

.stock-decrease {
    color: #ef4444;
}

.stock-change i {
    font-size: 12px;
}

/* Statistics Cards */
.stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value.positive {
    color: #10b981;
}

.stat-value.negative {
    color: #ef4444;
}

.stat-value.neutral {
    color: #3b82f6;
}

.stat-value.warning {
    color: #f59e0b;
}

/* Filter Controls */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.filter-label i {
    margin-right: 6px;
    color: #6b7280;
}

.filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: #374151;
    transition: all 0.2s ease;
}

.filter-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Current Stock Display */
.stock-display {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

.stock-number {
    font-size: 36px;
    font-weight: bold;
    color: #111827;
    text-align: center;
    margin-bottom: 8px;
}

.stock-label {
    font-size: 14px;
    color: #6b7280;
    text-align: center;
    margin-bottom: 16px;
}

.stock-alert {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
}

.stock-alert i {
    margin-right: 4px;
}

.stock-details {
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
    margin-top: 16px;
}

.stock-detail-row {
    display: flex;
    justify-content: between;
    align-items: center;
    padding: 4px 0;
    font-size: 14px;
}

.stock-detail-label {
    color: #6b7280;
}

.stock-detail-value {
    font-weight: 500;
    color: #111827;
}

/* Action Buttons */
.action-btn {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.action-btn.primary {
    background: #3b82f6;
    color: white;
}

.action-btn.primary:hover {
    background: #2563eb;
}

.action-btn.success {
    background: #10b981;
    color: white;
}

.action-btn.success:hover {
    background: #059669;
}

.action-btn.warning {
    background: #f59e0b;
    color: white;
}

.action-btn.warning:hover {
    background: #d97706;
}

.action-btn.secondary {
    background: #6b7280;
    color: white;
}

.action-btn.secondary:hover {
    background: #4b5563;
}

/* Loading States */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #d1d5db;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: #6b7280;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    background: #f9fafb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-placeholder {
    text-align: center;
    color: #6b7280;
}

.chart-placeholder i {
    font-size: 32px;
    margin-bottom: 12px;
    color: #d1d5db;
}

/* Transaction Type Badges */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.type-badge.sale {
    background: #fef2f2;
    color: #dc2626;
}

.type-badge.transfer {
    background: #f0fdf4;
    color: #16a34a;
}

.type-badge.adjustment {
    background: #fefce8;
    color: #ca8a04;
}

/* Responsive Design */
@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .audit-card {
        padding: 12px;
    }
    
    .audit-card .grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stock-number {
        font-size: 28px;
    }
    
    .timeline-dot {
        left: -4px;
        width: 8px;
        height: 8px;
    }
    
    .relative.pl-14 {
        padding-left: 2rem;
    }
}

@media (max-width: 640px) {
    .filter-info-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .filter-info-banner button {
        margin-left: 0;
        align-self: flex-end;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .action-btn {
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* Print Styles */
@media print {
    .filter-info-banner,
    .action-btn,
    .chart-container {
        display: none;
    }
    
    .audit-card {
        border: 1px solid #000;
        margin-bottom: 12px;
        page-break-inside: avoid;
    }
    
    .timeline-dot {
        background: #000 !important;
    }
}

/* Accessibility */
.filter-select:focus,
.action-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .audit-card {
        border: 2px solid #000;
    }
    
    .timeline-dot {
        border: 3px solid #000;
    }
    
    .filter-info-banner {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .audit-card,
    .action-btn,
    .loading-spinner {
        transition: none;
        animation: none;
    }
    
    .audit-card:hover,
    .action-btn:hover {
        transform: none;
    }
}

/* Stock Management Sub-tabs */
.stock-sub-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    padding: 0 24px;
}

.stock-sub-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    color: #6b7280;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stock-sub-tab:hover {
    color: #374151;
    background: rgba(59, 130, 246, 0.05);
}

.stock-sub-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.stock-sub-content {
    padding: 24px;
}

.stock-sub-content.hidden {
    display: none;
}

/* Cashier Management Sub-tabs */
.cashier-sub-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    padding: 0 24px;
}

.cashier-sub-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    color: #6b7280;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cashier-sub-tab:hover {
    color: #374151;
    background: rgba(59, 130, 246, 0.05);
}

.cashier-sub-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.cashier-sub-content {
    padding: 24px;
}

.cashier-sub-content.hidden {
    display: none;
} 