/* ********************** Structure ********************** */
/* ********************** Structure ********************** */
/* ********************** Structure ********************** */
/* ********************** Structure ********************** */

/* Border box reset */
.tp-styles-structural .planner-view *,
.month-view *,
.upcoming-events * {
    box-sizing: border-box;
}

/* ********************** Planner View ********************** */

.tp-styles-structural .planner-view {
    max-width: 960px;
    margin: 20px auto;
    padding: 10px;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

.tp-styles-structural .planner-header h2 {
    margin-bottom: 20px;
}

.tp-styles-structural .planner-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width:900px;
}

.tp-styles-structural .planner-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.tp-styles-structural .planner-cell {
    padding: 4px;
    min-height: 90px;
    display:flex;
    flex-direction:column;
    align-content:center;
}

.tp-styles-structural .planner-cell-header {
    border: none;
    background:none;
    padding: 10px;
    min-height:10px;
}

.tp-styles-structural .planner-date {
    text-align: center;
    width: 20px;
  height: 20px;
    margin-bottom:4px;
  align-self: center;
  border-radius: 50px;
  display: flex;
  align-content: center;
  justify-content: center;
  line-height: 1;
    flex-direction: column;
}

/* Adjust the grid to include an extra column for week labels */
.tp-styles-structural .planner-week,
.tp-styles-structural .planner-week-header {
    display: grid;
    /* Create 8 columns: one for the week label, and 7 for the days */
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.tp-styles-structural .planner-week.weeks-label-active,
.tp-styles-structural .planner-week-header.weeks-label-active {
    display: grid;
    /* Create 8 columns: one for the week label, and 7 for the days */
    grid-template-columns: 50px repeat(7, 1fr);
    gap: 1px;
}

.tp-styles-structural .label-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tp-styles-structural .month-label-cell {
    display:flex;
    align-items: center;
    justify-content: center;
    width:100%;
    position:relative;
    height:100%;
}
.tp-styles-structural .month-label-cell span {
    transform: translate(-50%, -50%) rotate(-90deg);
    position: absolute;
    top: 50%;
    left: 50%;
}

.tp-styles-structural .week-label-cell {
    display:flex;
    align-items: center;
    justify-content: center;
    width:100%;
    position:relative;
}
.tp-styles-structural .week-label-cell span {
    transform: translate(-50%, -50%) rotate(-90deg);
    position: absolute;
    top: 50%;
    left: 50%;
}

.tp-styles-structural .planner-month-label {
    position: absolute;
    left: -50px; /* adjust based on desired placement */
    top: 50%;
    transform: translate(-100%, -50%) rotate(-90deg);
    transform-origin: left top;
}

.tp-styles-structural .week-label-placeholder {
    width: 50px;
}

/* ********************** Banner Events (Planner View) ********************** */

.tp-styles-structural .planner-banner-row {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    min-height: 24px;
    grid-column: 1 / -1;
}

.tp-styles-structural .planner-banner-row.weeks-label-active {
    margin-left: 51px; /* offset for the week label column */
}

.tp-styles-structural .planner-banner-title {
    width: 100%;
    text-align: center;
}

/* ********************** Month View ********************** */

.tp-styles-structural .month-view {
    max-width: 960px;
    margin: 20px auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap:20px;
}

.tp-styles-structural .month-header h2 {
    margin-bottom: 20px;
}

.tp-styles-structural .month-grid {
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
    padding: 8px;
}

.tp-styles-structural .weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 10px;
}

.tp-styles-structural .weekday {
    padding: 10px 0;
}

.tp-styles-structural .days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: auto;
    gap: 5px;
    min-width: 800px;
}

.tp-styles-structural .day {
    overflow: hidden;
    min-height: 80px;
}

.tp-styles-structural .day.empty {
    background: none;
    box-shadow: none;
}

.tp-styles-structural .day-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position:relative;
}

.tp-styles-structural .day-header {
  display:flex;
  align-items:center;
  justify-content:center;
    margin-bottom:4px;
}

.tp-styles-structural .day-number{
  display:flex;
  align-items:center;
  justify-content:center;
  width: 20px;
  height: 20px; 
}

.tp-styles-structural .day-events {
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.tp-styles-structural .day-event {
    padding: 2px 4px;
    margin-bottom: 1px;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tp-styles-structural .day-events-more {
    padding: 1px 4px;
    font-weight: 600;
    cursor: default;
    text-align: center;
}

/* ********************** Banner Events (Month View) ********************** */

.tp-styles-structural .month-banner-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    padding: 2px 8px;
    min-height: 24px;
}

.tp-styles-structural .month-banner-title {
    width: 100%;
    text-align: center;
}

.tp-styles-structural .day-event ul {
    padding:0 0px 0 12px;
}

.tp-styles-structural .day-event li {
    margin:0 0 4px 0;
}

.tp-styles-structural .month-nav {
    text-align: center;
    margin-bottom: 10px;
    display:flex;
    justify-content:center;
    align-items:center;
}

.tp-styles-structural .month-nav a {
    margin: 0 10px;
}


/* ********************** Event listing ********************** */

.tp-styles-structural .upcoming-events {
    max-width: 970px;
    margin: 20px auto;
    padding: 10px;
}

.tp-styles-structural .md-card {
    margin: 16px 0;
    overflow: hidden;
}

.tp-styles-structural .md-card-content {
    padding: 16px;
}

.tp-styles-structural .md-card-title {
    margin: 0;
}

.tp-styles-structural .md-card-subtitle {
    margin: 8px 0 0;
}



/* ********************** Fonts ********************** */
/* ********************** Fonts ********************** */
/* ********************** Fonts ********************** */
/* ********************** Fonts ********************** */


/* ********************** Planner View ********************** */

.tp-styles-type .planner-view {
    font-family: 'Roboto', sans-serif;
    font-size:12px;
}

.tp-styles-type .event-title {
    font-weight:700;
}

.tp-styles-type .planner-banner-title,
.tp-styles-type .month-banner-title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85em;
}

.tp-styles-type .planner-cell-header {
    font-weight: bold;
}

.tp-styles-type .planner-date {
    font-size: 0.9em;
    font-weight: 400;
}

.tp-styles-type .month-label-cell span {
    white-space: nowrap;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.75em;
    line-height:1;
}
.tp-styles-type .week-label-cell span {
    white-space: nowrap;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.75em;
    line-height:1;
}
.tp-styles-type .planner-month-label {
    font-size: 1em;
    font-weight: 400;
    white-space: nowrap;
}

/* Example styles for header cells */
.tp-styles-type .planner-cell-header {
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;

}

/* ********************** Month View ********************** */

.tp-styles-type .month-view {
    font-size: 12px;
}

.tp-styles-type .weekdays {
    text-align: center;
    font-weight: bold;
}

.tp-styles-type .weekday {
    font-size: 0.75em;
    text-transform: uppercase;
}

.tp-styles-type .day-number{
    text-align: right;
    font-size: 0.85em;
    font-weight: 400;
}

.tp-styles-type .day-event {
    font-size: 0.8em;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
}

.tp-styles-type .day-events-more {
    font-size: 0.75em;
    line-height: 1;
}

.tp-styles-type .month-nav a {
    text-decoration: none;
    font-weight: bold;
}

.tp-styles-type .month-nav a:hover {
    text-decoration: underline;
}

.tp-styles-type .current-month {
    font-size: 1.1em;
    font-weight: 600;
}


/* ********************** Event listing ********************** */

.tp-styles-type .md-card-title {
    font-size: 1.25em;
}

.tp-styles-type .md-card-subtitle {
    font-size: 0.875em;
}



/* ********************** Colors ********************** */
/* CSS Custom Properties for theme customisation.
 * Override these via the Custom CSS field in Settings > Term Planner > Advanced,
 * or in your theme stylesheet. See docs/REFACTOR-PLAN.md for details.
 */

:root {
    /* Primary / accent */
    --tp-primary: #3f51b5;

    /* Grid / chrome */
    --tp-grid-border: #e1e1e1;
    --tp-label-bg: #eeeeee;
    --tp-label-color: #424242;

    /* Cells */
    --tp-cell-bg: #ffffff;
    --tp-cell-color: #000;
    --tp-cell-inactive-bg: #f5f5f5;
    --tp-cell-inactive-color: #9e9e9e;
    --tp-cell-even-month-bg: #fcfcfc;
    --tp-cell-weekend-bg: #fbf4e3;
    --tp-cell-today-border: #e2f9d9;

    /* Pre/post term */
    --tp-prepost-opacity: 0.5;

    /* Banners */
    --tp-banner-bg: #e8eaf6;
    --tp-banner-color: #283593;
    --tp-banner-border: #c5cae9;

    /* Month view */
    --tp-weekday-color: #616161;
    --tp-day-bg: #fcfcfc;
    --tp-day-number-color: #757575;
    --tp-day-number-bg: #ffffff;
    --tp-day-event-bg: #f9f9f9;

    /* Event listing */
    --tp-card-bg: #fcfcfc;
    --tp-card-title-color: #333;
    --tp-card-subtitle-color: #777;

    /* Shared */
    --tp-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


/* ********************** Planner View ********************** */

.tp-styles-colors .planner-grid {
    background: var(--tp-grid-border);
    border: 4px solid var(--tp-grid-border);
}

.tp-styles-colors .planner-cell {
    background-color: var(--tp-cell-bg);
}

.tp-styles-colors .planner-cell-header {
    color: #fff;
}

.tp-styles-colors .planner-date {
    background: var(--tp-cell-even-month-bg);
}

.tp-styles-colors .label-container {
    background-color: var(--tp-label-bg);
    color: var(--tp-label-color);
}

.tp-styles-colors .month-label-cell {
    background: var(--tp-grid-border);
}

.tp-styles-colors .week-label-cell {
    background: var(--tp-grid-border);
}

.tp-styles-colors .planner-month-label {
    color: var(--tp-label-color);
}

.tp-styles-colors .planner-week-header {
    background: var(--tp-primary);
}

/* Colors for the calendar cells */
.tp-styles-colors .planner-cell.active {
    background-color: var(--tp-cell-bg);
    color: var(--tp-cell-color);
}

.tp-styles-colors .planner-cell.inactive {
    background-color: var(--tp-cell-inactive-bg);
    color: var(--tp-cell-inactive-color);
}

.tp-styles-colors .planner-cell-header {
    color: #fff;
    background: var(--tp-primary);
}

.tp-styles-colors .planner-cell.active.even-month {
    background: var(--tp-cell-even-month-bg);
}

.tp-styles-colors .planner-cell.active.day-sun,
.tp-styles-colors .planner-cell.active.day-sat,
.tp-styles-colors .planner-cell.pre-term.day-sun,
.tp-styles-colors .planner-cell.pre-term.day-sat,
.tp-styles-colors .planner-cell.post-term.day-sun,
.tp-styles-colors .planner-cell.post-term.day-sat {
    background: var(--tp-cell-weekend-bg);
}

.tp-styles-colors .planner-cell.active.today {
    border: 4px solid var(--tp-cell-today-border);
}

/* Pre-term and post-term week rows: reduced opacity */
.tp-styles-colors .planner-week.pre-term-week,
.tp-styles-colors .planner-week.post-term-week {
    opacity: var(--tp-prepost-opacity);
}

.tp-styles-colors .planner-banner-row,
.tp-styles-colors .month-banner-row {
    background-color: var(--tp-banner-bg);
    color: var(--tp-banner-color);
    border-bottom: 1px solid var(--tp-banner-border);
}

/* ********************** Month View ********************** */

.tp-styles-colors .weekdays {
    color: var(--tp-weekday-color);
}

.tp-styles-colors .day {
    background-color: var(--tp-day-bg);
    border-radius: 2px;
    box-shadow: var(--tp-shadow);
    padding: 5px;
}

.tp-styles-colors .day-number {
    color: var(--tp-day-number-color);
    background: var(--tp-day-number-bg);
    border-radius: 50px;
}

.tp-styles-colors .day-event {
    background-color: var(--tp-day-event-bg);
    border-radius: 2px;
}

/* ********************** Event listing ********************** */

.tp-styles-colors .md-card {
    background: var(--tp-card-bg);
    border-radius: 2px;
    box-shadow: var(--tp-shadow);
}

.tp-styles-colors .md-card-title {
    color: var(--tp-card-title-color);
}

.tp-styles-colors .md-card-subtitle {
    color: var(--tp-card-subtitle-color);
}

/* ********************** Term Planner Nav ********************** */

.term-planner-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    max-width: 960px;
    margin: 20px auto 0;
    padding: 10px;
}

.term-planner-nav .tpn-chip {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--tp-grid-border, #e1e1e1);
    background: var(--tp-cell-bg, #ffffff);
    color: var(--tp-label-color, #424242);
    font-size: 0.9em;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.term-planner-nav .tpn-chip:hover,
.term-planner-nav .tpn-chip:focus {
    background: var(--tp-label-bg, #eeeeee);
    color: var(--tp-primary, #3f51b5);
    border-color: var(--tp-primary, #3f51b5);
}

.term-planner-nav .tpn-chip.is-active {
    background: var(--tp-primary, #3f51b5);
    color: #fff;
    border-color: var(--tp-primary, #3f51b5);
}

.term-planner-nav .tpn-sep {
    display: inline-block;
    width: 1px;
    align-self: stretch;
    min-height: 1.2em;
    background: var(--tp-grid-border, #e1e1e1);
    margin: 0 4px;
}

@media (max-width: 480px) {
    .term-planner-nav {
        gap: 6px;
        padding: 8px;
    }
    .term-planner-nav .tpn-chip {
        padding: 5px 10px;
        font-size: 0.85em;
    }
}

