:root {
    --cap-blue: #001871;
    --cap-red: #ba0c2f;
    --cap-yellow: #ffcd00;
    --cap-gray: #4a5568;
    --cap-light-gray: #ccd1e3;
    --white: #ffffff;
    --black: #000000;
    --border-color: #ddd;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Ubuntu', sans-serif;
    background-color: var(--white);
    color: var(--black);
}

.calendar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styling */
.cap-header {
    background: linear-gradient(135deg, var(--cap-blue) 0%, #002855 100%);
    color: var(--white);
    padding: 20px 30px;
    border-radius: 8px 8px 0 0;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cap-logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-link a {
    color: var(--white);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 16px;
    border: 2px solid var(--white);
    border-radius: 4px;
    transition: all 0.3s;
}

.admin-link a:hover {
    background: var(--white);
    color: var(--cap-blue);
}

.cap-logo {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cap-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-text h1 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}

.header-text h2 {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    font-weight: 700;
    opacity: 0.9;
}

/* Controls Section */
.controls-section {
    background: var(--white);
    padding: 20px 30px;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: space-between;
}

.view-controls {
    display: flex;
    gap: 5px;
    background: var(--cap-light-gray);
    padding: 5px;
    border-radius: 6px;
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--cap-gray);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
}

.view-btn:hover {
    background: rgba(0, 63, 135, 0.1);
    color: var(--cap-blue);
}

.view-btn.active {
    background: var(--cap-blue);
    color: var(--white);
}

.filter-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-section label {
    font-weight: 600;
    color: var(--cap-gray);
}

#squadron-filter {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    min-width: 300px;
    cursor: pointer;
    transition: border-color 0.3s;
}

#squadron-filter:focus {
    outline: none;
    border-color: var(--cap-blue);
}

.navigation-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-btn, .today-btn {
    padding: 8px 16px;
    border: 2px solid var(--cap-blue);
    background: var(--white);
    color: var(--cap-blue);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
}

.nav-btn:hover, .today-btn:hover {
    background: var(--cap-blue);
    color: var(--white);
}

.current-period {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--cap-blue);
    min-width: 200px;
    text-align: center;
}

/* Calendar View */
.calendar-view {
    background: var(--white);
    padding: 30px;
    border-radius: 0 0 8px 8px;
    border: 1px solid var(--border-color);
    border-top: none;
    min-height: 600px;
}

/* Month View */
.month-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
}

.day-header {
    font-family: 'Rajdhani', sans-serif;
    background: var(--cap-blue);
    color: var(--white);
    padding: 12px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
}

.day-cell {
    background: var(--white);
    height: 120px;
    padding: 8px;
    position: relative;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.day-cell.other-month {
    background: #fafafa;
    opacity: 0.6;
}

.day-cell.today {
    background: #e6f2ff;
    border: 2px solid var(--cap-blue);
}

.day-number {
    font-weight: 700;
    color: var(--cap-gray);
    margin-bottom: 5px;
    flex-shrink: 0;
}

.day-cell.today .day-number {
    color: var(--cap-blue);
}

.event-item {
    background: var(--cap-blue);
    color: var(--white);
    padding: 4px 6px;
    margin: 2px 0;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    transition: transform 0.2s;
    word-break: break-word;
    min-height: 20px;
}

.event-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.event-item.squadron-event {
    background: var(--cap-red);
}

/* Multi-day event spanning styles */
.event-item.event-single {
    border-radius: 3px;
}

.event-item.event-start {
    border-radius: 3px 0 0 3px;
    margin-right: -2px;
}

.event-item.event-middle {
    border-radius: 0;
    margin-left: -2px;
    margin-right: -2px;
    opacity: 0.9;
}

.event-item.event-end {
    border-radius: 0 3px 3px 0;
    margin-left: -2px;
}

/* Week View */
.week-view {
    display: grid;
    grid-template-columns: 80px repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
}

.time-slot {
    background: var(--white);
    padding: 10px;
    min-height: 60px;
    border-bottom: 1px solid var(--border-color);
}

.time-label {
    background: var(--cap-light-gray);
    padding: 10px;
    text-align: right;
    font-size: 12px;
    color: var(--cap-gray);
    font-weight: 600;
}

/* Day View */
.day-view {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
}

/* List View */
.list-view {
    max-width: 900px;
    margin: 0 auto;
}

.event-list-item {
    background: var(--white);
    border-left: 4px solid var(--cap-blue);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 4px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.event-list-item:hover {
    transform: translateX(5px);
}

.event-list-item.squadron-event {
    border-left-color: var(--cap-red);
}

.event-date {
    color: var(--cap-blue);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
}

.event-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--black);
    margin-bottom: 5px;
}

.event-squadron {
    color: var(--cap-gray);
    font-size: 14px;
    margin-bottom: 8px;
}

.event-description {
    color: #666;
    line-height: 1.6;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: var(--white);
    margin: 10% auto;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.close {
    color: var(--cap-gray);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: var(--cap-red);
}

#modal-title {
    font-family: 'Rajdhani', sans-serif;
    color: var(--cap-blue);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

#modal-body {
    line-height: 1.8;
}

#modal-body p {
    margin-bottom: 10px;
}

#modal-body strong {
    color: var(--cap-blue);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }

    .navigation-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    #squadron-filter {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .calendar-container {
        padding: 10px;
    }

    /* Header responsive styles */
    .cap-header {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
    }

    .cap-logo-section {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        width: 100%;
    }

    .cap-logo {
        width: 60px;
        height: 60px;
    }

    .header-text h1 {
        font-size: 20px;
    }

    .header-text h2 {
        font-size: 14px;
    }

    .admin-link {
        display: flex;
        gap: 10px;
        justify-content: center;
        width: 100%;
    }

    .admin-link a {
        padding: 6px 12px;
        font-size: 14px;
    }

    /* Controls section responsive */
    .controls-section {
        padding: 15px;
        gap: 15px;
    }

    .view-controls {
        width: 100%;
        justify-content: center;
    }

    .view-btn {
        padding: 6px 12px;
        font-size: 14px;
        flex: 1;
    }

    .filter-section {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }

    .filter-section label {
        text-align: left;
        font-size: 14px;
    }

    #squadron-filter {
        width: 100%;
        min-width: auto;
        font-size: 14px;
    }

    /* Navigation controls responsive */
    .navigation-controls {
        width: 100%;
        justify-content: space-between;
    }

    .nav-btn, .today-btn {
        padding: 6px 12px;
        font-size: 14px;
    }

    .current-period {
        font-size: 16px;
        min-width: auto;
    }

    /* Calendar view responsive */
    .calendar-view {
        padding: 15px;
    }

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

    .day-header {
        font-size: 12px;
        padding: 8px 4px;
    }

    .day-cell {
        height: 80px;
        padding: 4px;
    }

    .day-number {
        font-size: 12px;
    }

    .event-item {
        font-size: 10px;
        padding: 2px 4px;
    }

    /* Week view responsive */
    .week-view {
        font-size: 12px;
    }

    .time-label {
        font-size: 10px;
        padding: 4px;
    }

    /* List view responsive */
    .list-view {
        font-size: 14px;
    }

    .event-card {
        padding: 12px;
    }

    /* Modal responsive */
    #event-modal .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10% auto;
        padding: 15px;
    }

    #event-modal h2 {
        font-size: 18px;
    }

    #event-modal p {
        font-size: 14px;
    }

    .close {
        font-size: 24px;
        right: 10px;
        top: 10px;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--cap-gray);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--cap-light-gray);
    border-top: 3px solid var(--cap-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.event-registration a {
    color: #0033a0;   /* CAP blue */
    font-weight: 600;
    text-decoration: underline;
}

.event-registration strong {
    color: #0033a0;
}

/* Footer */
.app-footer {
    background: var(--cap-light-gray);
    border-top: 1px solid var(--border-color);
    padding: 20px 30px;
    margin-top: 30px;
    text-align: center;
    color: var(--cap-gray);
    font-size: 14px;
}

.footer-content a {
    color: var(--cap-blue);
    text-decoration: none;
    font-weight: 600;
}

.footer-content a:hover {
    text-decoration: underline;
}

/* Minimalistic Embed Mode Styles */
body.embed-mode .calendar-container {
    padding: 0;
    margin: 0;
    max-width: 100%;
}

/* Hide header completely in embed mode */
body.embed-mode .cap-header {
    display: none;
}

/* Hide view controls and filter in embed mode, but keep navigation */
body.embed-mode .view-controls {
    display: none;
}

body.embed-mode .filter-section {
    display: none;
}

/* Keep navigation visible in embed mode */
body.embed-mode .controls-section {
    padding: 15px;
    justify-content: center;
}

body.embed-mode .calendar-view {
    border-radius: 0;
}

body.embed-mode .app-footer {
    display: none;
}
