/* Color Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --danger-color: #dc2626;
    --success-color: #16a34a;
    --background-gradient-start: #1e293b;
    --background-gradient-end: #0f172a;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Global Styles */
* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Login Page Styles */
.login-page {
    background: linear-gradient(135deg, var(--background-gradient-start) 0%, var(--background-gradient-end) 100%);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.login-card {
    border: none;
    border-radius: 16px;
    background: var(--card-background);
    transition: transform 0.3s ease;
}

.login-card:hover {
    transform: translateY(-2px);
}

/* Logo Styles */
.logo-container {
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3.5rem;
    color: var(--primary-color);
    display: block;
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.5rem;
    margin-bottom: 0;
    letter-spacing: -0.5px;
}

/* Form Styles */
.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    border: 2px solid var(--border-color);
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

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

/* Password Toggle Button */
.password-toggle {
    border: 2px solid var(--border-color);
    border-left: none;
    background: var(--card-background);
    color: var(--text-secondary);
    border-radius: 0 8px 8px 0;
    transition: all 0.3s ease;
}

.password-toggle:hover,
.password-toggle:focus {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Login page password input group */
.login-card .input-group .form-control {
    border-right: none;
    border-radius: 8px 0 0 8px;
}

.input-group:focus-within .form-control {
    border-color: var(--primary-color);
}

.input-group:focus-within .password-toggle {
    border-color: var(--primary-color);
}

/* Button Styles */
.btn-primary {
    background: var(--primary-color);
    border: none;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--secondary-color);
    opacity: 0.7;
}

/* Spinner Animation */
#loginBtn .btn-text {
    display: inline-block;
}

#loginBtn.loading .btn-text {
    display: none;
}

#loginBtn.loading #loginSpinner {
    display: inline-block !important;
}

/* Toast Container */
#toast-container {
    z-index: 9999;
    max-width: 350px;
}

.toast {
    border-radius: 8px;
    border: none;
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* Card Footer */
.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    padding: 1rem;
}

/* Dashboard Navbar */
.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.navbar-brand i {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.username-display {
    margin-right: 1rem;
    font-weight: 500;
}

.username-display i {
    margin-right: 0.5rem;
}

/* Dashboard Content */
.dashboard-content {
    padding: 2rem 0;
}

.welcome-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    margin-bottom: 2rem;
}

/* Responsive Design */
@media (max-width: 576px) {
    .logo-icon {
        font-size: 2.5rem;
    }

    .logo-text {
        font-size: 1.5rem;
    }

    .login-card {
        border-radius: 12px;
    }

    .card-body {
        padding: 2rem 1.5rem !important;
    }

    #toast-container {
        max-width: calc(100% - 2rem);
    }
}

/* Inventory table styles */
#inventoryTable {
  font-size: 0.9rem;
}

#inventoryTable th,
#inventoryTable td {
  vertical-align: middle;
}

/* Column filter row */
#inventoryTable thead tr.column-filters th {
  padding: 0.25rem 0.35rem;
  background-color: #f8f9fa;
}

#inventoryTable thead .column-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  height: auto;
  line-height: 1.3;
}

/* Selected row styling - ensure all elements remain readable */
#inventoryTable tbody tr.selected {
  background-color: #0d6efd !important;  /* Bootstrap primary blue */
}

#inventoryTable tbody tr.selected:hover {
  background-color: #0b5ed7 !important;  /* Slightly darker on hover */
}

#inventoryTable tbody tr.selected td {
  color: #ffffff !important;  /* White text for contrast */
}

/* Override text-muted on selected rows */
#inventoryTable tbody tr.selected td.text-muted,
#inventoryTable tbody tr.selected td .text-muted {
  color: rgba(255, 255, 255, 0.85) !important;
}

/* Override fw-bold styling for better visibility */
#inventoryTable tbody tr.selected td.fw-bold {
  color: #ffffff !important;
}

/* Override margin colors on selected rows */
#inventoryTable tbody tr.selected td .margin-positive,
#inventoryTable tbody tr.selected td .margin-negative {
  color: #ffffff !important;
}

/* Badges need contrasting styling when row is selected */
#inventoryTable tbody tr.selected .badge {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

/* Supplier badges */
.badge {
  font-weight: 500;
}

/* DataTables processing overlay */
div.dt-processing {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border-radius: 0.375rem;
  padding: 1rem;
}

/* Column visibility button */
.dt-buttons .btn {
  margin-right: 0.5rem;
}

/* Fix colVis button visibility - override DataTables default styles */
.dt-buttons .btn.btn-outline-secondary.colvis-btn,
.dt-buttons .btn.btn-outline-secondary.colvis-btn:not(:hover) {
  color: #6c757d !important;
  background-color: transparent !important;
  border-color: #6c757d !important;
}

.dt-buttons .btn.btn-outline-secondary.colvis-btn span,
.dt-buttons .btn.btn-outline-secondary.colvis-btn:not(:hover) span {
  color: #6c757d !important;
}

.dt-buttons .btn.btn-outline-secondary.colvis-btn:hover,
.dt-buttons .btn.btn-outline-secondary.colvis-btn:focus {
  color: #fff !important;
  background-color: #6c757d !important;
  border-color: #6c757d !important;
}

.dt-buttons .btn.btn-outline-secondary.colvis-btn:hover span,
.dt-buttons .btn.btn-outline-secondary.colvis-btn:focus span {
  color: #fff !important;
}

/* Fix colVis dropdown menu - DataTables 2.x with Bootstrap 5 */
.dt-button-collection.dropdown-menu {
  background-color: #fff !important;
  min-width: 120px !important;
}

.dt-button-collection .dropdown-item,
.dt-button-collection button.dt-button {
  display: block !important;
  width: 100% !important;
  padding: 0.4rem 1rem !important;
  font-size: 0.875rem !important;
  color: #212529 !important;
  background-color: transparent !important;
  border: none !important;
  text-align: left !important;
  cursor: pointer !important;
}

.dt-button-collection .dropdown-item:hover,
.dt-button-collection button.dt-button:hover {
  background-color: #e9ecef !important;
  color: #212529 !important;
}

.dt-button-collection .dropdown-item.active,
.dt-button-collection button.dt-button.active {
  background-color: #0d6efd !important;
  color: #fff !important;
}

/* Fallback for non-Bootstrap dropdown structure */
div.dt-button-collection {
  background-color: #fff !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 0.375rem !important;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
  padding: 0.5rem 0 !important;
}

div.dt-button-collection button.dt-button span {
  color: #212529 !important;
}

/* Price columns alignment */
.dt-end {
  text-align: right !important;
}

/* Inventory page layout */
.inventory-container {
  padding-top: 1rem;
  padding-bottom: 4rem;
}

/* Phase 3: EU Label Badge Styles */
/* EU badges inherit Bootstrap badge colors, but ensure consistent sizing */
#inventoryTable .badge {
    font-size: 0.85em;
    min-width: 1.5em;
}

/* Phase 3: Zero Stock Row Styling */
#inventoryTable tbody tr.zero-stock {
    opacity: 0.5;
}

#inventoryTable tbody tr.zero-stock td {
    color: #6c757d !important;  /* Bootstrap text-muted */
}

/* Zero-stock rows when selected - restore full opacity and use selected colors */
#inventoryTable tbody tr.zero-stock.selected {
    opacity: 1;
}

#inventoryTable tbody tr.zero-stock.selected td {
    color: #ffffff !important;
}

#inventoryTable tbody tr.zero-stock.selected td .text-muted {
    color: rgba(255, 255, 255, 0.85) !important;
}

/* Phase 3: In-Stock Toggle Button Active State */
#toggleInStock.active {
    /* Bootstrap .btn-primary styles applied via JS class toggle */
}

/* Phase 3: Margin Column */
#inventoryTable td .margin-positive {
    color: #198754;  /* Bootstrap success green */
}

#inventoryTable td .margin-negative {
    color: #dc3545;  /* Bootstrap danger red */
}

/* Phase 3: Column Reorder Visual Feedback */
.dt-colReorder-moving {
    outline: 2px solid var(--bs-primary);
}

/* Print Styles */
@media print {
    .navbar,
    .card-footer {
        display: none;
    }

    /* Quote Modal Print Styles */

    /* Hide everything except quote modal */
    body * {
        visibility: hidden;
    }

    #quoteModal,
    #quoteModal * {
        visibility: visible;
    }

    /* Reset modal positioning for print */
    #quoteModal {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0;
        padding: 0;
        overflow: visible !important;
    }

    #quoteModal .modal-dialog {
        max-width: 100%;
        margin: 0;
    }

    /* Hide modal chrome (backdrop, buttons) */
    .modal-backdrop {
        display: none !important;
    }

    #quoteModal .modal-header .btn-close,
    #quoteModal .modal-header .btn,
    #quoteModal .modal-footer {
        display: none !important;
    }

    /* Page setup for A4 paper */
    @page {
        margin: 1.5cm;
        size: A4 portrait;
    }

    /* Table row handling (prevent breaks) */
    #quoteModal table {
        page-break-inside: auto;
        width: 100%;
    }

    #quoteModal tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    #quoteModal thead {
        display: table-header-group;
    }

    /* Keep totals together */
    #quoteModal .quote-totals {
        page-break-inside: avoid;
    }

    /* Optimize typography for print */
    #quoteModal .modal-body {
        font-size: 11pt;
        line-height: 1.4;
    }
}

/* Phase 4: Basket Modal Styles */

/* Basket card styling */
.basket-card {
  transition: opacity 0.3s ease;
}

.basket-card .card-body {
  padding: 1rem;
}

.basket-card .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.basket-card .card-subtitle {
  font-size: 0.8rem;
  color: #6c757d;
}

.basket-card .line-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

.basket-card .stock-info {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Quantity controls */
.basket-card .qty-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.basket-card .qty-input {
  width: 50px;
  text-align: center;
  font-weight: 600;
}

.basket-card .qty-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Supplier dropdown */
.basket-card .supplier-select {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
}

/* Margin badge on card */
.basket-card .margin-badge {
  font-size: 0.7rem;
  padding: 0.2em 0.5em;
}

/* Remove button */
.basket-card .remove-btn {
  padding: 0.25rem 0.4rem;
}

/* Badge bounce animation */
@keyframes badgeBounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
  60% {
    transform: translateY(-3px);
  }
}

.badge-bounce {
  animation: badgeBounce 0.5s ease;
}

/* Fade out animation for removed cards */
.basket-card.removing {
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.3s ease;
}

/* Customer info section */
.customer-info-section {
  border: 1px solid #dee2e6;
}

.customer-info-section input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

/* Basket footer total */
.basket-footer-total {
  padding: 0.5rem 1rem;
  background-color: #f8f9fa;
  border-radius: 0.375rem;
}

/* Empty basket message */
#emptyBasketMessage {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Responsive adjustments for basket modal */
@media (max-width: 767.98px) {
  .basket-card .qty-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .basket-footer-total {
    order: -1;
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
  }

  .modal-footer .d-flex.justify-content-between {
    flex-direction: column;
    gap: 0.5rem;
  }

  #clearBasketBtn {
    width: 100%;
  }
}

/* Basket button with badge */
#openBasketBtn .badge {
  font-size: 0.7rem;
  vertical-align: middle;
  margin-left: 0.25rem;
}

#openBasketBtn:disabled .badge {
  background-color: #6c757d !important;
}
