/**
 * Project Calendar - All Projects View
 * Clean styles for weekly and monthly calendar views
 */

/* ==================== DASHBOARD OVERFLOW FIX ==================== */
/* Prevent horizontal scrolling on the entire page */
body {
    overflow-x: hidden;
}

/* Constrain the dashboard grid container */
.dashlets.grid-stack {
    overflow: hidden;
    max-width: 100%;
}

/* Prevent dashlet content from overflowing its cell */
.grid-stack > .grid-stack-item > .grid-stack-item-content {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

/* Dashlet panel body should not push width */
.dashlets .panel-body {
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

/* ==================== MAIN CONTAINER ==================== */
.project-calendar-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
    background: #fff;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

/* ==================== TOOLBAR ==================== */
.project-calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-center {
    flex: 1;
    justify-content: center;
}

.period-label {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.project-calendar-toolbar .btn {
    padding: 5px 10px;
    font-size: 13px;
}

.project-calendar-toolbar .btn.active {
    background: #337ab7;
    border-color: #337ab7;
    color: #fff;
}

/* ==================== RESOURCE POOLS ==================== */
.resource-pools {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
    overflow: hidden;
    flex-wrap: wrap;
}

.resource-pool {
    flex: 1 1 0;
    min-width: 140px;
    max-width: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
}

.pool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
    font-size: 12px;
}

.pool-header i {
    margin-right: 5px;
}

.pool-count {
    color: #666;
    font-weight: normal;
}

.pool-items {
    padding: 8px;
    max-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
}

.pool-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    margin-bottom: 4px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    font-size: 12px;
    cursor: grab;
    transition: all 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.pool-item:hover {
    background: #e8f4fd;
    border-color: #337ab7;
}

.pool-item:active {
    cursor: grabbing;
}

.pool-item i {
    margin-right: 6px;
    color: #666;
}

.pool-item.worker-item i { color: #28a745; flex-shrink: 0; }
.pool-item.asset-item i { color: #007bff; flex-shrink: 0; }
.pool-item.task-item i { color: #ffc107; flex-shrink: 0; }

.pool-item .pool-item-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

/* Ensure tasks pool doesn't overflow */
.tasks-pool .pool-item {
    max-width: 100%;
    box-sizing: border-box;
}

.tasks-pool .pool-items {
    width: 100%;
}

.pool-empty {
    color: #999;
    font-size: 12px;
    text-align: center;
    padding: 10px;
}

/* ==================== CALENDAR CONTAINER ==================== */
.calendar-container {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px;
    max-width: 100%;
    box-sizing: border-box;
}

/* ==================== WEEKLY GRID TABLE ==================== */
.weekly-grid {
    width: 100%;
    overflow: hidden;
}

.weekly-grid-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
    max-width: 100%;
}

.weekly-grid-table th,
.weekly-grid-table td {
    border: 1px solid #ddd;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.weekly-grid-table thead th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.weekly-grid-table th.project-header {
    width: 15%;
    min-width: 0;
    text-align: left;
}

.weekly-grid-table th.day-header {
    min-width: 0;
}

.weekly-grid-table th.day-header.today {
    background: #d9edf7;
}

.weekly-grid-table th.day-header .day-name {
    font-weight: 600;
    display: block;
}

.weekly-grid-table th.day-header .day-date {
    font-size: 11px;
    color: #666;
    font-weight: normal;
}

.weekly-grid-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.weekly-grid-table tbody tr:hover {
    background: #f0f7ff;
}

.weekly-grid-table td.project-name-cell {
    background: #f9f9f9;
    font-weight: 500;
}

.weekly-grid-table .project-name-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.weekly-grid-table .project-color-indicator {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.weekly-grid-table .project-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    min-width: 0;
}

.weekly-grid-table td.day-cell {
    min-height: 40px;
    height: 40px;
    vertical-align: middle;
}

.weekly-grid-table td.day-cell.today {
    background: #eef7ff;
}

.weekly-grid-table td.day-cell.has-assignments {
    background: #efffef;
}

.weekly-grid-table .cell-content {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.weekly-grid-table .assignment-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
}

/* ==================== SIMPLE MONTHLY CALENDAR ==================== */
.simple-monthly-calendar {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.cal-header-cell {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.cal-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-cell {
    min-height: 80px;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 5px;
    background: #fff;
}

.cal-cell:nth-child(7n) {
    border-right: none;
}

.cal-cell.other-month {
    background: #fafafa;
}

.cal-cell.other-month .cal-day-num {
    color: #bbb;
}

.cal-cell.today {
    background: #e3f2fd;
}

.cal-cell.today .cal-day-num {
    background: #1976d2;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cal-cell.weekend {
    background: #fafafa;
}

.cal-day-num {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.cal-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.cal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    cursor: default;
}

.cal-dot:hover {
    transform: scale(1.3);
}

.cal-dot-more {
    font-size: 9px;
    color: #666;
}

/* ==================== DRAG AND DROP ==================== */
.weekly-grid-table td.day-cell.drag-over {
    background: #d4edda !important;
    box-shadow: inset 0 0 0 2px #28a745;
}

/* ==================== NO DATA ==================== */
.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

/* ==================== MONTH TABLE ==================== */
.month-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.month-table th {
    padding: 10px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
}

.month-table td.month-cell {
    border: 1px solid #ddd;
    padding: 5px;
    height: 80px;
    vertical-align: top;
    background: #fff;
}

.month-table td.month-cell.other {
    background: #f9f9f9;
}

.month-table td.month-cell.other .day-num {
    color: #aaa;
}

.month-table td.month-cell.today {
    background: #e3f2fd;
}

.month-table td.month-cell.weekend {
    background: #fafafa;
}

.month-table .day-num {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 5px;
}

.month-table .dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.month-table .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
/* Monthly Calendar with colored bars */
.mcal {
    position: relative;
    width: 100%;
    max-width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
    overflow: hidden;
}

.mcal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.mcal-header-cell {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.mcal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.mcal-day {
    min-height: 90px;
    border-right: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 4px;
    background: #fff;
    box-sizing: border-box;
}

.mcal-day:nth-child(7n) {
    border-right: none;
}

.mcal-day.other {
    background: #f8f8f8;
}

.mcal-day.other .mcal-day-num {
    color: #aaa;
}

.mcal-day.today {
    background: #e8f4fc;
}

.mcal-day.today .mcal-day-num {
    background: #1976d2;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mcal-day.weekend {
    background: #fafafa;
}

.mcal-day-num {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.mcal-bars {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mcal-bar {
    height: 6px;
    border-radius: 2px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.mcal-bar:hover {
    transform: scaleY(1.5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mcal-more {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
}

/* Popup */
.mcal-popup {
    display: none;
    position: absolute;
    background: #333;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mcal-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 15px;
    border: 5px solid transparent;
    border-top-color: #333;
}

/* Legend */
.mcal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 12px;
    border-bottom: 1px solid #ddd;
    background: #fafafa;
}

.mcal-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #333;
    cursor: default;
}

.mcal-legend-color {
    width: 14px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}
