/**
 * Warehouse Stock Management - Custom Styles
 * Includes theme support, RTL adjustments, and utility classes.
 */

/* ============================================
   CSS Variables & Theme Support
   ============================================ */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
}

/* Light mode (default) */
[data-bs-theme="light"] {
    --body-bg: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --table-hover-bg: rgba(0, 0, 0, 0.02);
}

/* Dark mode */
[data-bs-theme="dark"] {
    --body-bg: #1a1d20;
    --card-bg: #212529;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --table-hover-bg: rgba(255, 255, 255, 0.02);
}

/* ============================================
   Base Styles
   ============================================ */

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--body-bg);
    transition: background-color 0.3s ease;
}

main {
    flex: 1 0 auto;
}

footer {
    flex-shrink: 0;
}

/* ============================================
   Navigation
   ============================================ */

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

.navbar-brand {
    font-weight: 600;
}

.nav-link {
    transition: opacity 0.2s ease;
}

.nav-link:hover {
    opacity: 0.8;
}

/* ============================================
   Cards & Components
   ============================================ */

.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

/* Stats cards on dashboard */
.card.bg-primary,
.card.bg-success,
.card.bg-info,
.card.bg-warning,
.card.bg-danger,
.card.bg-secondary {
    border: none;
}

/* ============================================
   Tables
   ============================================ */

.table {
    margin-bottom: 0;
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom-width: 2px;
}

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

/* Sticky table header */
.table-responsive .sticky-top {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ============================================
   Forms
   ============================================ */

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.375rem;
}

.form-text {
    font-size: 0.8125rem;
}

/* Form validation states */
.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--danger-color);
}

.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--success-color);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-group-sm > .btn {
    padding: 0.25rem 0.5rem;
}

/* ============================================
   Badges
   ============================================ */

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

/* ============================================
   Alerts
   ============================================ */

.alert {
    border-radius: 0.5rem;
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* ============================================
   Pagination
   ============================================ */

.pagination {
    margin-bottom: 0;
}

.page-link {
    border-radius: 0.25rem !important;
    margin: 0 0.125rem;
}

/* ============================================
   Theme Toggle Button
   ============================================ */

#themeToggle {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#themeToggle:hover {
    transform: scale(1.1);
}

#themeToggle:focus {
    box-shadow: none;
}

#themeIcon {
    font-size: 1.25rem;
}

/* ============================================
   RTL Support
   ============================================ */

[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .me-1,
[dir="rtl"] .me-2 {
    margin-right: 0 !important;
    margin-left: 0.25rem;
}

[dir="rtl"] .me-2 {
    margin-left: 0.5rem;
}

[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

[dir="rtl"] .ms-2 {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

[dir="rtl"] .text-end {
    text-align: left !important;
}

[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] .dropdown-menu-end {
    --bs-position: start;
}

[dir="rtl"] .btn-group > .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

[dir="rtl"] .btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

[dir="rtl"] .bi-arrow-right::before {
    content: "\f12f"; /* bi-arrow-left */
}

[dir="rtl"] .bi-arrow-left::before {
    content: "\f138"; /* bi-arrow-right */
}

/* ============================================
   Utility Classes
   ============================================ */

.cursor-pointer {
    cursor: pointer;
}

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

.opacity-hover {
    transition: opacity 0.2s ease;
}

.opacity-hover:hover {
    opacity: 0.75;
}

/* ============================================
   Loading States
   ============================================ */

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .table {
        font-size: 0.875rem;
    }

    .btn-group-sm > .btn {
        padding: 0.2rem 0.4rem;
    }

    h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .d-flex.gap-2 {
        flex-direction: column;
    }

    .d-flex.gap-2 > .btn,
    .d-flex.gap-2 > a {
        width: 100%;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .navbar,
    footer,
    .btn,
    .pagination,
    #themeToggle {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    body {
        background: white !important;
    }
}
