/* H&S Inventory Management System - Custom Styles */

/* Root variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --gray-light: #f3f4f6;
    --gray-dark: #374151;
}

/* General Styles */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--gray-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Navigation Dropdown Enhancement */
.group:hover .group-hover\:opacity-100 {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Table Enhancements */
.table-hover tbody tr:hover {
    background-color: var(--gray-light);
    cursor: pointer;
}

table th.sortable {
    cursor: pointer;
    user-select: none;
}

table th.sortable:hover {
    background-color: #e5e7eb;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fed7aa;
    color: #92400e;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Form Enhancements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-error {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Card Components */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-dark);
}

/* Alert Messages */
.alert {
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fed7aa;
    color: #92400e;
    border: 1px solid #fdba74;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 0.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Dashboard Stats Cards */
.stat-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background-color: #dbeafe;
    color: #2563eb;
}

.stat-icon.green {
    background-color: #d1fae5;
    color: #10b981;
}

.stat-icon.yellow {
    background-color: #fed7aa;
    color: #f59e0b;
}

.stat-icon.red {
    background-color: #fee2e2;
    color: #ef4444;
}

/* Print Styles */
@media print {
    nav, footer, .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
    
    table {
        font-size: 10pt;
    }
    
    .page-break {
        page-break-after: always;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .hide-mobile {
        display: none;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .stat-card {
        margin-bottom: 1rem;
    }

    /* Improve action areas on phones */
    /* Stack primary form actions vertically with comfortable spacing */
    .form-actions-stacked,
    .form-actions,
    .actions,
    .btn-row,
    .flex.justify-between.items-center.pt-6.border-t-2.border-gray-200 {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    /* Ensure buttons/links within action rows are full width and touch friendly */
    .form-actions-stacked a,
    .form-actions-stacked button,
    .form-actions a,
    .form-actions button,
    .actions a,
    .actions button,
    .btn-row a,
    .btn-row button,
    .flex.justify-between.items-center.pt-6.border-t-2.border-gray-200 a,
    .flex.justify-between.items-center.pt-6.border-t-2.border-gray-200 button {
        width: 100% !important;
        display: inline-flex;
        justify-content: center;
        padding-top: 0.875rem !important;
        padding-bottom: 0.875rem !important;
        border-radius: 0.75rem !important;
        font-size: 1rem !important;
    }

    /* Reduce overly tight grids on phones */
    .grid {
        gap: 0.75rem !important;
    }

    /* Improve cards/panels inner padding for readability */
    .card,
    .rounded-xl,
    .rounded-lg,
    .p-8 { /* common big paddings in views */
        padding: 1rem !important;
    }

    /* Make quick actions wrap with proper spacing */
    .flex.flex-wrap.gap-3 {
        gap: 0.75rem !important;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Tooltips */
.tooltip {
    position: relative;
}

.tooltip .tooltip-text {
    visibility: hidden;
    background-color: #374151;
    color: white;
    text-align: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 0.875rem;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
}

/* Search Highlight */
.search-highlight {
    background-color: #fef3c7;
    padding: 0.125rem 0.25rem;
    border-radius: 0.125rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

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

/* Inventory Status Colors */
.inventory-status {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.inventory-status.in-stock {
    background-color: #d1fae5;
    color: #065f46;
}

.inventory-status.low-stock {
    background-color: #fed7aa;
    color: #92400e;
}

.inventory-status.out-of-stock {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Activity Log Terminal Style */
.log-terminal {
    background-color: #1a1a1a;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    min-height: 300px;
}

.log-entry {
    margin-bottom: 0.5rem;
    padding: 0.25rem;
}

.log-entry:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Barcode/QR Code Display */
.code-display {
    background-color: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    font-family: monospace;
}

.code-display i {
    font-size: 3rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

/* Navigation Active State */
.nav-active {
    background-color: rgba(37, 99, 235, 0.1);
    border-left: 3px solid var(--primary-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    bottom: auto !important;
    left: auto !important;
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    max-width: 400px !important;
    pointer-events: none !important;
}

.toast {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 16px 20px !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    background: white !important;
    min-width: 300px !important;
    max-width: 400px !important;
    animation: slideInRight 0.3s ease-out forwards !important;
    transition: all 0.3s ease !important;
    border-left: 4px solid !important;
    position: relative !important;
    pointer-events: auto !important;
    opacity: 1 !important;
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-out;
    opacity: 0;
    transform: translateX(100%);
}

.toast-success {
    border-left-color: var(--success-color);
    background: linear-gradient(to right, #d1fae5 0%, white 10%);
}

.toast-error {
    border-left-color: var(--danger-color);
    background: linear-gradient(to right, #fee2e2 0%, white 10%);
}

.toast-warning {
    border-left-color: var(--warning-color);
    background: linear-gradient(to right, #fed7aa 0%, white 10%);
}

.toast-info {
    border-left-color: var(--primary-color);
    background: linear-gradient(to right, #dbeafe 0%, white 10%);
}

.toast-icon {
    flex-shrink: 0 !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    margin-right: 12px !important;
}

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

.toast-error .toast-icon {
    color: var(--danger-color);
}

.toast-warning .toast-icon {
    color: var(--warning-color);
}

.toast-info .toast-icon {
    color: var(--primary-color);
}

.toast-content {
    flex: 1 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    color: var(--gray-dark) !important;
    word-wrap: break-word !important;
}

.toast-close {
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    color: #9ca3af !important;
    transition: color 0.2s !important;
    margin-left: 12px !important;
    font-size: 18px !important;
}

.toast-close:hover {
    color: var(--gray-dark);
}

.toast-progress {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    height: 3px !important;
    width: 100% !important;
    opacity: 0.3 !important;
    animation: progressBar 5s linear forwards !important;
    transform-origin: left !important;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes progressBar {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Mobile adjustments for toast */
@media (max-width: 768px) {
    .toast-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* Utility Classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shadow-hover:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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