/**
 * MSM Management Modern Components CSS
 * Version: 1.0.0
 */

/* =========================================================================
   CSS Variables
   ========================================================================= */
:root {
    --msm-primary: #6B5B95;
    --msm-primary-light: #8B7BB5;
    --msm-primary-dark: #4B3B75;
    --msm-secondary: #4A4063;
    --msm-success: #22C55E;
    --msm-warning: #F59E0B;
    --msm-danger: #EF4444;
    --msm-info: #3B82F6;

    --msm-card-bg: rgba(26, 32, 44, 0.8);
    --msm-card-border: rgba(255, 255, 255, 0.08);
    --msm-text-primary: #FFFFFF;
    --msm-text-secondary: rgba(255, 255, 255, 0.7);
    --msm-text-muted: rgba(255, 255, 255, 0.5);
}

[data-bs-theme="light"] {
    --msm-card-bg: rgba(255, 255, 255, 0.9);
    --msm-card-border: rgba(0, 0, 0, 0.08);
    --msm-text-primary: #1a202c;
    --msm-text-secondary: rgba(26, 32, 44, 0.7);
    --msm-text-muted: rgba(26, 32, 44, 0.5);
}

/* =========================================================================
   KPI Cards
   ========================================================================= */
.kpi-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px;
    background: var(--msm-card-bg);
    border: 1px solid var(--msm-card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 20px;
    flex-shrink: 0;
}

.kpi-primary .kpi-icon {
    background: linear-gradient(135deg, var(--msm-primary), var(--msm-primary-dark));
    color: white;
}

.kpi-success .kpi-icon {
    background: linear-gradient(135deg, var(--msm-success), #16A34A);
    color: white;
}

.kpi-warning .kpi-icon {
    background: linear-gradient(135deg, var(--msm-warning), #D97706);
    color: white;
}

.kpi-danger .kpi-icon {
    background: linear-gradient(135deg, var(--msm-danger), #DC2626);
    color: white;
}

.kpi-info .kpi-icon {
    background: linear-gradient(135deg, var(--msm-info), #2563EB);
    color: white;
}

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--msm-text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--msm-text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
}

.kpi-trend {
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.kpi-trend.text-success { color: var(--msm-success); }
.kpi-trend.text-danger { color: var(--msm-danger); }

/* =========================================================================
   Modern Cards
   ========================================================================= */
.msm-card {
    background: var(--msm-card-bg);
    border: 1px solid var(--msm-card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.msm-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--msm-card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.msm-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--msm-text-primary);
    margin: 0;
}

.msm-card-body {
    padding: 24px;
}

.msm-card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--msm-card-border);
    background: rgba(0, 0, 0, 0.1);
}

/* =========================================================================
   Modern Buttons
   ========================================================================= */
.btn-msm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-msm-primary {
    background: linear-gradient(135deg, var(--msm-primary), var(--msm-primary-dark));
    color: white;
}

.btn-msm-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 91, 149, 0.4);
}

.btn-msm-secondary {
    background: var(--msm-card-bg);
    border: 1px solid var(--msm-card-border);
    color: var(--msm-text-primary);
}

.btn-msm-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-msm-ghost {
    background: transparent;
    color: var(--msm-text-secondary);
}

.btn-msm-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--msm-text-primary);
}

/* =========================================================================
   Chart Containers
   ========================================================================= */
.chart-container {
    position: relative;
    min-height: 300px;
    padding: 16px;
}

.chart-container canvas {
    max-width: 100%;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 0;
    justify-content: center;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--msm-text-secondary);
}

.chart-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* =========================================================================
   Data Tables Enhancement
   ========================================================================= */
.msm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.msm-table thead th {
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--msm-text-secondary);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--msm-card-border);
}

.msm-table tbody td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--msm-text-primary);
    border-bottom: 1px solid var(--msm-card-border);
    vertical-align: middle;
}

.msm-table tbody tr:hover {
    background: rgba(107, 91, 149, 0.08);
}

.msm-table tbody tr:last-child td {
    border-bottom: none;
}

/* =========================================================================
   Status Badges
   ========================================================================= */
.badge-msm {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-msm-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--msm-success);
}

.badge-msm-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--msm-warning);
}

.badge-msm-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--msm-danger);
}

.badge-msm-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--msm-info);
}

.badge-msm-primary {
    background: rgba(107, 91, 149, 0.15);
    color: var(--msm-primary-light);
}

/* Status dot */
.badge-msm::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* =========================================================================
   Progress Bars
   ========================================================================= */
.progress-msm {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-msm-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.progress-msm-bar.primary {
    background: linear-gradient(90deg, var(--msm-primary), var(--msm-primary-light));
}

.progress-msm-bar.success {
    background: linear-gradient(90deg, #16A34A, var(--msm-success));
}

.progress-msm-bar.warning {
    background: linear-gradient(90deg, #D97706, var(--msm-warning));
}

.progress-msm-bar.danger {
    background: linear-gradient(90deg, #DC2626, var(--msm-danger));
}

/* =========================================================================
   Form Controls Enhancement
   ========================================================================= */
.form-control-msm {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--msm-card-border);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--msm-text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control-msm:focus {
    outline: none;
    border-color: var(--msm-primary);
    box-shadow: 0 0 0 3px rgba(107, 91, 149, 0.2);
}

.form-control-msm::placeholder {
    color: var(--msm-text-muted);
}

.form-label-msm {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--msm-text-secondary);
    margin-bottom: 8px;
}

/* =========================================================================
   Activity Timeline
   ========================================================================= */
.timeline-msm {
    position: relative;
    padding-left: 32px;
}

.timeline-msm::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--msm-card-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -26px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--msm-primary);
    border: 2px solid var(--msm-card-bg);
}

.timeline-content {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 12px 16px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--msm-text-primary);
    margin-bottom: 4px;
}

.timeline-text {
    font-size: 13px;
    color: var(--msm-text-secondary);
}

.timeline-time {
    font-size: 12px;
    color: var(--msm-text-muted);
    margin-top: 8px;
}

/* =========================================================================
   Loading States
   ========================================================================= */
.skeleton {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* =========================================================================
   Responsive Adjustments
   ========================================================================= */
@media (max-width: 768px) {
    .kpi-card {
        padding: 16px;
    }

    .kpi-value {
        font-size: 24px;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .msm-card-header,
    .msm-card-body {
        padding: 16px;
    }

    .chart-container {
        min-height: 250px;
    }
}

/* =========================================================================
   Animations
   ========================================================================= */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fadeIn { animation: fadeIn 0.3s ease-out; }
.animate-slideUp { animation: slideUp 0.4s ease-out; }
.animate-pulse { animation: pulse 2s infinite; }

/* Staggered animation for lists */
.animate-stagger > * {
    opacity: 0;
    animation: slideUp 0.4s ease-out forwards;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.3s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.4s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.5s; }
.animate-stagger > *:nth-child(6) { animation-delay: 0.6s; }
