/* Insphere Classroom OS - Dashboard Styles */
:root {
    /* Color Palette */
    --primary-teal: #006D77;
    --primary-teal-dark: #005a63;
    --primary-teal-light: #e6f7f8;

    --accent-coral: #F28482;
    --accent-coral-hover: #d97371;

    --bg-body: #F7F8FC;
    --bg-white: #FFFFFF;

    --text-main: #1F2937;
    --text-muted: #6B7280;
    --text-light: #FFFFFF;

    --border-subtle: #E5E7EB;

    /* Spacing & Sizing */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-md: 12px;
    --radius-sm: 8px;

    /* Typography */
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: inherit;
}

/* Layout Shell */
.app-shell {
    display: flex;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-white);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: 100vh;
    overflow-y: auto;
    /* Fix for hidden bottom buttons on small screens */
    transition: width 0.3s ease;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-teal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.nav-group {
    margin-bottom: 1.5rem;
}

.nav-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--primary-teal-light);
    color: var(--primary-teal);
}

.nav-link svg {
    width: 20px;
    height: 20px;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    width: 100%;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 99;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    margin-right: 1rem;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        height: 100%;
        width: 260px;
        z-index: 1001;
        /* High z-index */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease-in-out;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .metric-card,
    .chart-card,
    .timeline-card,
    .announcements-card,
    .weather-card,
    .weather-half,
    .weather-full {
        grid-column: span 1;
    }

    /* Header padding adj */
    .top-header {
        padding: 0 0.75rem;
        /* Tighter padding */
    }

    /* Hide decorative text in header actions on mobile */
    .header-actions span {
        display: none;
    }

    /* Hide User Name/Role on mobile to save space */
    .user-profile>div:first-child {
        display: none;
    }

    /* Hide Tenant Name on mobile, keep icon */
    .tenant-selector span {
        display: none;
    }

    .tenant-selector {
        padding: 0.5rem;
        /* Reduce padding when text is gone */
    }
}

.tenant-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--bg-body);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn-primary {
    background-color: var(--primary-teal);
    color: var(--text-light);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.btn-primary:hover {
    background-color: var(--primary-teal-dark);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    background-color: var(--accent-coral);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* Scrollable Page Content */
.page-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.page-title-area {
    margin-bottom: 2rem;
}

.breadcrumbs {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.page-title {
    font-size: 1.75rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    grid-auto-rows: min-content;
    /* Two rows for now */
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Metric Cards */
.metric-card {
    grid-column: span 1;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-teal);
    margin: 0.5rem 0;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Graph/Large Cards */
.chart-card {
    grid-column: span 2;
    min-height: 300px;
}

.announcements-card {
    grid-column: span 2;
}

.weather-card {
    grid-column: span 1;
}

.timeline-card {
    grid-column: span 3;
}

/* Announcements List */
.announcement-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.announcement-item:last-child {
    border-bottom: none;
}

.announcement-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.tag-urgent {
    background: #fee2e2;
    color: #ef4444;
}

.tag-maintenance {
    background: #fef3c7;
    color: #92400e;
}

.tag-normal {
    background: #e0f2fe;
    color: #0284c7;
}

.announcement-title {
    font-weight: 500;
    margin: 0.25rem 0;
}

.announcement-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Timeline */
.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    align-items: flex-start;
}

.timeline-time {
    font-weight: 600;
    min-width: 60px;
    color: var(--primary-teal);
}

.timeline-marker {
    width: 2px;
    height: 100%;
    background: var(--border-subtle);
    position: relative;
    margin-top: 5px;
}

.timeline-marker::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-coral);
    border-radius: 50%;
    left: -4px;
    top: 0;
}

/* Weather Widget */
.weather-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.temp-large {
    font-size: 2.5rem;
    font-weight: 300;
}

.weather-half {
    grid-column: span 2;
}

.weather-full {
    grid-column: span 4;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-card,
    .timeline-card,
    .weather-full {
        grid-column: span 2;
    }

    .weather-half {
        grid-column: span 1;
    }
}

/* --- New Module Styles --- */

/* Data Tables */
.table-container {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-subtle);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background-color: #f9fafb;
}

/* Badges for Status */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-neutral {
    background: #f3f4f6;
    color: #374151;
}

/* Filter Bars */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    min-width: 250px;
}

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input,
    .form-control {
        width: 100% !important;
        min-width: 0;
    }

    .pagination-container {
        flex-direction: column;
        gap: 1rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    .page-title {
        font-size: 1.5rem;
    }
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.form-control:focus {
    outline: 2px solid var(--primary-teal);
    border-color: transparent;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    /* Time + 5 days */
    gap: 1px;
    background: var(--border-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cal-header,
.cal-cell {
    background: white;
    padding: 1rem;
    min-height: 100px;
}

.cal-header {
    background: #f9fafb;
    font-weight: 600;
    text-align: center;
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.cal-header.active-day {
    background: var(--primary-teal-light);
    color: var(--primary-teal);
    border-bottom: 2px solid var(--primary-teal);
}

.header-date {
    font-size: 0.75rem;
    font-weight: 400;
    margin-top: 0.2rem;
    color: var(--text-muted);
}

.cal-header.active-day .header-date {
    color: var(--primary-teal);
}

.cal-time-col {
    background: #f9fafb;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}


/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.page-link:hover {
    background-color: var(--primary-teal-light);
    color: var(--primary-teal);
    border-color: var(--primary-teal);
}

.page-link.active {
    background-color: var(--primary-teal);
    color: white;
    border-color: var(--primary-teal);
}

.page-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f3f4f6;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}

.modal-container {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Schedule Board */
.schedule-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .schedule-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .schedule-board {
        grid-template-columns: 1fr;
    }
}

/* --- Modern Vibrant Calendar Redesign --- */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* No borders, just gap for separation */
    gap: 0;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    /* Deep soft shadow */
    border: 1px solid rgba(0, 0, 0, 0.02);
    overflow: hidden;
    padding: 1rem;
}

.cal-header-cell {
    background: transparent;
    padding: 0.75rem 0.5rem;
    /* Reduced padding */
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.cal-day-cell {
    background: transparent;
    min-height: 90px;
    /* Reduced for single-page view */
    padding: 0.35rem;
    /* Tighter padding */
    position: relative;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    margin: 2px;
}

.cal-day-cell:hover {
    background: #f1f5f9;
    transform: scale(1.02);
}

.cal-day-number {
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: center;
    color: var(--text-main);
    font-size: 0.9rem;
    width: 28px;
    /* Slightly smaller */
    height: 28px;
    align-items: center;
    border-radius: 50%;
    align-self: flex-start;
}

.cal-day-cell.other-month .cal-day-number {
    color: #cbd5e1;
    font-weight: 400;
}

/* Today styling */
.cal-day-cell.today .cal-day-number {
    background: #0f172a;
    /* Dark bold contrast */
    color: white;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.3);
}

/* Vibrant Event Chips */
.event-chip {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    border-radius: 4px; /* Smaller radius for clean left-border look */
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.event-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

/* Color Coding - Vivid & Glassy */
.evt-academic {
    background: rgba(16, 185, 129, 0.15);
    /* Emerald tint */
    color: #047857;
}

.evt-holiday {
    background: rgba(239, 68, 68, 0.15);
    /* Red tint */
    color: #b91c1c;
}

.evt-activity {
    background: rgba(249, 115, 22, 0.15);
    /* Orange tint */
    color: #c2410c;
}

.evt-birthday {
    background: radial-gradient(circle at top left, #ede9fe, #ddd6fe);
    color: #6d28d9;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Add a visual indicator for busy days (3+ events) if we had JS logic, 
   but for now CSS only specific overrides can't count. 
   We'll treat the container as the modernist canvas. */

/* Responsive Calendar */
@media (max-width: 768px) {
    .calendar-grid {
        padding: 0.5rem;
        gap: 0;
        border-radius: 16px;
    }

    .cal-day-cell {
        min-height: 80px;
        padding: 0.25rem;
        margin: 1px;
        border-radius: 8px;
    }

    .cal-day-number {
        font-size: 0.8rem;
        width: 24px;
        height: 24px;
        margin-bottom: 0.25rem;
    }

    .event-chip {
        padding: 2px 4px;
        font-size: 0.65rem;
        border-radius: 4px;
    }

    .cal-header-cell {
        padding: 0.5rem 0.2rem;
        font-size: 0.65rem;
    }
}

/* --- Calendar 2-Column Layout --- */
.calendar-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    align-items: start;
}

.calendar-sidebar .card {
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    /* Softer shadow */
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: 8px;
    transition: background 0.1s;
}

.legend-item:hover {
    background: #f8fafc;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), 0 0 0 4px rgba(0, 0, 0, 0.05);
    /* Ring effect */
}

@media (max-width: 1024px) {
    .calendar-layout {
        grid-template-columns: 1fr;
    }

    .calendar-sidebar {
        margin-bottom: 2rem;
    }
}

/* Ensure button text visibility on Tablet/Desktop but maybe hide on very small mobile if needed */
@media (max-width: 480px) {
    .btn-text {
        display: none;
    }

    .btn-primary {
        padding: 0.6rem;
    }
}