@import url("theme.css");

/* ── Calendar Container ── */
.calendar-container {
    padding: 1rem 1.25rem 2rem;
    max-width: 100%;
    box-sizing: border-box;
}

/* ── Subnav Toolbar ── */
.cal-subnav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--secondary-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-wrap: wrap;
    min-height: 50px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 100;
}

.cal-subnav-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    flex-wrap: wrap;
}

.cal-subnav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── View Toggle Pill ── */
.view-pill {
    display: inline-flex;
    background: var(--primary-bg);
    border-radius: 24px;
    padding: 3px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}

.view-pill-btn {
    border: none;
    background: transparent;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.22s ease;
    color: var(--text-color);
    opacity: 0.55;
    white-space: nowrap;
}

.view-pill-btn.active {
    background: var(--accent-color);
    color: #fff;
    opacity: 1;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.view-pill-btn:hover:not(.active) {
    opacity: 0.8;
    background: var(--secondary-bg);
}

/* ── Date Navigation ── */
.date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.date-sep {
    font-size: 0.8rem;
    opacity: 0.45;
    color: var(--text-color);
}

.nav-btn {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: var(--section-bg);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: background 0.18s;
    font-size: 0.78rem;
}

.nav-btn:hover {
    background: var(--secondary-bg);
}

input[type="date"] {
    font-size: 0.78rem;
    height: 30px;
    padding: 2px 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: var(--section-bg);
    color: var(--text-color);
    outline: none;
}

.btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #4caf50;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    white-space: nowrap;
}

.btn-upload:hover {
    background: #43a047;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.btn-icon-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--text-color) !important;
    text-decoration: none !important;
    font-size: 0.95rem;
    transition: background 0.18s;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.btn-icon-round:hover {
    background: var(--secondary-bg);
}

/* ── Calendar Grid ── */
#calendar {
    display: grid;
    grid-template-columns: repeat(var(--calendar-cols, 7), 1fr);
    gap: 8px;
}

.week-row {
    display: contents;
}


/* ── Plan View Cells ── */
.day-cell-plan {
    background: var(--section-bg);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    transition: box-shadow 0.2s ease;
    height: 200px;
}

.day-cell-plan:hover {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.11);
}

.day-cell-plan.is-today {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

/* Date label – plan view */
.date-label {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1px;
    padding-bottom: 5px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--secondary-bg);
}

.date-month {
    font-size: 0.62rem;
    color: var(--text-color);
    opacity: 0.4;
    font-weight: 500;
}

.date-num {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}

.date-dow {
    font-size: 0.62rem;
    font-weight: 500;
    color: var(--text-color);
    opacity: 0.55;
    margin-left: 2px;
    align-self: flex-end;
    padding-bottom: 2px;
}

.is-today .date-num {
    background: var(--accent-color);
    color: #fff;
}

/* Plan meal items */
.meal-detail {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 6px;
    border-radius: 6px;
    background: var(--primary-bg);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
}

.meal-detail:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.meal-detail.meal-breakfast { border-left: 3px solid #ff8f00; }
.meal-detail.meal-lunch     { border-left: 3px solid #0288d1; }
.meal-detail.meal-dinner    { border-left: 3px solid #5e35b1; }

.meal-icon {
    flex-shrink: 0;
    font-size: 0.75rem;
    width: 14px;
    text-align: center;
}

.icon.morning { color: #ffd700; }
.icon.noon    { color: #32cd32; }
.icon.night   { color: #745399; }

.meal-title {
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    font-size: 0.72rem;
    line-height: 1.3;
}

/* ── Actual View Cells ── */
.day-cell-actual {
    background: var(--section-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    display: flex;
    flex-direction: column;
    height: 370px;
}

.day-cell-actual:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
}

.day-cell-actual.is-today {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

/* Date label – actual view */
.day-cell-actual .date-label {
    padding: 8px 10px 7px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-color);
    border-bottom: 1px solid var(--secondary-bg);
    justify-content: flex-start;
    gap: 0;
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Meal type section label */
.meal-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 5px 10px 1px;
    color: var(--text-color);
    opacity: 0.42;
    flex-shrink: 0;
}

/* Actual meal container */
.meal-container {
    display: flex;
    flex-direction: column;
    padding: 0 8px 6px;
    gap: 3px;
    flex-shrink: 0;
}

.meal-thumb {
    width: 100%;
    height: 88px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.meal-container span {
    font-size: 0.7rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    opacity: 0.8;
}

/* Empty cell */
.empty-cell-prompt {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    opacity: 0.12;
    font-size: 2rem;
    transition: opacity 0.2s;
}

.day-cell-actual:hover .empty-cell-prompt {
    opacity: 0.28;
}

/* ── Settings Dialog ── */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 0;
}

.settings-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--text-color);
    gap: 16px;
}

.settings-label input,
.settings-label select {
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.85rem;
    background: var(--section-bg);
    color: var(--text-color);
    width: 90px;
}

/* ── Loading Overlay ── */
#loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 9999;
    color: #fff;
    text-align: center;
    padding-top: 25%;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cal-spin 0.8s linear infinite;
    display: inline-block;
    margin-bottom: 12px;
}

@keyframes cal-spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ── */
@media (max-width: 767px) {
    #calendar {
        grid-template-columns: 1fr !important;
    }
    .calendar-container {
        padding: 0.5rem;
    }
    .day-cell-plan {
        height: auto !important;
        min-height: 120px;
    }
    .day-cell-actual {
        height: auto;
        min-height: 180px;
    }
    .cal-subnav {
        padding: 6px 10px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    #calendar {
        grid-template-columns: repeat(3, 1fr);
    }
    .day-cell-plan  { height: 250px; }
    .day-cell-actual { height: 410px; }
}
