/* --- DESIGN SYSTEM & RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #f0f2f5;         /* Light grey background like miraimil */
    --bg-row: #ffffff;          /* Pure white card backgrounds */
    --bg-card: #f8fafc;         /* Light grey card background for tasks */
    --border-color: #e2e8f0;     /* Thin slate border */
    --color-text: #1e293b;       /* Dark slate text */
    --color-text-muted: #64748b; /* Medium slate text */
    
    /* Standard Flat SaaS Colors */
    --mes-primary: #1976d2;     /* Royal Blue accent */
    --mes-green: #2ecc71;       /* Flat Green */
    --mes-yellow: #f1c40f;      /* Flat Yellow */
    --mes-red: #e74c3c;         /* Flat Red */
    --mes-blue: #3498db;        /* Flat Blue */
    --mes-gray: #e2e8f0;        /* Light grey track / Idle state */
    
    --font-primary: 'Noto Sans JP', sans-serif;
    --font-mono: 'Roboto Mono', 'Noto Sans JP', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--color-text);
    font-family: var(--font-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px;
}

/* --- HEADER (White with blue top-line, matching miraimil) --- */
.dashboard-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 8px 20px;
    background: #ffffff;
    border-top: 4px solid var(--mes-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
    min-height: 52px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.calendar-icon {
    font-size: 18px;
    color: var(--mes-primary);
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-display {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.header-center h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--mes-primary);
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    justify-content: flex-end;
}

.control-panel {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pager {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    gap: 8px;
}

.pager-text {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--mes-primary);
}

.btn-pager {
    background: transparent;
    border: none;
    color: var(--mes-primary);
    cursor: pointer;
    font-size: 12px;
}

.btn-pager:hover {
    color: #1e3a8a;
}

.btn-action {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #eff6ff;
    border-color: var(--mes-primary);
    color: var(--mes-primary);
}

/* --- MAIN MONITOR AREA --- */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding-right: 2px;
}

/* Scrollbar */
.dashboard-main::-webkit-scrollbar {
    width: 6px;
}
.dashboard-main::-webkit-scrollbar-track {
    background: transparent;
}
.dashboard-main::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* --- LOADING OVERLAY --- */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f1f5f9;
    border-top-color: var(--mes-primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

/* --- PROCESS ROW STYLING --- */
.monitor-row {
    display: grid;
    grid-template-columns: 270px 1fr 50px;
    background: var(--bg-row);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.2s;
}

.monitor-row.active {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}

/* --- ROW LEFT: INFO PANEL --- */
.row-info-panel {
    padding: 12px 15px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #fafafb;
}

.resource-label-container {
    margin-bottom: 8px;
}

.resource-code {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--color-text-muted);
    display: block;
    margin-bottom: 2px;
}

.resource-name-badge {
    display: inline-block;
    padding: 4px 20px 4px 10px;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    clip-path: polygon(0 0, 90% 0, 100% 100%, 0 100%);
    margin-left: -10px;
}

/* miraimil-like card headers (solid blues/yellows) */
.monitor-row.line-green .resource-name-badge {
    background: var(--mes-primary); /* Primary Blue */
}

.monitor-row.line-yellow .resource-name-badge {
    background: var(--mes-yellow);
    color: #1a202c;
}

.row-summary-gauge {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
}

.gauge-container {
    position: relative;
    width: 62px;
    height: 62px;
    flex-shrink: 0;
}

.gauge-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.gauge-track {
    fill: none;
    stroke: #f1f5f9;
    stroke-width: 8;
}

.gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease-out;
}

.gauge-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.gauge-percentage {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}

.metric-label {
    color: var(--color-text-muted);
}

.metric-value {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-text);
}

.metric-value.highlight {
    color: #1e3a8a; /* Darker blue for highlights */
}

.row-hours-info {
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
    font-size: 11px;
}

.row-hours-info .metric-label {
    display: block;
    margin-bottom: 2px;
}

/* --- ROW CENTER: TASKS GRID --- */
.row-tasks-panel {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 8px;
    overflow-x: auto;
    background-color: #fafbfc;
}

.task-card {
    min-width: 115px;
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.task-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-card .gauge-container {
    width: 52px;
    height: 52px;
    margin-bottom: 4px;
}

.task-card .gauge-percentage {
    font-size: 12px;
}

.task-status-text {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-muted);
    font-weight: 700;
}

/* Arrow divider */
.arrow-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 14px;
    padding: 0 4px;
    user-select: none;
}

/* Flow animation on arrows for active lines */
.monitor-row.active .arrow-flow {
    animation: light-arrow-flow 1.5s infinite linear;
}

.monitor-row.active .arrow-flow:nth-child(2) { animation-delay: 0s; }
.monitor-row.active .arrow-flow:nth-child(4) { animation-delay: 0.2s; }
.monitor-row.active .arrow-flow:nth-child(6) { animation-delay: 0.4s; }
.monitor-row.active .arrow-flow:nth-child(8) { animation-delay: 0.6s; }
.monitor-row.active .arrow-flow:nth-child(10) { animation-delay: 0.8s; }

/* --- ROW RIGHT: CONTROLLER PANEL --- */
.row-control-panel {
    border-left: 1px solid var(--border-color);
    background: #fafafb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
}

.btn-row-action {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--mes-primary);
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-row-action:hover {
    background: var(--mes-primary);
    border-color: var(--mes-primary);
    color: #ffffff;
}

/* --- FOOTER (Dark Navy Accent Bar) --- */
.dashboard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 20px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
    min-height: 32px;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.02);
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.status-indicator.online {
    background-color: var(--mes-green);
    box-shadow: 0 0 4px var(--mes-green);
    animation: status-blink 2s infinite alternate;
}

.status-text {
    font-size: 11px;
    color: var(--color-text-muted);
}

.copyright {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* --- KEYFRAME ANIMATIONS --- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes status-blink {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

@keyframes light-arrow-flow {
    0% {
        color: #cbd5e1;
    }
    50% {
        color: var(--mes-primary);
    }
    100% {
        color: #cbd5e1;
    }
}

/* Gentle pulse highlight for the active task card */
.task-card.active {
    border-color: #93c5fd;
    background: #eff6ff;
}
