/* ============================================================
   1-base.css
   Bundle 1/5 — Global tokens, resets, utilities
   Nguồn gốc: app.css + :root vars từ admin-layout.css + ai-components.css
   Load TRƯỚC TIÊN trong App.razor, sau MudBlazor.
   ============================================================ */

/* ══════════════════════════════════════════════════════════
   APP.CSS — Global styles, utilities, animations
══════════════════════════════════════════════════════════ */

/* ── Legacy vars (dùng bởi app.css components cũ) ── */
:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

[data-theme="dark"] {
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--background-color);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Canvas (legacy MudBlazor wrapper — không xóa, dùng bởi app.css component cũ) */
.canvas-container {
    position: relative;
    width: 100%;
    height: 600px;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 0px;
    overflow: hidden;
}

.drawing-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

    .drawing-canvas.eraser-mode {
        cursor: grab;
    }

/* Image card */
.image-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    cursor: pointer;
}

    .image-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }

/* Job item */
.job-item {
    transition: background-color 0.2s ease-in-out;
    cursor: pointer;
}

    .job-item:hover {
        background-color: var(--background-color);
    }

@media (max-width: 768px) {
    .canvas-container {
        height: 400px;
    }

    .mud-grid {
        padding: 8px;
    }
}

/* Drawing tool buttons */
.drawing-tool-button {
    min-width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
}

    .drawing-tool-button:hover {
        background-color: var(--primary-color);
        color: white;
        transform: scale(1.05);
    }

    .drawing-tool-button.active {
        background-color: var(--primary-color);
        color: white;
    }

.color-palette-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all 0.2s ease-in-out;
}

    .color-palette-button:hover {
        transform: scale(1.1);
        border-color: var(--primary-color);
    }

    .color-palette-button.active {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    }

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.3s ease-in-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.2s ease-in-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Utilities */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-muted {
    color: var(--text-secondary) !important;
}

.w-100 {
    width: 100%;
}

.h-100 {
    height: 100%;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-space-between {
    justify-content: space-between;
}

.flex-column {
    flex-direction: column;
}

.flex-row {
    flex-direction: row;
}

/* Spacing */
.pa-1 {
    padding: 4px
}

.pa-2 {
    padding: 8px
}

.pa-3 {
    padding: 12px
}

.pa-4 {
    padding: 16px
}

.pa-5 {
    padding: 20px
}

.ma-1 {
    margin: 4px
}

.ma-2 {
    margin: 8px
}

.ma-3 {
    margin: 12px
}

.ma-4 {
    margin: 16px
}

.ma-5 {
    margin: 20px
}

.mt-1 {
    margin-top: 4px
}

.mt-2 {
    margin-top: 8px
}

.mt-3 {
    margin-top: 12px
}

.mt-4 {
    margin-top: 16px
}

.mt-5 {
    margin-top: 20px
}

.mb-1 {
    margin-bottom: 4px
}

.mb-2 {
    margin-bottom: 8px
}

.mb-3 {
    margin-bottom: 12px
}

.mb-4 {
    margin-bottom: 16px
}

.mb-5 {
    margin-bottom: 20px
}

.mr-1 {
    margin-right: 4px
}

.mr-2 {
    margin-right: 8px
}

.mr-3 {
    margin-right: 12px
}

.mr-4 {
    margin-right: 16px
}

.mr-5 {
    margin-right: 20px
}

.ml-1 {
    margin-left: 4px
}

.ml-2 {
    margin-left: 8px
}

.ml-3 {
    margin-left: 12px
}

.ml-4 {
    margin-left: 16px
}

.ml-5 {
    margin-left: 20px
}

.mx-1 {
    margin-left: 4px;
    margin-right: 4px
}

.mx-2 {
    margin-left: 8px;
    margin-right: 8px
}

.mx-3 {
    margin-left: 12px;
    margin-right: 12px
}

.mx-4 {
    margin-left: 16px;
    margin-right: 16px
}

.mx-5 {
    margin-left: 20px;
    margin-right: 20px
}

.my-1 {
    margin-top: 4px;
    margin-bottom: 4px
}

.my-2 {
    margin-top: 8px;
    margin-bottom: 8px
}

.my-3 {
    margin-top: 12px;
    margin-bottom: 12px
}

.my-4 {
    margin-top: 16px;
    margin-bottom: 16px
}

.my-5 {
    margin-top: 20px;
    margin-bottom: 20px
}

/* ══════════════════════════════════════════════════════════
   ADMIN + AI COLOR TOKENS — :root (global, dùng cho fixed elements)
   Nguồn: admin-layout.css + ai-components.css
   Phải ở :root vì position:fixed elements không inherit từ .adm-shell
══════════════════════════════════════════════════════════ */

/* Light mode defaults */
:root {
    /* Admin color tokens */
    --color-background-primary: #ffffff;
    --color-background-secondary: #f9fafb;
    --color-background-tertiary: #f3f4f6;
    --color-background-hover: #f3f4f6;
    --color-background-info: #eff6ff;
    --color-background-danger: #fef2f2;
    --color-background-warning: #fffbeb;
    --color-background-success: #f0fdf4;
    --color-text-primary: #111827;
    --color-text-secondary: #6b7280;
    --color-text-tertiary: #9ca3af;
    --color-text-info: #1e40af;
    --color-text-danger: #991b1b;
    --color-text-warning: #92400e;
    --color-text-success: #166534;
    --color-border-primary: #e5e7eb;
    --color-border-secondary: #d1d5db;
    --color-border-tertiary: #e5e7eb;
    --color-border-danger: #fca5a5;
    --border-radius-md: 6px;
    --border-radius-lg: 10px;
    /* AI status tokens */
    --ai-radius: 8px;
    --ai-radius-lg: 12px;
    --ai-pending: #f59e0b;
    --ai-pending-bg: #fef3c7;
    --ai-pending-text: #92400e;
    --ai-processing: #3b82f6;
    --ai-processing-bg: #eff6ff;
    --ai-processing-text: #1e40af;
    --ai-completed: #22c55e;
    --ai-completed-bg: #f0fdf4;
    --ai-completed-text: #166534;
    --ai-rejected: #ef4444;
    --ai-rejected-bg: #fef2f2;
    --ai-rejected-text: #991b1b;
    --ai-failed: #f97316;
    --ai-failed-bg: #fff7ed;
    --ai-failed-text: #9a3412;
}

/* Dark mode — .adm-dark trên body/html để fix position:fixed elements */
html[data-theme="dark"],
.adm-dark {
    --color-background-primary: #1f2937;
    --color-background-secondary: #111827;
    --color-background-tertiary: #0f172a;
    --color-background-hover: #374151;
    --color-background-info: #172554;
    --color-background-danger: #450a0a;
    --color-background-warning: #451a03;
    --color-background-success: #052e16;
    --color-text-primary: #f9fafb;
    --color-text-secondary: #9ca3af;
    --color-text-tertiary: #6b7280;
    --color-text-info: #93c5fd;
    --color-text-danger: #fca5a5;
    --color-text-warning: #fcd34d;
    --color-text-success: #86efac;
    --color-border-primary: #374151;
    --color-border-secondary: #374151;
    --color-border-tertiary: #1f2937;
    --color-border-danger: #7f1d1d;
    --border-radius-md: 6px;
    --border-radius-lg: 10px;
    /* AI status tokens — dark */
    --ai-pending-bg: #451a03;
    --ai-pending-text: #fde68a;
    --ai-processing-bg: #1e3a5f;
    --ai-processing-text: #bfdbfe;
    --ai-completed-bg: #052e16;
    --ai-completed-text: #bbf7d0;
    --ai-rejected-bg: #450a0a;
    --ai-rejected-text: #fecaca;
    --ai-failed-bg: #431407;
    --ai-failed-text: #fed7aa;
}

/* Fallback: prefers-color-scheme dark cho ai tokens khi dùng ngoài AdminLayout */
@media (prefers-color-scheme: dark) {
    :root {
        --ai-pending-bg: #451a03;
        --ai-pending-text: #fde68a;
        --ai-processing-bg: #1e3a5f;
        --ai-processing-text: #bfdbfe;
        --ai-completed-bg: #052e16;
        --ai-completed-text: #bbf7d0;
        --ai-rejected-bg: #450a0a;
        --ai-rejected-text: #fecaca;
        --ai-failed-bg: #431407;
        --ai-failed-text: #fed7aa;
    }
}
