:root {
    /* Official School Brand Colors */
    --brand-wine: #651d32;          /* PANTONE 7421C Red */
    --brand-green: #00c389;         /* PANTONE 3395C Green (Bright Accent) */
    --brand-green-dark: #005c3f;    /* Deep Forest Green (Text & Frame Match) */
    --brand-grey: #64748b;          /* Slate Grey Accent */
    
    /* Backgrounds */
    --bg: #fdfcfc;                  /* Soft, glare-free white canvas */
    --panel-bg: #f0f4fa;            /* Matches your calendar iframe perfectly */
    --text-color: #0f172a;          /* Deep slate typography */
    
    /* Shadows */
    --header-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --panel-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.06), 0 1px 3px 1px rgba(15, 23, 42, 0.03);
    --card-shadow-hover: 0 6px 14px rgba(15, 23, 42, 0.10);
}

* {
    box-sizing: border-box;
}

/* 0. Canvas Background */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text-color);
    margin: 0;
    padding: 18px 28px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 1. Header Bar */
header {
    width: 100%;
    margin-bottom: 20px;
    background: #ffffff;
    padding: 8px 20px;
    height: 90px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: var(--header-shadow); 
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
    position: relative;
    z-index: 100;
}

/* Zone 1: Logo */
.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.header-logo {
    height: 78px;
    width: auto;
    object-fit: contain;
}

/* Zone 2: Dynamic Greeting */
#greeting-container {
    text-align: center;
}

#auth-status {
    display: inline-block;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    color: #1e293b;
    line-height: 1.35;
}

#auth-status strong {
    color: var(--brand-wine);
    font-weight: 700;
}

.title-line {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--brand-grey);
    font-weight: 600;
}

/* Zone 3: Actions (SSO & Waffle) */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 2. Google Waffle Launcher */
.waffle-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    transition: background 0.2s;
}

.waffle-button:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.waffle-dropdown {
    display: none;
    position: absolute;
    top: 75px;
    right: 20px; 
    width: 320px;
    background-color: var(--panel-bg);
    border-radius: 20px;
    border: 1px solid #e2e8f0; 
    box-shadow: 0 10px 20px -2px rgba(15, 23, 42, 0.22), 0 4px 8px -2px rgba(15, 23, 42, 0.10);
    padding: 10px;
    z-index: 1000;
}

.waffle-dropdown.show {
    display: block;
}

.waffle-favorites-card {
    background-color: #ffffff;
    border-radius: 14px;
    padding: 12px 8px;
    border: 1px solid #f1f5f9;
}

.waffle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 4px;
}

.waffle-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    text-decoration: none;
    color: #1e293b;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 10px;
    transition: background 0.15s ease;
}

.waffle-favorites-card .waffle-item:hover {
    background-color: #f8fafc;
}

.waffle-item img {
    width: 36px;
    height: 36px;
    margin-bottom: 6px;
    object-fit: contain;
}

/* 3. DYNAMIC DASHBOARD LAYOUT */
.dashboard-layout {
    display: flex;
    gap: 20px;
    width: 100%;
    align-items: stretch;
    flex: 1;
    min-height: calc(100vh - 150px);
}

.left-panel {
    flex: 1 1 380px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Right Panel (Calendar) */
.right-panel {
    flex: 2 1 650px;
    background: var(--panel-bg); 
    padding: 0; 
    border-radius: 22px;
    border: none; 
    box-shadow: var(--panel-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}

.right-panel h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #334155;
}

/* Calendar Header Layout */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 12px 16px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background-color: #ffffff; 
    border: 1.5px solid #e2e8f0; 
    border-radius: 50px; 
    font-size: 0.88rem;
    color: #334155;
}

.badge-label {
    font-weight: bold;
    color: #5f6368;
    margin-right: 2px;
}

.week-icon {
    font-size: 1.1rem;
    color: #1a73e8; 
}

.calendar-wrapper {
    flex: 1;
    width: 100%;
    min-height: 600px;
    display: flex;
}

.calendar-wrapper iframe {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none !important; 
}

/* Outer Panel Boxes */
.panel-box {
    padding: 12px 14px 14px 14px;
    border-radius: 22px;
    box-shadow: var(--panel-shadow);
}

.panel-box h2 {
    margin: 4px 0 10px 6px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Zone Specific Backgrounds */
#public-zone { background: var(--panel-bg); }
#public-zone h2 { color: #334155; }

#student-zone { background: var(--brand-wine); display: none; }
#student-zone h2 { color: #ffffff; }

#staff-zone { background: var(--brand-green); display: none; }
#staff-zone h2 { color: var(--text-color); }

#error-zone { background: #fef2f2; display: none; }
#error-zone h2 { color: #991b1b; }

/* Inner Link Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding-top: 10px;
}

/* Keyframe Animation for Cards */
@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Individual Link Cards (Clean Floating Tiles) */
.card {
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid transparent; 
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04); 
    border-radius: 10px;
    text-decoration: none;
    color: #334155;
    font-weight: 600;
    font-size: 0.86rem;
    display: flex;
    align-items: center;
    /* Default to 1 so cards are never invisible on mobile Safari */
    opacity: 1;
    animation: slideUpFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hover States per Zone */
#public-links .card:hover {
    border-color: var(--brand-grey);
    color: var(--brand-grey);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.student-card:hover {
    border-color: var(--brand-wine);
    color: var(--brand-wine);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

.staff-card:hover {
    border-color: var(--brand-green-dark);
    color: var(--brand-green-dark);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

/* Tablets */
@media (max-width: 900px) {
    header {
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    
    .header-left, .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-layout {
        flex-direction: column;
        min-height: auto;
    }

    .calendar-wrapper {
        min-height: 500px;
    }
}

/* Mobile Devices */
@media (max-width: 600px) {
    body { padding: 12px 14px; }

    header {
        display: flex;
        flex-direction: column; 
        align-items: center;    
        position: relative;     
        padding: 16px 14px 12px 14px;
        gap: 16px; /* Adds breathing room between Logo and SSO Button */
        height: auto;
    }

    .header-left {
        width: 100%;
        display: flex;
        justify-content: center; 
    }

    .header-logo {
        height: 60px; 
    }

    /* Keep the SSO button in the normal stack and center it */
    .header-right {
        width: 100%;
        display: flex;
        justify-content: center; 
        align-items: center;
    }

    /* Pin ONLY the Waffle Button to the top-right corner */
    .waffle-button {
        position: absolute;
        top: 14px;
        right: 14px;
        background: #ffffff; /* Ensures it stays visible if it overlaps anything */
    }

    /* Keep the dropdown positioned safely below the waffle */
    .waffle-dropdown {
        top: 65px; 
        right: 14px;
        left: 14px; 
        width: auto;
    }

    #greeting-container {
        width: 100%;
        text-align: center;
        padding-top: 12px;
        border-top: 1px solid #e2e8f0;
    }

    #auth-status { font-size: 0.92rem; }

    .dashboard-layout { gap: 16px; }
    .panel-box { padding: 12px; }
    .grid { gap: 10px; }
    .calendar-header { padding: 12px 12px 8px 12px; }
}
