body { font-family: Arial, sans-serif; padding: 20px; user-select: none; }
/* --- Access Control and Controls Layout --- */

 body.logged-in #controls {
    display: flex !important;
    flex-direction: column;
}

/* 1. General Container for Spacing */
#controls {
    margin-bottom: 20px; /* Space between controls and the grid */
    padding: 10px;
    border: 1px solid #ccc; /* Simple border for visual separation */
    border-radius: 4px;
}

/* 2. FLEXBOX for the Control Rows */
.control-row {
    display: flex;
    /* Aligns items vertically in the center of the row */
    align-items: center; 
    /* Adds space between the rows */
    margin-bottom: 10px; 
    /* Ensures items are spaced appropriately */
    gap: 15px; 
    padding: 5px 0;
}

/* 3. Simple Styling for Elements */
/* Ensures all buttons and inputs have a uniform, clean appearance */
.control-row input[type="text"],
.control-row button,
.control-row label {
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 4px;
}

/* 4. Styling for Buttons (Clean look) */
.action-button {
    cursor: pointer;
    border: 1px solid #aaa;
    background-color: #f0f0f0;
    transition: background-color 0.1s;
}

.action-button:hover {
    background-color: #e0e0e0;
}

/* Specific button styles (optional, based on your original colors) */
#submitScheduleButton {
    background-color: #008000; /* Green */
    color: white;
    border-color: #006400;
}

#loadCalendarButton {
    background-color: #4285f4; /* Google Blue */
    color: white;
    border-color: #3b76e1;
}

/* Ensures the calendar URL input takes up space */
#calendarUrl {
    flex-grow: 1; 
    min-width: 250px;
}

	/* rest */
    #saveStatus { margin-left: 20px; font-size: 0.9em; color: green; font-weight: bold; }
    #calendarMessage {
        margin-top: 5px;
        font-size: 0.9em;
        color: #4285f4;
        font-weight: bold;
    }

    /* Button Styling */
    .action-button {
        border: none;
        padding: 5px 10px;
        border-radius: 4px;
        cursor: pointer;
        font-weight: bold;
        transition: background-color 0.2s;
    }

    .btn-delete-all {
        background-color: #f44336;
        color: white;
    }
    .btn-delete-all:hover { background-color: #d32f2f; }

    .btn-delete-unassigned {
        background-color: #ff9800; /* Orange for targeted deletion */
        color: white;
    }
    .btn-delete-unassigned:hover { background-color: #f57c00; }

    /* --- Grid Container & Fixed Header --- */

    #grid-wrapper {
        position: relative;
        /* Limits height to enable vertical scrolling */
        max-height: 80vh;
        overflow-y: auto;
        margin-top: 20px;
        border: 1px solid #aaa;
       
        display: inline-block;
        touch-action: auto; /* Explicitly allow scrolling */
        overflow-x: auto; /* Ensures scrollbar appears when content overflows */
    width: 100%;
    -webkit-overflow-scrolling: touch; /* Improves scrolling performance on iOS */
    }

    #grid {
        position: relative;
        display: inline-block;
    }

    .row { display: flex; }

    /* Cell Styling */
    .cell {
        width: 120px;
        height: 45px;
        border: 1px solid #ccc;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        background: white;
        cursor: pointer;
    }
    .cell:hover { background: #f0f0f0; }

    /* Fixed Date Header */
    .header-row {
        position: sticky;
        top: 0;
        z-index: 50;
        background: #eee;
    }
    .header-row .cell {
        background: #eee;
        font-weight: bold;
        cursor: default;
    }

    /* Fixed Row Label Header */
    .label-cell {
        width: 80px;
        background: #f8f8f8;
        font-weight: bold;
        border-right: 2px solid #aaa;
        cursor: default;
        display:flex;
        align-items:center;
        justify-content:center;

        position: sticky;
        left: 0;
        z-index: 51;
    }

    /* Top-left corner (both sticky) */
    .header-row .label-cell {
        background: #eee;
        border-bottom: 1px solid #ccc;
        z-index: 52;
    }

    .group-end {
        border-bottom: 3px solid black !important;
    }

    /* --- Block Styling --- */
    .block {
        position: absolute;
        border: 1px solid #88b9e8;
        border-radius: 6px;
        padding: 4px;
        text-align: center;
        cursor: grab;
        box-shadow: 0 2px 6px rgba(0,0,0,0.15);
        overflow: hidden;
        box-sizing: border-box;
        transition: box-shadow 0.1s;
			  z-index: 10;
 	    touch-action: none;
    }
    .block span.name-line {
        position: absolute;
        left: 0;
        width: 100%;
        height: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0 5px;
        box-sizing: border-box;
    }

    .dragging {
			opacity: 0.75;
			cursor: grabbing;
			pointer-events: none;
			box-shadow: 0 8px 16px rgba(0,0,0,0.25);
			z-index: 100;
	}
    .resize-handle {
        position: absolute; right: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 10;
    }
    .resizing { cursor: col-resize; }

    /* Color Palette for Blocks */
    .color-blue { background: #d8ecff; border-color: #88b9e8; }
    .color-green { background: #e0ffe0; border-color: #90d490; }
    .color-yellow { background: #fffacd; border-color: #d4d490; }
    .color-red { background: #ffe0e0; border-color: #d49090; }

    /* Icons */
    .delete-icon, .edit-icon {
        position: absolute; top: 2px; width: 18px; height: 18px; border-radius: 50%;
        display: flex; align-items: center; justify-content: center; font-size: 12px;
        font-weight: bold; cursor: pointer; z-index: 20; line-height: 1; box-sizing: border-box;
        transition: background 0.1s; border: 1px solid transparent;
    }
    .delete-icon { right: 2px; background: rgba(255, 0, 0, 0.7); color: white; }
    .delete-icon:hover { background: red; border-color: #fff; }
    .edit-icon { right: 24px; background: rgba(0, 150, 0, 0.7); color: white; content: "\270E"; font-size: 14px; }
    .edit-icon:hover { background: green; border-color: #fff; }

/* --- 1. HIDE CONTROLS BY DEFAULT (Crucial starting point) --- */
/* This targets the main control container you defined previously. */
#controls {
    display: none !important;
}

/* --- 2. SHOW CONTROLS ONLY FOR AUTHORIZED ROLES --- */
/* WordPress body classes: role-author, role-editor, role-administrator */

/* Target Authors */
body.role-author #controls {
    display: flex !important;
}

/* Target Editors */
body.role-editor #controls {
    display: flex !important;
}

/* Target Administrators */
body.role-administrator #controls {
    display: flex !important;
}

