/* Firearms Tracking System - Custom Styles */

/* Root Variables for Theme Support */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    /* Light theme variables */
    --bg-color: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-color: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.125);
}

/* Dark theme variables */
[data-bs-theme="dark"] {
    --bg-color: #212529;
    --bg-secondary: #343a40;
    --text-color: #ffffff;
    --text-muted: #adb5bd;
    --border-color: #495057;
    --shadow: rgba(255, 255, 255, 0.125);
}

/* Global Styles */
body {
    background-color: var(--bg-secondary);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* Navigation Enhancements */
.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    border-radius: 0.375rem;
    margin: 0 0.25rem;
    transition: all 0.2s ease-in-out;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.navbar-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

/* Card Enhancements */
.card {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem var(--shadow);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    background-color: var(--bg-color);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem var(--shadow);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    border-radius: 0.75rem 0.75rem 0 0 !important;
    font-weight: 500;
}

/* Button Enhancements */
.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

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

.btn-group .btn {
    transform: none;
}

.btn-group .btn:hover {
    transform: translateY(-1px);
}

/* Form Enhancements */
.form-control, .form-select {
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

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

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

/* Password Field Fixes - Prevent shrinking and maintain consistent appearance */
.form-control[type="password"],
.form-control[type="text"]#passwordField,
.form-control[type="text"]#confirmPasswordField {
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    letter-spacing: 0.05em;
    min-width: 250px;
}

/* Ensure input groups don't allow shrinking */
.input-group {
    display: flex;
    width: 100%;
}

.input-group .form-control {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

/* Force password fields to maintain width - critical fix */
.input-group .form-control[type="password"],
.input-group .form-control[type="text"] {
    flex-shrink: 0 !important;
    min-width: 250px !important;
}

/* Table Enhancements */
.table {
    color: var(--text-color);
}

.table th {
    border-top: none;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-color);
}

.table td {
    border-color: var(--border-color);
    vertical-align: middle;
}

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

/* Firearm list enhancements */
.firearm-notes {
    border-top: none !important;
    position: relative !important;
}

.firearm-notes td {
    padding-top: 0.25rem !important;
    padding-bottom: 0.75rem !important;
    background-color: rgba(108, 117, 125, 0.1) !important;
    border-bottom: 2px solid rgba(108, 117, 125, 0.2) !important;
}

/* Prevent checkbox column alignment issues */
th:first-child, td:first-child {
    width: 40px;
    text-align: center;
    vertical-align: middle;
}

/* Ensure notes don't hover when main row is hovered */
.table-hover tbody tr.firearm-notes:hover {
    background-color: rgba(108, 117, 125, 0.1) !important;
}

/* Prevent table reflow during checkbox operations */
.table.stable-layout {
    table-layout: fixed !important;
}

/* Keep firearm rows and notes grouped together */
.firearm-row + .firearm-notes {
    position: relative;
}

/* Ensure stable DOM structure */
tbody tr {
    transition: none !important;
}

/* Badge Enhancements */
.badge {
    font-size: 0.75em;
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.5em 0.75em;
}

/* Alert Enhancements */
.alert {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 0.125rem 0.25rem var(--shadow);
}

.alert-dismissible .btn-close {
    opacity: 0.7;
}

.alert-dismissible .btn-close:hover {
    opacity: 1;
}

/* Statistics Cards */
.stats-card {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    border: none;
}

.stats-card .card-body {
    padding: 1.5rem;
}

.stats-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
}

/* Mobile Responsive Enhancements */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .table-responsive {
        border: none;
    }
    
    .btn-group-sm .btn {
        padding: 0.25rem 0.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .navbar-nav {
        text-align: center;
    }
    
    .navbar-nav .nav-link {
        margin: 0.25rem 0;
    }
}

/* Dark/Light Theme Toggle */
.theme-toggle {
    position: relative;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 50px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background-color: rgba(255, 255, 255, 0.1);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading States */
.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State Styles */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Code/Serial Number Styling */
code {
    color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

/* Password Strength Indicator */
.password-strength {
    height: 4px;
    border-radius: 2px;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.password-strength.weak { background-color: var(--danger-color); width: 33%; }
.password-strength.medium { background-color: var(--warning-color); width: 66%; }
.password-strength.strong { background-color: var(--success-color); width: 100%; }

/* Custom File Upload */
.form-control[type="file"] {
    padding: 0.5rem;
}

.form-control[type="file"]::-webkit-file-upload-button {
    border: none;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    margin-right: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.form-control[type="file"]::-webkit-file-upload-button:hover {
    background: #0056b3;
}

/* Pagination Enhancements */
.pagination .page-link {
    border-radius: 0.375rem;
    margin: 0 0.125rem;
    border-color: var(--border-color);
    color: var(--text-color);
}

.pagination .page-link:hover {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Footer */
footer {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color) !important;
}

/* Print Styles */
@media print {
    .navbar, .btn, .pagination, footer {
        display: none !important;
    }
    
    .container-fluid {
        margin: 0;
        padding: 0;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
        break-inside: avoid;
    }
    
    .table {
        font-size: 12px;
    }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus States */
.btn:focus, .form-control:focus, .form-select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .card {
        border-width: 2px;
    }
    
    .btn {
        border-width: 2px;
    }
    
    .table th, .table td {
        border-width: 2px;
    }
}
