/* ============================================
   Admin Shared Components Styles
   ============================================ */

/* ============================================
   Admin Page Header
   ============================================ */

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-page-header-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-page-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.admin-page-header-icon {
    color: var(--color-primary);
}

.admin-page-header-text {
    font-weight: 600;
    margin: 0;
}

.admin-page-header-subtitle {
    margin-left: 0.5rem;
}

.admin-page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .admin-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-page-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}


/* ============================================
   Admin Empty State
   ============================================ */

.admin-empty-state-container {
    padding: 3rem;
    border-radius: 12px;
    margin-top: 1rem;
}

.admin-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.admin-empty-state-icon {
    margin-bottom: 1rem;
}

.admin-empty-state-title {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.admin-empty-state-description {
    margin-bottom: 1.5rem;
    max-width: 400px;
}

.admin-empty-state-content {
    margin-bottom: 1.5rem;
    width: 100%;
}

.admin-empty-state-action {
    margin-top: 0.5rem;
}

/* ============================================
   Admin Error State
   ============================================ */

.admin-error-state-container {
    padding: 3rem;
    border-radius: 12px;
    margin-top: 1rem;
}

.admin-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.admin-error-state-icon {
    margin-bottom: 1rem;
}

.admin-error-state-title {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.admin-error-state-description {
    margin-bottom: 1.5rem;
    max-width: 400px;
}

.admin-error-state-content {
    margin-bottom: 1.5rem;
    width: 100%;
}

.admin-error-state-action {
    margin-top: 0.5rem;
}

/* ============================================
   Admin Loading State
   ============================================ */

.admin-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.admin-loading-message {
    margin-top: 1rem;
}

/* ============================================
   Admin Form Actions
   ============================================ */

.admin-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-light);
}

/* Left-aligned variant */
.admin-form-actions.align-left {
    justify-content: flex-start;
}

/* No border variant */
.admin-form-actions.no-border {
    border-top: none;
    padding-top: 0;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .admin-form-actions {
        flex-direction: column-reverse;
        width: 100%;
    }

    .admin-form-actions .admin-form-save,
    .admin-form-actions .admin-form-cancel {
        width: 100%;
    }
}

/* ============================================
   Admin Form Styles (Standardized)
   ============================================ */

.admin-form {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 12px;
}

.admin-form-title {
    margin-bottom: 1.5rem;
}

.admin-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-form-row > * {
    min-width: 0;
}

.admin-form-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border-light);
}

.admin-form-section-title {
    margin-bottom: 1rem;
    font-weight: 600;
}

/* ============================================
   Admin Table Styles (Standardized)
   ============================================ */

.admin-table {
    margin-top: 1rem;
    overflow-x: auto;
}

.admin-table .actions {
    white-space: nowrap;
}

.admin-table th {
    white-space: nowrap;
}

/* Table toolbar wrapping for tablet and below */
.admin-table .mud-table-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Mobile table improvements */
@media (max-width: 600px) {
    .admin-table {
        font-size: 0.875rem;
    }

    .admin-table .mud-table-toolbar {
        padding: 8px;
    }

    .admin-table .mud-table-toolbar .mud-input-control {
        min-width: 0;
    }

    .admin-table .mud-table-toolbar .mud-input {
        min-width: 0;
    }
}

/* ============================================
   Admin Card Styles
   ============================================ */

.admin-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
}

.admin-card-content {
    flex-grow: 1;
}

.admin-card-actions {
    padding: 1rem;
    padding-top: 0;
}

/* ============================================
   Admin Status Chips (Standardized)
   ============================================ */

.admin-status-online {
    background-color: var(--color-success) !important;
    color: white !important;
}

.admin-status-slow {
    background-color: var(--color-warning) !important;
    color: black !important;
}

.admin-status-offline {
    background-color: var(--color-danger) !important;
    color: white !important;
}

/* ============================================
   Admin Code Display
   ============================================ */

.admin-code {
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

[data-theme="dark"] .admin-code {
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   Admin Toolbar
   ============================================ */

.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-toolbar-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================
   Admin Alert (Organization Selection)
   ============================================ */

.admin-org-alert {
    margin-bottom: 1rem;
}

/* ============================================
   Admin Sidebar Navigation
   ============================================ */

/* Make tooltip wrappers and nav groups full width in nav menu */
.mud-navmenu .mud-tooltip-root,
.mud-navmenu .mud-tooltip-root.mud-tooltip-inline {
    display: block;
    width: 100%;
}

.mud-navmenu .mud-nav-group {
    width: 100%;
}

.mud-navmenu .mud-nav-group > .mud-nav-link {
    width: 100%;
    box-sizing: border-box;
}

/* Align MudNavGroup expand arrows consistently to the right */
.mud-nav-group > .mud-nav-link .mud-nav-link-text {
    flex: 1;
}

/* Navigation link styling for dark sidebar */
.mud-drawer .mud-nav-link {
    border-radius: 8px;
    margin: 2px 8px;
    transition: all 0.15s ease;
}

.mud-drawer .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.mud-drawer .mud-navmenu.mud-navmenu-default .mud-nav-link.active:not(.mud-nav-link-disabled) {
    background-color: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
}

.mud-drawer .mud-nav-link.active .mud-nav-link-icon {
    color: #60a5fa;
}

/* Divider styling in sidebar */
.mud-drawer .mud-divider {
    border-color: rgba(255, 255, 255, 0.12);
    margin-left: 8px;
    margin-right: 8px;
}

/* Mini drawer when CLOSED - collapsed icon-only state */
.mud-drawer-mini.mud-drawer--closed {
    width: 56px !important;
}

.mud-drawer-mini.mud-drawer--closed .mud-nav-link {
    justify-content: center !important;
    padding: 12px 0 !important;
    margin: 2px 6px;
    min-width: 44px;
}

.mud-drawer-mini.mud-drawer--closed .mud-nav-link .mud-nav-link-icon {
    margin: 0 !important;
}

.mud-drawer-mini.mud-drawer--closed .mud-nav-link .mud-nav-link-text {
    display: none;
}

.mud-drawer-mini.mud-drawer--closed .mud-nav-link-expand-icon {
    display: none !important;
}

.mud-drawer-mini.mud-drawer--closed .mud-drawer-header {
    justify-content: center !important;
    padding: 12px 0;
}

/* Mini drawer when OPEN - full width with text */
.mud-drawer-mini.mud-drawer--open {
    width: 240px !important;
}

.mud-drawer-mini.mud-drawer--open .mud-drawer-header {
    justify-content: center !important;
    padding: 12px 16px;
}

/* Dark mode adjustments */
[data-theme="dark"] .mud-drawer .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .mud-drawer .mud-nav-link.active {
    background-color: rgba(96, 165, 250, 0.15);
}

[data-theme="dark"] .mud-drawer .mud-divider {
    border-color: rgba(255, 255, 255, 0.08);
}

/* ============================================
   Dark Mode Component Contrast
   ============================================ */

/* Cards need visible borders in dark mode */
[data-theme="dark"] .mud-paper {
    border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .mud-card {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: #252525;
}

/* Elevated surfaces should be slightly lighter */
[data-theme="dark"] .mud-paper.mud-elevation-1,
[data-theme="dark"] .mud-paper.mud-elevation-2 {
    background-color: #262626;
}

[data-theme="dark"] .mud-paper.mud-elevation-3,
[data-theme="dark"] .mud-paper.mud-elevation-4 {
    background-color: #2a2a2a;
}

/* Table rows need subtle separation */
[data-theme="dark"] .mud-table-row:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

/* ============================================
   Account Menu Improvements
   ============================================ */

/* Account button styling - target the MudMenu activator button directly */
.admin-account-menu .mud-menu-activator {
    display: flex;
    align-items: center;
    border-radius: 8px !important;
    padding: 4px 12px !important;
    transition: background-color 0.15s ease;
    font-weight: 500;
    cursor: pointer;
}

.admin-account-menu .mud-menu-activator:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Account menu dropdown styling */
.mud-menu .mud-popover-paper {
    border-radius: 12px;
    min-width: 200px;
}

.mud-menu .mud-list-item {
    border-radius: 6px;
    margin: 2px 8px;
    transition: background-color 0.15s ease;
}

.mud-menu .mud-list-item:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Dark mode menu styling */
[data-theme="dark"] .mud-menu .mud-popover-paper {
    background-color: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mud-menu .mud-list-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* ============================================
   Organization Selector (AppBar)
   ============================================ */

.org-selector {
    min-width: 200px;
    max-width: 250px;
}

.page-title-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

@media (max-width: 600px) {
    .org-selector {
        min-width: 120px;
        max-width: 160px;
    }
}

@media (max-width: 400px) {
    .org-selector {
        min-width: 100px;
        max-width: 130px;
    }
}

/* ============================================
   Dropdown/Select Styling for Dark Mode
   ============================================ */

/* Organization dropdown in dark appbar */
.mud-appbar .mud-select .mud-input-control {
    color: inherit;
}

.mud-appbar .mud-select .mud-input {
    color: white !important;
}

.mud-appbar .mud-select .mud-select-input {
    color: white !important;
}

.mud-appbar .mud-select .mud-input-label {
    color: rgba(255, 255, 255, 0.7) !important;
}

.mud-appbar .mud-select .mud-icon-root {
    color: rgba(255, 255, 255, 0.7);
}

/* Select dropdown popover */
[data-theme="dark"] .mud-popover-paper {
    background-color: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mud-list-item-text {
    color: rgba(255, 255, 255, 0.87);
}

[data-theme="dark"] .mud-list-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* ============================================
   Product Order - Drag and Drop
   ============================================ */

.product-order-card {
    cursor: grab;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    border-radius: 8px;
}

.product-order-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-order-card:active {
    cursor: grabbing;
    transform: scale(1.01);
}

.product-drag-handle {
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

.product-order-card:hover .product-drag-handle {
    opacity: 0.8;
}

/* Drop zone placeholder styling */
.mud-drop-zone .mud-dropitem-placeholder {
    border: 2px dashed var(--mud-palette-primary);
    border-radius: 8px;
    opacity: 0.5;
    min-height: 60px;
}
