/* MLM Gallery - Admin-Bereich Styles */
/* Hybrid Navigation: Horizontal Top-Nav + Contextual Sidebar */

/* =====================================================
   CSS Custom Properties
   ===================================================== */
:root {
    --admin-top-nav-height: 60px;
    --admin-sidebar-width: 280px;
    --admin-sidebar-collapsed-width: 0px;
}

/* =====================================================
   Skip Link (Accessibility)
   ===================================================== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--mlm-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 10000;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid white;
    outline-offset: 2px;
}

/* =====================================================
   Top Navigation (Horizontal)
   ===================================================== */
.admin-top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--admin-top-nav-height);
    background: var(--mlm-primary);
    color: white;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.admin-top-nav-container {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1rem;
    max-width: 100%;
}

/* Brand/Logo */
.admin-top-nav-brand {
    flex-shrink: 0;
    margin-right: 1.5rem;
}

.admin-top-nav-brand a {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
}

.admin-top-nav-brand img {
    height: 40px;
    width: auto;
}

.admin-top-nav-brand i {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

/* Navigation Tabs */
.admin-top-nav-tabs {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
    flex: 1;
}

.admin-top-nav-item {
    height: 100%;
}

.admin-top-nav-link {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.admin-top-nav-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

.admin-top-nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
    border-bottom-color: white;
}

.admin-top-nav-link i {
    margin-right: 0.5rem;
    font-size: 1rem;
}

/* User Actions */
.admin-top-nav-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
    gap: 0.25rem;
}

.admin-top-nav-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.admin-top-nav-action:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.15);
}

.admin-top-nav-action i {
    font-size: 1.1rem;
}

/* =====================================================
   Admin Layout Wrapper
   ===================================================== */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    padding-top: var(--admin-top-nav-height);
}

/* =====================================================
   Contextual Sidebar
   ===================================================== */
.admin-sidebar {
    width: var(--admin-sidebar-width);
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    position: fixed;
    top: var(--admin-top-nav-height);
    left: 0;
    height: calc(100vh - var(--admin-top-nav-height));
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease, width 0.3s ease;
    z-index: 1020;
}

.admin-sidebar.collapsed {
    width: 0;
}

.admin-sidebar.collapsed .sidebar-nav {
    opacity: 0;
    visibility: hidden;
}

/* Sidebar Toggle Button - fixed below content header */
.sidebar-toggle {
    position: fixed;
    top: calc(var(--admin-top-nav-height) + 3.4rem);
    left: calc(var(--admin-sidebar-width) - 14px);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mlm-primary, #2c3e50);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    font-size: 0.85rem;
    transition: left 0.3s ease, background 0.2s ease;
    z-index: 1025;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Button moves to left edge when sidebar is collapsed (sibling selector) */
.admin-sidebar.collapsed + .sidebar-toggle {
    left: 0;
    border-radius: 0 50% 50% 0;
    border-left: none;
}

.sidebar-toggle:hover {
    background: #1a252f;
    color: white;
}

.sidebar-toggle:focus {
    outline: 3px solid var(--mlm-primary);
    outline-offset: 2px;
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-heading {
    padding: 0.75rem 1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6c757d;
    margin: 0;
}

.sidebar-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    color: #495057;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background-color: #e9ecef;
    color: #212529;
}

.sidebar-item.active .sidebar-link,
.sidebar-link:focus {
    background-color: rgba(30, 58, 95, 0.1);
    border-left-color: var(--mlm-primary);
    color: var(--mlm-primary);
    font-weight: 500;
}

.sidebar-link:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--mlm-primary);
}

.sidebar-link i {
    width: 1.25rem;
    margin-right: 0.75rem;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar Subgroups */
.sidebar-subgroup {
    margin: 0;
}

.sidebar-subgroup-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.625rem 1rem;
    background: none;
    border: none;
    color: #495057;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-subgroup-toggle:hover {
    background-color: #e9ecef;
    color: #212529;
}

.sidebar-subgroup-toggle:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--mlm-primary);
}

.sidebar-subgroup-toggle i:first-child {
    width: 1.25rem;
    margin-right: 0.75rem;
    text-align: center;
}

.sidebar-subgroup-toggle span {
    flex: 1;
}

.sidebar-subgroup-icon {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.sidebar-subgroup-toggle[aria-expanded="false"] .sidebar-subgroup-icon {
    transform: rotate(-90deg);
}

.sidebar-subgroup-items {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.02);
}

.sidebar-subgroup-items .sidebar-link {
    padding-left: 2.75rem;
    font-size: 0.8125rem;
}

/* =====================================================
   Main Content Area
   ===================================================== */
.admin-main {
    flex: 1;
    margin-left: var(--admin-sidebar-width);
    padding: 1.5rem;
    background-color: #f8f9fa;
    min-height: calc(100vh - var(--admin-top-nav-height));
    transition: margin-left 0.3s ease;
}

/* Dashboard has no sidebar */
.admin-wrapper:not(:has(.admin-sidebar)) .admin-main,
.admin-main.no-sidebar {
    margin-left: 0;
}

/* =====================================================
   Admin Header (Page Title + Actions)
   ===================================================== */
.admin-header {
    background: white;
    padding: 1rem 1.5rem;
    margin: -1.5rem -1.5rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: var(--admin-top-nav-height);
    z-index: 1010;
}

.admin-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 500;
    color: #212529;
}

.admin-header .btn,
.admin-header .btn-group .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.admin-card h2 {
    margin-top: 0;
    color: #212529;
    font-weight: 500;
}

/* =====================================================
   Tables
   ===================================================== */
.admin-table {
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-table table {
    margin: 0;
}

.admin-table thead {
    background: var(--mlm-primary);
    color: white;
}

.admin-table th {
    border: none;
    padding: 0.875rem 1rem;
    font-weight: 500;
}

.admin-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e9ecef;
}

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

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

.admin-table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.admin-table .btn-group .btn-sm {
    min-width: 2rem;
    min-height: 2rem;
}

/* =====================================================
   Buttons
   ===================================================== */
.btn-admin-primary {
    background: var(--bs-light);
    border: 1px solid #6c757d;
    color: #212529;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.btn-admin-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: var(--mlm-primary);
}

/* =====================================================
   Forms
   ===================================================== */
.admin-form {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-form .form-label {
    font-weight: 500;
    color: #212529;
    margin-bottom: 0.5rem;
}

.form-label.required::after {
    content: " *";
    color: var(--bs-danger);
}

.admin-form .form-control {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 0.625rem 0.75rem;
    transition: all 0.2s ease;
}

.admin-form .form-control:focus {
    border-color: var(--mlm-primary);
    box-shadow: 0 0 0 0.2rem rgba(30, 58, 95, 0.15);
}

/* =====================================================
   Status Badges
   ===================================================== */
.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.status-owned {
    background-color: #d4edda;
    color: #155724;
}

.status-not-owned {
    background-color: #f8d7da;
    color: #721c24;
}

.status-ordered {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* =====================================================
   Loading States
   ===================================================== */
.admin-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.admin-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =====================================================
   Timeline (Status History)
   ===================================================== */
.timeline {
    position: relative;
    padding-left: 0;
}

.timeline-item {
    position: relative;
    padding: 0.5rem 0;
    border-left: 2px solid #dee2e6;
    padding-left: 1rem;
    margin-bottom: 0.5rem;
}

.timeline-item:last-child {
    border-left-color: transparent;
    margin-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0.75rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--mlm-primary);
    border: 2px solid #fff;
}

.timeline-item:first-child::before {
    background-color: #28a745;
}

.timeline-marker {
    position: absolute;
    left: -10px;
    top: 0.5rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-radius: 50%;
    font-size: 14px;
    z-index: 1;
}

.timeline-content {
    padding: 0.5rem 0;
}

.timeline-content .metadata {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
}

/* Mobile Offcanvas Navigation styles removed - using contextual sidebar instead */

/* =====================================================
   Responsive Design
   ===================================================== */

/* Tablet */
@media (max-width: 992px) {
    .admin-top-nav-link span {
        display: none;
    }

    .admin-top-nav-link {
        padding: 0 0.75rem;
    }

    .admin-top-nav-link i {
        margin-right: 0;
        font-size: 1.2rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .admin-top-nav-tabs {
        display: none;
    }

    .admin-top-nav-actions {
        display: none;
    }

    .admin-sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        z-index: 1040;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0;
        padding: 1rem;
    }

    .admin-header {
        margin: -1rem -1rem 1rem;
        padding: 0.875rem 1rem;
    }

    .admin-header h1 {
        font-size: 1.25rem;
    }

    .admin-top-nav-brand span {
        display: none;
    }
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .sidebar-link,
    .sidebar-subgroup-toggle,
    .admin-top-nav-link,
    .admin-top-nav-action {
        min-height: 44px;
    }
}

/* =====================================================
   Accessibility: Focus Visible
   ===================================================== */
.admin-top-nav-link:focus-visible,
.admin-top-nav-action:focus-visible,
.sidebar-link:focus-visible,
.sidebar-subgroup-toggle:focus-visible {
    outline: 3px solid white;
    outline-offset: -3px;
}

.sidebar-link:focus-visible,
.sidebar-subgroup-toggle:focus-visible {
    outline-color: var(--mlm-primary);
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .admin-sidebar {
        border-right-width: 2px;
    }

    .sidebar-item.active .sidebar-link {
        border-left-width: 4px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .admin-sidebar,
    .admin-main,
    .sidebar-subgroup-icon,
    .admin-top-nav-link,
    .sidebar-link {
        transition: none;
    }
}

/* Print styles */
@media print {
    .admin-top-nav,
    .admin-sidebar,
    .sidebar-toggle,
    .admin-header .btn {
        display: none !important;
    }

    .admin-main {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .admin-wrapper {
        padding-top: 0 !important;
    }
}
