/* Custom application colors and overrides */
:root {
    --fredl-primary-color: #0d6efd;
    --fredl-header-bg: #91989f;
    --fredl-sidebar-bg: #6f8fa0;
    --fredl-footer-bg: #6f8fa0;
    --fredl-bg: #bed1d9;
    --fredl-table-heading: #6f8c8c;
    --sidebar-width: 220px;
    --header-height: 70px;
    --bs-light: #ffeecc;
    --bs-primary: #bed1d9;
}

body {
    background: var(--fredl-bg);
    line-height: 1.5;
}

/* Fixed Header */
header.navbar {
    background: var(--fredl-header-bg);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    height: var(--header-height);
    padding: 1rem 2rem;
}

header.navbar .navbar-brand {
    color: white;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header.navbar .navbar-brand:hover {
    color: white;
}

header.navbar .navbar-brand img {
    height: 2rem;
    width: auto;
}

/* User Dropdown */
.user-menu {
    position: relative;
}

.user-button {
    background: rgba(255,255,255,0.1);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.user-button:hover {
    background: rgba(255,255,255,0.2);
}

.user-button::after {
    content: '▼';
    font-size: 0.7rem;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.25rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.1);
    min-width: 200px;
    display: none;
    z-index: 1050;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.user-dropdown a:hover {
    background: var(--bs-light);
}

.user-dropdown a:first-child {
    border-radius: 0.25rem 0.25rem 0 0;
}

.user-dropdown a:last-child {
    border-radius: 0 0 0.25rem 0.25rem;
}

/* Filter Menu */
.filter-menu {
    position: relative;
    margin-right: 1rem;
    margin-left: 2rem;
}

.filter-button {
    background: rgba(255,255,255,0.1);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.filter-button:hover {
    background: rgba(255,255,255,0.2);
}

.filter-button::after {
    content: '▼';
    font-size: 0.7rem;
}

.filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.25rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.1);
    min-width: 280px;
    max-height: 70vh;
    overflow-y: auto;
    display: none;
    z-index: 1050;
}

.filter-dropdown.show {
    display: block;
}

.filter-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.filter-dropdown a:hover {
    background: var(--bs-light);
}

/* Create Button */
.create-button {
    background: rgba(40, 167, 69, 0.8);
    color: white;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    transition: background 0.2s, transform 0.1s;
    line-height: 1;
}

.create-button:hover {
    background: rgba(40, 167, 69, 1);
    transform: scale(1.1);
}

.create-icon {
    margin-top: -2px;
}

/* Ownership Toggle */
.ownership-toggle {
    display: flex;
    gap: 0.3rem;
    background: rgba(255,255,255,0.15);
    border-radius: 0.25rem;
    padding: 0.25rem;
    margin-right: 1.2rem;
}

.ownership-toggle a {
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    text-decoration: none;
    color: white;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.ownership-toggle a:hover {
    background: rgba(255,255,255,0.2);
}

.ownership-toggle a.active {
    background: rgba(255,255,255,0.3);
    font-weight: bold;
}

/* Search Filter Styles */
.search-filter {
    position: relative;
    margin-right: auto;
}

.search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 250px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.search-input::placeholder {
    color: #999;
}

.search-clear {
    position: absolute;
    right: 0.5rem;
    color: #999;
    text-decoration: none;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.search-clear:hover {
    color: #333;
}

/* Active search indicator */
.search-input[value]:not([value=""]) {
    border-color: #28a745;
    background-color: #f0fff0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .search-input {
        width: 150px;
        font-size: 0.8rem;
    }
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--fredl-sidebar-bg);
    overflow-y: auto;
    z-index: 1020;
}

.sidebar nav {
    padding: 1rem 0;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
    padding: 0.5rem 1.1rem;
    transition: background 0.2s;
}

.sidebar nav a .menu-icon {
    width: 1.8rem;
    height: 1.8rem;
    flex-shrink: 0;
    color: white;
    fill: white;
    stroke: white;
}

.sidebar nav a .fremoicon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar nav a.active {
    background: var(--bs-primary);
}

.sidebar nav .submenu a.active {
    background: var(--bs-primary);
}

.sidebar nav .menu-item {
    position: relative;
}

.sidebar nav .menu-item > a {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.sidebar nav .menu-item > a::after {
    content: '›';
    margin-left: auto;
    font-size: 1.4rem;
    transition: transform 0.2s;
}

.sidebar nav .menu-item.expanded > a::after {
    transform: rotate(90deg);
}

.sidebar nav .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.2);
}

.sidebar nav .menu-item.expanded > .submenu {
    max-height: 2000px;
}

.sidebar nav .submenu a {
    padding-left: 2.5rem;
    font-size: 0.9rem;
}

.sidebar nav .submenu .menu-item > a {
    padding-left: 2.5rem;
}

.sidebar nav .submenu .submenu a {
    padding-left: 3.5rem;
    font-size: 0.85rem;
}

.sidebar nav .submenu .submenu .submenu a {
    padding-left: 4.5rem;
    font-size: 0.8rem;
}

/* Main Content Area */
.content-wrapper {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    min-height: calc(100vh - var(--header-height) - 80px);
}

main {
    padding: 2rem;
}

/* Footer */
footer {
    background: var(--fredl-footer-bg);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-left: var(--sidebar-width);
}

/* Custom table headings */
.table-heading {
    background: var(--fredl-table-heading);
    font-weight: 600;
    color: white;
}

.table-footer {
    background: var(--fredl-table-heading);
}

/* Custom badges for asset status */
.badge-active {
    background: #d4edda;
    color: #155724;
}

.badge-in_stock {
    background: #d4edda;
    color: #155724;
}

.badge-on_layout {
    background: #cce5ff;
    color: #004085;
}

.badge-loaned {
    background: #fff3cd;
    color: #856404;
}

.badge-sold {
    background: #f8d7da;
    color: #721c24;
}

.badge-scrapped {
    background: #d6d8db;
    color: #383d41;
}

.badge-excellent {
    background: #d4edda;
    color: #155724;
}

.badge-good {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-fair {
    background: #fff3cd;
    color: #856404;
}

.badge-poor {
    background: #f8d7da;
    color: #721c24;
}

.badge-needs_repair {
    background: #f8d7da;
    color: #721c24;
}

/* Login page override for non-authenticated users */
body.no-sidebar .content-wrapper {
    margin-left: 0;
}

body.no-sidebar footer {
    margin-left: 0;
}

body.no-sidebar .sidebar {
    display: none;
}

/* Bootstrap overrides for better FreDL styling */

/* Tables */
table {
    width: 100%;
    margin-bottom: 1rem;
    background-color: white;
    border-collapse: collapse;
}

table thead th {
    background: var(--fredl-table-heading);
    color: white;
    padding: 0.75rem;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    vertical-align: bottom;
}

table tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

table tbody tr:hover {
    background-color: #f8f9fa;
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
    color: #212529;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Checkboxes */
input[type="checkbox"] {
    /*width: auto;*/
    margin-right: 0.5rem;
}

/* Form groups */
.form-group,
.mb-3 {
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.25rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary,
.btn {
    color: #fff;
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-secondary {
    color: #fff;
    background-color: #6c757d;
    border-color: #6c757d;
}

.btn-danger {
    color: #fff;
    background-color: #dc3545;
    border-color: #dc3545;
}

.btn-success {
    color: #fff;
    background-color: #198754;
    border-color: #198754;
}

.btn-light {
    color: #000;
    background-color: #f8f9fa;
    border-color: #f8f9fa;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.2rem;
}

/* Action button icon tooltips */
.action-btn-icon {
    position: relative;
}

.action-btn-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: #333;
    color: white;
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: 4px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-btn-icon:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.1rem;
    border: 5px solid transparent;
    border-top-color: #333;
    pointer-events: none;
    z-index: 1000;
}
