﻿/* --- 1. MAIN LAYOUT WRAPPER --- */
.main-layout-container {
    display: flex;
    flex-direction: row;
    /* Subtract Header/Nav height. If user has scrollbars, increase 150px to 200px */
    height: calc(100vh - 80px);
    overflow: hidden; /* Only internal panels scroll */
    border: 1px solid #ddd;
}

/* --- 2. MIDDLE PANEL (Flex 1 = grows to fill space) --- */
.middle-panel {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #ffffff;
    transition: all 0.3s ease;
    min-width: 0;
}

/* --- 3. RIGHT PANEL (Fixed Width or 0) --- */
.right-panel {
    width: 300px; /* Target width when open */
    background: #ffffff; /* Changed to cleaner white */
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.9rem; /* Reduced base font size for the panel */
}

    /* Logic for closing the panel */
    .right-panel.closed {
        width: 0px !important;
        opacity: 0;
        border-left: none;
        padding: 0;
    }

/* --- RIGHT PANEL HEADER STYLES (PROFESSIONAL ENHANCEMENTS) --- */
.panel-header-row {
    padding: 10px 15px;
    background: #f1f1f1;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
}

    
    .panel-header-row.professional-header {
        background: #f8f9fa; /* Lighter header background */
        border-bottom: 2px solid #e9ecef; /* Thicker, defined border */
        padding: 12px 20px;
    }

.data-header {
    font-weight: 600; /* Slightly heavier */
    font-size: 1.1rem;
    color: #343a40; /* Darker, more professional text */
    display: flex;
    align-items: center;
    gap: 8px;
}


/* Close Button Styling */
.close-btn.right-panal-close-btn {
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    color: #6c757d;
    transition: background-color 0.2s, color 0.2s;
}

    .close-btn.right-panal-close-btn:hover {
        background-color: #e9ecef;
        color: #343a40;
    }

    .close-btn.right-panal-close-btn span {
        font-size: 1.1rem;
    }


/* Lock Switch */
.lock-switch {
    display: flex;
    align-items: center;
    gap: 8px; /* Increased gap */
    cursor: pointer;
    font-size: 0.9rem; /* Slightly larger text */
    color: #6c757d; /* Professional grey */
    user-select: none;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

    .lock-switch:hover {
        background-color: #e9ecef; /* Subtle hover effect */
    }

.lock-label-text {
    font-weight: 500;
}

.switch-bg {
    width: 34px; /* Slightly wider switch */
    height: 18px; /* Slightly taller switch */
    background: #ced4da; /* Lighter grey for unlocked */
    border-radius: 10px;
    position: relative;
    transition: background 0.3s;
}

.switch-dot {
    width: 14px; /* Larger dot */
    height: 14px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); /* Added shadow for depth */
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left 0.3s;
}

.lock-switch.locked .switch-bg {
    background: #28a745; /* Bootstrap success green for locked */
}

.lock-switch.locked .switch-dot {
    left: 18px; /* Adjusted position for new width */
}

/* 4. DATA DISPLAY AREA STYLES (PROFESSIONAL ENHANCEMENTS - FONT & STACKING) */
.professional-display-area {
    padding: 15px; /* Reduced padding */
    overflow-y: auto;
}

/* Info Card Header */
.info-card-header {
    background: #e9f5ff; /* Light blue background */
    color: #004085; /* Dark blue text */
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    border-left: 5px solid #007bff; /* Accent border */
    font-size: 1rem;
    font-weight: 600;
}



/* Data Section Cards */
.data-section-card {
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px; /* Reduced internal padding */
    background: #f8f9fa;
}

.section-title {
    font-size: 1rem; /* Slightly reduced */
    color: #343a40;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 6px; /* Reduced padding */
    margin-top: 0;
    margin-bottom: 10px; /* Reduced margin */
    font-weight: 600;
}

/* Data Table Styling for Stacked Label/Value */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem; /* Reduced table font size */
    table-layout: fixed;
}

    .data-table tr {
        display: block; /* Force table rows to stack vertically */
        margin-bottom: 8px; /* Space between label/value pairs */
        border-bottom: none !important;
    }

        .data-table tr:last-child {
            margin-bottom: 0;
        }

.data-label {
    font-weight: 600;
    color: #495057;
    padding: 0;
    width: 100%;
    display: block; /* Stacks label above value */
    font-size: 0.8rem; /* Label font size */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-value {
    color: #343a40;
    text-align: left; /* Aligns value under the label */
  /*  font-weight: bold;*/
    padding: 2px 0 0 0; /* Space below label */
    display: block; /* Stacks value below label */
    font-size: 0.7rem; /* Label font size */
}


/* Base style for icon-only buttons */
.action-btn.icon-only {
    width: 30px; /* Fixed width */
    height: 30px; /* Fixed height for circle */
    padding: 0; /* Remove padding */
    justify-content: center; /* Center icon horizontally */
    align-items: center; /* Center icon vertically */
    display: flex; /* Override previous flex settings if needed */
    font-size: 0.9rem; /* Set icon size */
    flex-shrink: 0; /* Prevents button from shrinking */
}

/* Specific class for round pill shape */
.action-btn.rounded-pill {
    border-radius: 50%; /* Makes the button a circle/pill shape */
}

/* Ensure the icon is centered and visible */
.action-btn.icon-only .action-btn-icon {
    font-size: 0.8rem; /* Fine-tune icon size */
    margin: 0;
    line-height: 1; /* Ensure icon sits correctly */
}

/* You must remove the previous "action-btn-icon" styles that used Unicode characters.
   The original .action-btn styles need to be adapted: */

.action-btn {
    /* Kept existing button styles, adjusted for icon-only */
    border: 1px solid #ccc;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

/* Re-apply colors for the new structure */
.action-btn.add {
    background-color: #28a745;
    color: white;
    border-color: #218838;
}

    .action-btn.add:hover {
        background-color: #218838;
    }

.action-btn.remove {
    background-color: #dc3545;
    color: white;
    border-color: #c82333;
}

    .action-btn.remove:hover {
        background-color: #c82333;
    }

.action-btn.edit {
    background-color: #ffc107;
    color: #343a40; /* Dark text for yellow button */
    border-color: #e0a800;
}

    .action-btn.edit:hover {
        background-color: #e0a800;
    }


/* Action Button Styles */
.card-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    justify-content: flex-end; /* Align buttons to the right */
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 80px);
    gap: 5px;
    margin-bottom: 10px;
}

.cell-disabled {
    aspect-ratio: 1;
    background-color: #c9a1a1;
    border: 1px solid #bbb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 4px;
    cursor: pointer; /* Added cursor */
}
    .cell-disabled:hover {
        background-color: #d0d0d0;
    }

.cell {
    aspect-ratio: 1;
    background-color: #e0e0e0;
    border: 1px solid #bbb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 4px;
    cursor: pointer; /* Added cursor */
}

    .cell:hover {
        background-color: #d0d0d0;
    }

.dual-cell-disabled {
    aspect-ratio: 1;
    background-color: #c9a1a1;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    padding: 15px 3px 3px 3px;
    gap: 3px;
    position: relative;
    cursor: pointer;
}

    .dual-cell-disabled:hover {
        background-color: #eee;
    }


.dual-cell {
    aspect-ratio: 1;
    background-color: #f8f8f8;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    padding: 15px 3px 3px 3px;
    gap: 3px;
    position: relative;
    cursor: pointer;
}

    .dual-cell:hover {
        background-color: #eee;
    }

.station-header-label {
    position: absolute;
    top: 2px;
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
    color: #888;
    font-weight: bold;
}

.dual-sub-slot {
    flex: 1;
    background: #eaeaea;
    border: 1px dashed #bbb;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pallet {
    width: 70%;
    height: 50%;
    background-color: #e67e22;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
}

.cart-map-item {
    width: 80%;
    height: 70%;
    background-color: #8e44ad;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.7rem;
}

.arm-row-container {
    display: flex;
    gap: 20px;
    width: 100%;
    margin-top: 20px;
    flex-wrap: wrap;
}

.arm-station {
    flex: 1;
    min-width: 300px;
    border: 2px dashed #27ae60;
    background: #f8fff8;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px 100px 10px 100px
}

    .arm-station:hover {
        background-color: #f0fdf0;
    }



.slots-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.slot {
    flex: 1;
    aspect-ratio: 1.2;
    background: #eaeaea;
    border: 1px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.docks-container {
    display: flex;
    gap: 12px;
}

.dock-station-unit {
    flex: 1;
    border: 1px solid #ccc;
    padding: 6px;
    border-radius: 6px;
    background: #fafafa;
}

.dock-label {
    text-align: center;
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 4px;
}

.dock-slot {
    height: 40px;
    background: #eaeaea;
    border: 1px dashed #bbb;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.station-id {
    position: absolute;
    bottom: 1px;
    font-size: 0.7rem;
    color: #555;
    font-weight: bold;
}

.sub-slot-id {
    position: absolute;
    font-size: 0.6rem;
    color: #777;
    bottom: 1px;
    right: 3px;
}

.operation-list {
    margin-top: 15px;
}

.op-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}

    .op-item:hover {
        background-color: #f9f9f9;
    }

.status-running {
    color: green;
    font-weight: bold;
}

.status-stopped {
    color: red;
    font-weight: bold;
}

.zones-flex-container {
    display: grid; /* use grid layout */
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    align-items: start;
}

.group-name {
    font-size: 0.7rem;
    color: #555;
    font-weight: bold;
}

/* The wrapper we added in the HTML */
.zone-group-card {
    position: relative;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px 10px 10px 10px; /* more top padding */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transform: scale(0.75);
    transform-origin: top left;
    width: 133%;
}

/* Title on the border */
.group-title {
    position: absolute;
    top: -12px; /* move text on the border */
    left: 15px; /* padding left */
    background: #fff; /* background to cover border */
    padding: 0 8px;
    font-weight: bold;
    font-size: 14px;
    color: #666;
}



/* --- ADJUSTING INNER COMPONENTS --- */

.zone-group-card .zones-flex-container {
    display: flex; /* Keep internal logic as flex */
    flex-wrap: nowrap; /* Prevent wrapping inside the card */
    gap: 50px;
}

.timer-span {
    color: #343a40;
    text-align: left; /* Aligns value under the label */
    /*  font-weight: bold;*/
    padding: 2px 0 0 0; /* Space below label */
    display: block; /* Stacks value below label */
    font-size: 0.7rem; /* Label font size */
    margin-top:10px
}

/*AGF zone Components*/
/* The main container for the Robot */
.agv-robot-unit {
    position: relative;
    width: 240px; /* Adjust based on your grid */
    margin: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s;
}

    .agv-robot-unit:hover {
        transform: translateY(-3px);
    }

/* The Title (ID) floating above or on the robot */
.agv-name-badge {
    background-color: #333;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: -10px; /* Overlap the body slightly */
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* The Robot Body (Chassis) */
.agv-chassis {
    background: linear-gradient(to bottom, #f0f0f0, #d9d9d9);
    border: 2px solid #999;
    border-radius: 8px;
    width: 100%;
    min-height: 200px;
    padding: 15px 5px 5px 5px; /* Top padding for the badge overlap */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* The Cargo Deck (Where Pallets/Carts go) */
.agv-deck {
    background-color: rgba(0,0,0,0.05);
    border: 1px dashed #ccc;
    border-radius: 4px;
    width: 90%;
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4px;
    gap: 4px; /* Space between dual carts */
}

/* Interactive Elements styling */
.cargo-item {
    cursor: pointer;
    text-align: center;
    width: 100%;
}

.pallet-box {
    background-color: #e67e22; /* Wood color */
    color: white;
    border: 1px solid #8d6e63;
    padding: 5px;
    font-weight: bold;
    border-radius: 3px;
    box-shadow: 0 2px 2px rgba(0,0,0,0.1);
}

.cart-box {
    background-color: #8e44ad; /* Blue cart */
    color: white;
    border: 1px solid #0288d1;
    padding: 4px;
    font-size: 0.7rem;
    border-radius: 3px;
    flex: 1; /* Distribute space for dual carts */
}

.cart-empty {
    background-color: #e0e0e0;
    color: #9e9e9e;
    border: 1px dashed #bdbdbd;
}

.status-text {
    display: block;
    font-size: 0.6rem;
    margin-top: 2px;
}

/*End of AGF componet*/

@media (max-width: 768px) {

    /* Stack layout vertically on mobile */
    .main-layout-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    /* Middle gets full width */
    .middle-panel {
        width: 100%;
        padding: 15px;
        overflow: visible;
    }

    /* Right panel moves DOWN and becomes full width */
    .right-panel {
        width: 100% !important;
        border-left: none;
        border-top: 1px solid #ddd;
        opacity: 1 !important;
        padding: 10px;
        white-space: normal;
    }

        /* Closed state on mobile simply hides the panel */
        .right-panel.closed {
            display: none;
        }

    /* Zone layout: 1 column instead of 2 */
    .zones-flex-container {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    /* Zone card scale reset */
    .zone-group-card {
        transform: scale(1);
        width: 100%;
    }

    /* Grid smaller for mobile */
    .grid {
        grid-template-columns: repeat(4, 60px);
    }

    .cell,
    .dual-cell {
        max-width: 70px;
    }

    /* Arm station spacing smaller */
    .arm-station {
        min-width: unset;
        margin: 10px 0;
    }
}
