/* === Admin Layout === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f6fa;
    color: #2d3436;
    font-size: 14px;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.admin-sidebar {
    width: 220px;
    background: #2d3436;
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid #636e72;
}

.sidebar-logo {
    display: block;
    width: 100%;
    max-width: 140px;
    height: auto;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
}

.sidebar-nav li a {
    display: block;
    padding: 0.7rem 1rem;
    color: #b2bec3;
    text-decoration: none;
    transition: background 0.15s;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: #636e72;
    color: #fff;
}

/* === Sidebar Footer (logout) === */
.admin-sidebar a,
.admin-sidebar a:link,
.admin-sidebar a:visited {
    color: inherit;
    text-decoration: none;
}

.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 1rem;
    border-top: 1px solid #636e72;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.sidebar-user-info svg {
    color: #dfe6e9;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 0.82rem;
    color: #dfe6e9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

/* === Sidebar Login Link === */
.sidebar-login-link {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logout-form {
    margin: 0;
    padding: 0;
}

.sidebar-logout,
.sidebar-logout:visited,
.sidebar-logout:active {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: #636e72;
    color: #fff;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
}

.sidebar-logout:hover {
    background: #d63031;
    color: #fff;
    text-decoration: none;
}

.sidebar-logout-icon,
.sidebar-login-icon,
.sidebar-user-icon {
    flex-shrink: 0;
}

/* === Login Prompt === */
.login-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    gap: 0.75rem;
}

.login-prompt-icon {
    color: #0984e3;
    margin-bottom: 0.5rem;
}

.login-prompt h1 {
    font-size: 1.8rem;
    color: #2d3436;
    margin: 0;
}

.login-prompt h2 {
    font-size: 1.1rem;
    color: #636e72;
    font-weight: 400;
    margin: 0;
}

.login-prompt p {
    color: #636e72;
    font-size: 0.95rem;
    max-width: 400px;
}

.login-prompt .btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 2rem;
    background: #0984e3;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.15s;
    margin-top: 0.5rem;
}

.login-prompt .btn-primary:hover {
    background: #0652DD;
}

/* === Content === */
.admin-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.75rem; }

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value { font-size: 2rem; font-weight: 700; color: #0984e3; }
.stat-label { color: #636e72; font-size: 0.85rem; }

/* === Table === */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.admin-table th,
.admin-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #636e72;
}

.admin-table tr:hover { background: #f8f9fa; }
.row-inactive { opacity: 0.5; }

code {
    background: #f1f2f6;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-stock     { background: #dfe6e9; color: #2d3436; }
.badge-delivered { background: #ffeaa7; color: #636e72; }
.badge-active    { background: #55efc4; color: #00b894; }
.badge-expired   { background: #fab1a0; color: #d63031; }
.badge-blocked   { background: #ff7675; color: #fff; }

/* === Filter Bar === */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar--secondary {
    margin-bottom: 1rem;
}

.filter-bar select,
.filter-bar input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.filter-date-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #636e72;
    white-space: nowrap;
}

.filter-date-label input {
    width: 140px;
}

/* === Forms === */
.form-section {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 500px;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: #636e72;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* === Detail === */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-section {
    background: #fff;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

dl { display: grid; grid-template-columns: 130px 1fr; gap: 0.4rem 0.75rem; }
dt { font-weight: 600; color: #636e72; font-size: 0.85rem; }
dd { word-break: break-all; }

/* === Buttons === */
.btn, .btn-sm {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.15s;
}

.btn:hover, .btn-sm:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-primary { background: #0984e3; color: #fff; }
.btn-success { background: #00b894; color: #fff; }
.btn-warning { background: #fdcb6e; color: #2d3436; }
.btn-danger  { background: #d63031; color: #fff; }
.btn         { background: #dfe6e9; color: #2d3436; }

.action-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* === Bulk Toolbar === */
.bulk-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: #f0f0f0;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    min-height: 44px;
    position: sticky;
    top: 0;
    z-index: 10;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.bulk-toolbar--active {
    background: #dfe6e9;
    border-color: #b2bec3;
}

.bulk-info {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.bulk-info--empty {
    font-weight: 400;
    color: #b2bec3;
}

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

.bulk-actions select {
    padding: 0.35rem 0.6rem;
    border: 1px solid #b2bec3;
    border-radius: 6px;
    font-size: 0.85rem;
}

.bulk-domain-select {
    min-width: 60px;
}

/* === Table keyboard wrapper === */
.table-keyboard-wrap {
    outline: none;
}

.table-keyboard-wrap:focus-within .admin-table {
    box-shadow: 0 0 0 2px rgba(9,132,227,0.15);
}

/* === Row states === */
.row-focused {
    outline: 2px solid #0984e3;
    outline-offset: -2px;
}

.row-selected {
    background: #dfe6e9 !important;
}

/* === Subtle links (clickable text) === */
a.subtle-link,
a.subtle-link:visited,
a.subtle-link:active {
    color: inherit;
    text-decoration: none;
    cursor: default;
    transition: color 0.15s, text-decoration 0.15s;
}

a.subtle-link:hover {
    color: #0984e3;
    text-decoration: underline;
    cursor: pointer;
}

.bulk-select-all-hint {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: #636e72;
}

/* === Badges (extended) === */
.badge-created   { background: #81ecec; color: #00b894; }
.badge-printing  { background: #ffeaa7; color: #636e72; }
.badge-expedited { background: #a29bfe; color: #fff; }
.badge-customer  { background: #55efc4; color: #00b894; }
.badge-self-customer { background: #00cec9; color: #fff; }
.badge-damaged   { background: #ff7675; color: #fff; }

/* === Target-type badges === */
.type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    font-weight: 700;
    font-size: 0.75rem;
}
.type-badge-q    { background: #0984e3; color: #fff; }
.type-badge-t    { background: #e17055; color: #fff; }
.type-badge-none { background: #b2bec3; color: #636e72; }

/* === Messages === */
.error   { color: #d63031; margin: 0.75rem 0; }
.success { color: #00b894; margin: 0.75rem 0; }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem 2rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    min-width: 380px;
    max-width: 500px;
}

.modal-dialog h2 {
    margin-top: 0;
}

/* === Snackbar === */
.snackbar-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    max-width: 480px;
}

.snackbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    animation: snackbar-in 0.3s ease;
}

@keyframes snackbar-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.snackbar-info    { background: #0984e3; }
.snackbar-success { background: #00b894; }
.snackbar-warning { background: #fdcb6e; color: #2d3436; }
.snackbar-error   { background: #d63031; }

.snackbar-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    opacity: 0.7;
}
.snackbar-close:hover { opacity: 1; }

/* === Responsive === */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; }
    .sidebar-nav { display: flex; overflow-x: auto; }
    .sidebar-nav li a { white-space: nowrap; }
    .admin-content { padding: 1rem; }
}
