/**
 * RK Knit Fab Admin Dashboard Stylesheet
 * Incorporates matching design tokens and dark-theme configurations.
 */

/* Core Work Space Elements */
#admin-workspace {
    padding-top: 100px;
    padding-bottom: 60px;
    min-height: 80vh;
}

/* Tabs Toggle Display Engine */
.admin-tab-section {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-tab-section.active {
    display: block;
}

/* Stats Cards Grid Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius-lg);
    padding: 24px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 12px var(--shadow-subtle);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-heavy);
    border-color: var(--primary);
}

.stat-icon {
    font-size: 36px;
    color: var(--primary);
    background-color: var(--primary-container);
    padding: 16px;
    border-radius: var(--border-radius-md);
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

body.dark-theme .stat-icon {
    color: #a5a4f3;
    background-color: rgba(165, 164, 243, 0.1);
}

.stat-card:hover .stat-icon {
    background-color: var(--primary);
    color: var(--on-primary);
}

body.dark-theme .stat-card:hover .stat-icon {
    background-color: #a5a4f3;
    color: #121212;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

/* Dashboard Quick Actions Area */
.dashboard-actions {
    background-color: var(--bg-surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    box-shadow: 0 4px 12px var(--shadow-subtle);
}

/* Admin Grid Data Table styling */
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.section-header-row h2 {
    color: var(--text-primary);
}

.admin-fabrics-list-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow-subtle);
    margin-top: 24px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.admin-table th {
    padding: 16px 24px;
    background-color: var(--bg-surface-low);
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--outline);
}

.admin-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--outline-variant);
    font-size: 14px;
    vertical-align: middle;
    color: var(--text-secondary);
}

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

/* Admin Action Buttons */
.btn-table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-xs);
    border: 1px solid var(--outline);
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-table-action:hover {
    color: var(--primary);
    border-color: var(--primary);
    background-color: var(--primary-container);
}

body.dark-theme .btn-table-action:hover {
    color: #a5a4f3;
    border-color: #a5a4f3;
    background-color: rgba(165, 164, 243, 0.1);
}

.btn-table-action.delete:hover {
    color: #ff4d4d;
    border-color: #ff4d4d;
    background-color: rgba(255, 77, 77, 0.08);
}

/* Multi-Tab Admin Forms & Input groups */
.form-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius-lg);
    padding: 36px;
    box-shadow: 0 6px 18px var(--shadow-subtle);
}

.form-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--outline-variant);
    padding-bottom: 20px;
}

.form-card-header h2 {
    margin: 0;
    font-size: 24px;
    color: var(--text-primary);
}

.form-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--outline);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.form-back-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--bg-surface-low);
}

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 20px;
    border-bottom: 1px dashed var(--outline);
    padding-bottom: 8px;
}

body.dark-theme .form-section-title {
    color: #a5a4f3;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .form-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.form-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.form-input-group label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.form-input-group input,
.form-input-group select,
.form-input-group textarea {
    padding: 12px 16px;
    border: 1px solid var(--outline-variant);
    background-color: var(--bg-surface-low);
    color: var(--text-primary);
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: all var(--transition-speed);
    font-family: inherit;
    font-size: 14px;
}

.form-input-group input:focus,
.form-input-group select:focus,
.form-input-group textarea:focus {
    border-color: var(--primary);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(22, 21, 124, 0.08);
}

body.dark-theme .form-input-group input:focus,
body.dark-theme .form-input-group select:focus,
body.dark-theme .form-input-group textarea:focus {
    border-color: #a5a4f3;
    box-shadow: 0 0 0 3px rgba(165, 164, 243, 0.15);
}

/* Photo upload boxes */
.photo-upload-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 16px;
}

@media (min-width: 576px) {
    .photo-upload-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.photo-upload-box {
    border: 2px dashed var(--outline);
    border-radius: var(--border-radius-md);
    background-color: var(--bg-surface-low);
    height: 150px;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.photo-upload-box:hover {
    border-color: var(--primary);
    background-color: var(--bg-surface);
}

body.dark-theme .photo-upload-box:hover {
    border-color: #a5a4f3;
}

.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    padding: 12px;
    color: var(--text-muted);
}

.upload-inner img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.upload-inner .material-symbols-outlined {
    font-size: 32px;
    color: var(--primary);
}

body.dark-theme .upload-inner .material-symbols-outlined {
    color: #a5a4f3;
}

.upload-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-hint {
    font-size: 11px;
}

/* Uploaded thumbnails previews strip */
.uploaded-swatches-strip {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding: 12px;
    background-color: var(--bg-surface-low);
    border-radius: var(--border-radius-sm);
    min-height: 50px;
    border: 1px solid var(--outline-variant);
}

.swatch-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius-xs);
    overflow: hidden;
    border: 1px solid var(--outline);
}

.swatch-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.swatch-delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: rgba(255, 77, 77, 0.85);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed);
}

.swatch-delete-btn:hover {
    background-color: #ff3333;
}

.form-submit-row {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 32px;
    border-top: 1px solid var(--outline-variant);
    padding-top: 24px;
}

/* Category Manager Layout split */
.category-manager-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    align-items: start;
}

@media (min-width: 992px) {
    .category-manager-grid {
        grid-template-columns: 350px 1fr;
    }
}

/* Float status alerts toast */
.edit-save-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 100px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 999;
}

.edit-save-bar.active {
    transform: translate(-50%, 0);
}

/* Nav Item active bar override for Admin */
.admin-nav-item {
    position: relative;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-speed);
}

.admin-nav-item:hover,
.admin-nav-item.active {
    color: var(--primary);
}

body.dark-theme .admin-nav-item:hover,
body.dark-theme .admin-nav-item.active {
    color: #a5a4f3;
}

.admin-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 12px;
    right: 12px;
    height: 3px;
    background-color: var(--primary);
    border-radius: 2px;
}

body.dark-theme .admin-nav-item.active::after {
    background-color: #a5a4f3;
}
