/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

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

/* Header */
.header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.login-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-status {
    color: #6c757d;
    font-size: 0.9rem;
}

.date-time-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.current-date {
    color: #6c757d;
    font-size: 0.9rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: #0078d4;
    color: white;
}

.btn-primary:hover {
    background-color: #106ebe;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.hidden {
    display: none !important;
}

/* Authentication states */
.not-authenticated .requires-auth {
    display: none;
}

.authenticated .requires-login {
    display: none;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0078d4;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-link {
    color: #0078d4;
    text-decoration: none;
    font-weight: 500;
}

/* App Header for Room Pages */
.app-header {
    background: white;
    border-bottom: 1px solid #e9ecef;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #323130;
    margin: 0;
}

.header-link {
    color: inherit;
    text-decoration: none;
}

.header-link:hover {
    text-decoration: underline;
}

.header-room-info {
    text-align: right;
}

.header-room-info h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #323130;
}

.room-status-large {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
}

.status-indicator-large {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator-large.available {
    background: #107c10;
}

.status-indicator-large.upcoming {
    background: #ff8c00;
}

.status-indicator-large.busy {
    background: #d13438;
}

.status-indicator-large.error {
    background: #8764b8;
}

/* Room Page Styles */
.room-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
}

.room-view {
    margin-bottom: 2rem;
}

.room-view.hidden {
    display: none;
}

.current-status {
    margin-bottom: 2rem;
}

.status-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.current-event-info {
    font-size: 0.95rem;
    color: #605e5c;
}

.upcoming-events {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.events-list {
    margin-top: 1rem;
}

.event-item {
    padding: 1rem;
    border-left: 4px solid #0078d4;
    background: #f8f9fa;
    margin-bottom: 1rem;
    border-radius: 0 4px 4px 0;
}

.event-item.busy {
    border-left-color: #d13438;
}

.calendar-container {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.calendar-day {
    background: white;
    padding: 0.75rem;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.calendar-day.other-month {
    background: #f8f9fa;
    color: #6c757d;
}

.calendar-day.today {
    background: #e7f3ff;
}

.day-number {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.day-event {
    font-size: 0.7rem;
    padding: 0.125rem 0.25rem;
    background: #0078d4;
    color: white;
    border-radius: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.back-link:hover {
    text-decoration: underline;
}

.room-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #0078d4;
    color: white;
}

.btn-primary:hover {
    background: #106ebe;
}

.btn-secondary {
    background: #f3f2f1;
    color: #323130;
    border: 1px solid #d2d0ce;
}

.btn-secondary:hover {
    background: #edebe9;
}

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.loading-spinner.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0078d4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
    background: #fde7e9;
    color: #d13438;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #d13438;
    margin-bottom: 1rem;
}

.error-message.hidden {
    display: none;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #323130;
}

.date-display {
    font-size: 1.1rem;
    color: #605e5c;
    font-weight: 500;
}

.legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #605e5c;
}

/* Status Indicators */
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.available {
    background: #107c10;
}

.status-indicator.upcoming {
    background: #ff8c00;
}

.status-indicator.busy {
    background: #d13438;
}

.status-indicator.error {
    background: #8764b8;
}

/* Refresh Controls */
.refresh-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.last-updated {
    font-size: 0.9rem;
    color: #605e5c;
}

/* Rooms Container */
.rooms-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Room Card */
.room-card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border-left: 4px solid transparent;
}

.room-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.room-card.available {
    border-left-color: #107c10;
}

.room-card.upcoming {
    border-left-color: #ff8c00;
}

.room-card.busy {
    border-left-color: #d13438;
}

.room-card.error {
    border-left-color: #8764b8;
}

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

.room-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #323130;
    margin: 0;
}

.room-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.room-status.available {
    color: #107c10;
}

.room-status.upcoming {
    color: #ff8c00;
}

.room-status.busy {
    color: #d13438;
}

.room-meta {
    font-size: 0.9rem;
    color: #605e5c;
    margin-bottom: 1rem;
}

.room-meta span {
    margin-right: 1rem;
}

/* Room Link */
.room-link {
    display: inline-block;
    margin-top: 1rem;
    color: #0078d4;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.room-link:hover {
    color: #106ebe;
    text-decoration: underline;
}

/* Current Event */
.current-event {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.event-title {
    font-weight: 500;
    color: #323130;
    margin-bottom: 0.25rem;
}

.event-time {
    font-size: 0.8rem;
    color: #605e5c;
}

/* Next Events */
.next-events {
    border-top: 1px solid #edebe9;
    padding-top: 1rem;
}

.next-events h4 {
    font-size: 0.9rem;
    color: #605e5c;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.next-event {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f2f1;
}

.next-event:last-child {
    border-bottom: none;
}

.next-event-title {
    font-size: 0.9rem;
    color: #323130;
    margin-bottom: 0.25rem;
}

.next-event-time {
    font-size: 0.8rem;
    color: #605e5c;
}

/* Room Details Page */
.room-details-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.room-details-content.hidden {
    display: none;
}

.dashboard-content.hidden {
    display: none;
}

.room-info h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.room-info .room-status {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.room-meta {
    display: flex;
    gap: 2rem;
    color: #605e5c;
}

.view-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.current-month {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 150px;
    text-align: center;
}

/* Calendar View */
.calendar-view {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.calendar-header {
    background: #f8f9fa;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: #605e5c;
}

.calendar-day {
    background: white;
    min-height: 100px;
    padding: 0.5rem;
    position: relative;
}

.calendar-day.other-month {
    background: #f8f9fa;
    color: #a19f9d;
}

.calendar-day.today {
    background: #fff4ce;
}

.day-number {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.calendar-event {
    background: #0078d4;
    color: white;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.calendar-event.all-day {
    background: #107c10;
}

.calendar-event:hover {
    opacity: 0.8;
}

/* Events Sidebar */
.events-sidebar {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: fit-content;
}

.events-sidebar h3 {
    margin-bottom: 1rem;
    color: #323130;
}

.upcoming-events {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.upcoming-event {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #0078d4;
}

.upcoming-event-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #323130;
}

.upcoming-event-time {
    font-size: 0.9rem;
    color: #605e5c;
    margin-bottom: 0.25rem;
}

.upcoming-event-attendees {
    font-size: 0.8rem;
    color: #a19f9d;
}

/* Hidden elements */
.hidden {
    display: none !important;
}

/* Network notice */
.network-notice {
    text-align: center;
    padding: 3rem;
    background: #fefbf2;
    border: 1px solid #fed7aa;
    color: #c2410c;
    border-radius: 12px;
    margin: 2rem 0;
}

.network-notice h2 {
    color: #c2410c;
    margin-bottom: 1rem;
}

.network-notice p {
    margin: 0.5rem 0;
}

.network-notice .reload-section {
    margin-top: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .legend {
        gap: 1rem;
    }

    .rooms-container {
        grid-template-columns: 1fr;
    }

    .room-details-content {
        grid-template-columns: 1fr;
    }

    .events-sidebar {
        order: -1;
    }

    .refresh-controls {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .header .container {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .nav {
        width: 100%;
        justify-content: space-between;
    }

    .calendar-day {
        min-height: 80px;
        padding: 0.25rem;
    }

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