: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 */

    /* Deeper Tinted Zone Trays (Enhanced Contrast) */
    --wine-container: #f3dce2;      /* Deeper blush container */
    --green-container: #d4f2e7;     /* Deeper mint container */
    --grey-container: #f0f4f9;      /* MATCHES GOOGLE CALENDAR MATERIAL 3 EXACTLY */

    /* Canvas & Base Styles */
    --bg: #f9fafb;                   /* Very subtle off-white canvas */
    --text-color: #0f172a;           /* Deep slate typography */
    
    /* Soft Elevation Shadows */
    --panel-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.10), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --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: 16px 24px;
    min-height: 90px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: var(--panel-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 56px;
    width: auto;
    object-fit: contain;
}

header h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--brand-wine);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

#week-widget {
    font-size: 0.8rem;
    font-weight: 600;
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 5px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#auth-status {
    font-size: 0.85rem;
    color: var(--brand-grey);
    font-weight: 500;
    white-space: nowrap;
}

/* 2. Google Waffle Launcher */
.waffle-container {
    position: relative;
}

.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: 55px;
    right: 0;
    width: 320px;
    background-color: var(--grey-container);
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    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 (Outer Container - Using the exact same matched variable) */
.right-panel {
    flex: 2 1 650px;
    background: var(--grey-container); 
    padding: 0; /* Keeps iframe flush to the edges */
    border-radius: 22px;
    border: 1.5px solid var(--brand-grey);
    box-shadow: var(--panel-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Clips the iframe tightly to the rounded corners */
}

.right-panel h2 {
    padding: 16px 16px 8px 16px;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #334155;
    background: transparent;
}

/* Inner Calendar Wrapper (Invisible structure) */
.calendar-wrapper {
    flex: 1;
    width: 100%;
    min-height: 600px;
    background: transparent;
    border-radius: 0;
    border: none;
    box-shadow: none; 
    display: flex;
}

.calendar-wrapper iframe {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none !important; /* CRITICAL: Overrides Google's inline double border */
}

/* Outer Panel Boxes (Outer Container Trays for Left Panel) */
.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 Outer Backgrounds & Matching Borders */
#public-zone { 
    background: var(--grey-container); 
    border: 1.5px solid var(--brand-grey); /* Updated to match the overall theme border */
}
#public-zone h2 { color: #334155; }

#student-zone { 
    background: var(--wine-container); 
    border: 1.5px solid var(--brand-wine); 
}
#student-zone h2 { color: var(--brand-wine); }

#staff-zone { 
    background: var(--green-container); 
    border: 1.5px solid var(--brand-green-dark); 
}
#staff-zone h2 { color: var(--brand-green-dark); }

#error-zone { 
    background: #fef2f2; 
    border: 1.5px solid #ef4444; 
}
#error-zone h2 { color: #991b1b; }

#student-zone, #staff-zone, #error-zone {
    display: none;
}

/* Inner White Card Sheet (Expanded Padding) */
.grid {
    background: #ffffff;
    padding: 18px;
    border-radius: 16px;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

/* Keyframe animation */
@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Individual Link Cards */
.card {
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid transparent; 
    border-radius: 10px;
    text-decoration: none;
    color: #334155;
    font-weight: 600;
    font-size: 0.86rem;
    display: flex;
    align-items: center;
    
    opacity: 0;
    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);
}

/* Public Cards Hover */
#public-links .card { 
    border-left: 3.5px solid var(--brand-grey); 
}
#public-links .card:hover {
    background: #ffffff;
    border: 1px solid var(--brand-grey);
    border-left: 3.5px solid var(--brand-grey);
    color: var(--brand-grey);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

/* Student Cards Hover */
.student-card { 
    border-left: 3.5px solid var(--brand-wine); 
}
.student-card:hover {
    background: #ffffff;
    border: 1px solid var(--brand-wine);
    border-left: 3.5px solid var(--brand-wine);
    color: var(--brand-wine);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

/* Staff Cards Hover */
.staff-card { 
    border-left: 3.5px solid var(--brand-green-dark); 
}
.staff-card:hover {
    background: #ffffff;
    border: 1px solid var(--brand-green-dark);
    border-left: 3.5px solid var(--brand-green-dark);
    color: var(--brand-green-dark);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

@media (max-width: 900px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-layout {
        flex-direction: column;
        min-height: auto;
    }

    .calendar-wrapper {
        min-height: 500px;
    }
}