* {
    box-sizing: border-box;
}

:root {
    color-scheme: light;

    --bg-page: #f4f6f8;
    --bg-surface: #ffffff;
    --bg-hover: #f8fafc;
    --bg-active: #eff6ff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --border-color-soft: #f1f5f9;
    --chip-bg: #e5e7eb;
    --chip-bg-hover: #d1d5db;
    --chip-text: #374151;
    --alert-error-bg: #fee2e2;
    --alert-error-text: #991b1b;
    --alert-success-bg: #dcfce7;
    --alert-success-text: #166534;
    --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg-page: #0f172a;
    --bg-surface: #1e293b;
    --bg-hover: #243244;
    --bg-active: #1e3a5f;
    --text-primary: #e5e7eb;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --border-color-soft: #1e293b;
    --chip-bg: #334155;
    --chip-bg-hover: #475569;
    --chip-text: #e2e8f0;
    --alert-error-bg: #450a0a;
    --alert-error-text: #fecaca;
    --alert-success-bg: #052e16;
    --alert-success-text: #bbf7d0;
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.45);

    --fc-page-bg-color: #1e293b;
    --fc-neutral-bg-color: #243244;
    --fc-neutral-text-color: #94a3b8;
    --fc-border-color: #334155;
    --fc-button-text-color: #e5e7eb;
    --fc-button-bg-color: #334155;
    --fc-button-border-color: #334155;
    --fc-button-hover-bg-color: #475569;
    --fc-button-hover-border-color: #475569;
    --fc-button-active-bg-color: #2563eb;
    --fc-button-active-border-color: #2563eb;
    --fc-today-bg-color: rgba(37, 99, 235, 0.15);
    --fc-list-event-hover-bg-color: #243244;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
}

.site-header {
    background: #111827;
}

.logo-bar {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 18px 0 8px;
    text-align: center;
}

.logo {
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    text-decoration: none;
}

.navbar {
    padding: 10px 0 16px;
}

.nav-container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.nav-links,
.auth-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.auth-links {
    margin-left: auto;
}

.nav-links a,
.auth-links a,
.logout-link {
    color: #d1d5db;
    text-decoration: none;
    font-weight: 500;
}

.nav-links a:hover,
.auth-links a:hover,
.logout-link:hover,
.logo:hover {
    color: #ffffff;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 20px;
    padding: 0;
    background: transparent;
    color: #d1d5db;
    border: 1px solid #374151;
    border-radius: 999px;
}

.theme-toggle:hover {
    background: #1f2937;
    color: #ffffff;
}

.theme-toggle-icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-toggle-icon-moon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle-icon-sun {
    display: inline-flex;
}

.page-container {
    width: 90%;
    max-width: 1100px;
    margin: 40px auto;
}

.meeting-card,
.calendar-card,
.profile-card,
.meeting-detail-card,
.auth-form,
.page-form {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}

.meeting-card {
    margin-bottom: 20px;
}

.meeting-card h2 {
    margin-top: 0;
}

.meeting-card h2 a {
    color: var(--text-primary);
    text-decoration: none;
}

.meeting-card h2 a:hover {
    color: #2563eb;
}

.meeting-detail-card {
    padding: 32px;
}

.meeting-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
}

.action-btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.edit-btn {
    background: #2563eb;
    color: #ffffff;
}

.edit-btn:hover {
    background: #1d4ed8;
    color: #ffffff;
}

.delete-btn {
    background: #ef4444;
    color: #ffffff;
}

.delete-btn:hover {
    background: #dc2626;
    color: #ffffff;
}

.invite-btn {
    background: #10b981;
    color: #ffffff;
}

.invite-btn:hover {
    background: #059669;
    color: #ffffff;
}

.room-btn {
    background: #7c3aed;
    color: #ffffff;
}

.room-btn:hover {
    background: #6d28d9;
    color: #ffffff;
}

button,
.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    background: #2563eb;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

button:hover,
.btn:hover {
    background: #1d4ed8;
}

.btn.secondary {
    background: var(--chip-bg);
    color: var(--chip-text);
}

.btn.secondary:hover {
    background: var(--chip-bg-hover);
}

.btn.danger {
    background: #dc2626;
}

.btn.danger:hover {
    background: #b91c1c;
}

.inline-action-form {
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.auth-form p,
.page-form p,
.profile-form p {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    gap: 12px;
}

input,
textarea,
select {
    width: 100%;
    max-width: 500px;
    padding: 10px;
    margin-top: 6px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

textarea {
    min-height: 160px;
}

.footer {
    margin-top: 80px;
    padding: 24px 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.dashboard-header {
    margin-bottom: 24px;
}

.dashboard-header h1 {
    margin-bottom: 8px;
}

.dashboard-header p {
    color: var(--text-secondary);
}

.auth-links .logout-form {
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.auth-links .logout-link {
    background: transparent;
    padding: 0;
    color: #d1d5db;
    font: inherit;
    font-weight: 500;
    border: none;
    cursor: pointer;
}

.auth-links .logout-link:hover {
    background: transparent;
    color: #ffffff;
}

.message {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.message.error {
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
}

.message.success {
    background: var(--alert-success-bg);
    color: var(--alert-success-text);
}

.profile-container {
    display: flex;
    justify-content: center;
}

.profile-card {
    width: 100%;
    max-width: 700px;
    padding: 32px;
}

.profile-card h1 {
    margin-top: 0;
    text-align: center;
}

.profile-content {
    display: flex;
    align-items: center;
    gap: 40px;
    margin-top: 30px;
}

.profile-avatar {
    flex-shrink: 0;
}

.profile-avatar-img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.profile-info {
    flex: 1;
}

.profile-info p {
    margin: 0 0 14px;
}

.profile-form {
    margin-top: 24px;
}

.profile-form .form-group {
    margin-bottom: 22px;
}

.profile-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.profile-form textarea,
.profile-form input[type="file"] {
    width: 100%;
    max-width: 100%;
}

.profile-form input[type="checkbox"] {
    width: auto;
    margin: 0 8px 0 0;
}

.current-avatar {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.current-avatar a {
    color: #2563eb;
    word-break: break-all;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.current-avatar-box {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.current-avatar-box img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 50%;
}

.current-avatar-box a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.current-avatar-box a:hover {
    text-decoration: underline;
}

.profile-link {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
}

.profile-link:hover {
    color: #2563eb;
    text-decoration: none;
}

.auth-helper {
    margin-top: 18px;
    text-align: center;
    color: var(--text-secondary);
}

.auth-helper a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.auth-helper a:hover {
    text-decoration: underline;
}

.notifications-page {
    max-width: 800px;
    margin: 0 auto;
}

.notifications-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification-link {
    position: relative;
}

.notification-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.notification-badge-hidden {
    display: none !important;
}

.notification-item {
    display: block;
    padding: 16px 20px;
    background: var(--bg-surface);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.notification-item.unread {
    font-weight: 700;
    border-left: 5px solid #2563eb;
}

.notification-date {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}

.participant-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px;
}

.participant-info p {
    margin: 0 0 6px;
}

.participant-email {
    color: var(--text-secondary);
    font-size: 14px;
}

.status-badge {
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--chip-bg);
    color: var(--chip-text);
    font-size: 12px;
    font-weight: 600;
}

.participant-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.participant-action-form {
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.participant-btn {
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.accept-btn {
    background: #2563eb;
    color: #ffffff;
}

.accept-btn:hover {
    background: #1d4ed8;
}

.decline-btn {
    background: #ef4444;
    color: #ffffff;
}

.decline-btn:hover {
    background: #dc2626;
}

@media (max-width: 700px) {
    .profile-content {
        flex-direction: column;
        text-align: center;
    }

    .profile-info {
        width: 100%;
    }

    .participant-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .participant-actions {
        width: 100%;
    }
}

.password-field {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 545px;
}

.password-field input {
    flex: 1;
    max-width: none;
}

.password-toggle {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    padding: 0;
    margin-top: 6px;
    background: var(--chip-bg);
    color: var(--chip-text);
}

.password-toggle:hover {
    background: var(--chip-bg-hover);
}

.notification-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-toast {
    width: 320px;
    padding: 16px 18px;
    border-radius: 10px;
    background: #111827;
    color: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
    cursor: pointer;
    animation: notification-toast-in 0.25s ease-out;
}

.notification-toast-title {
    margin: 0 0 6px;
    font-weight: 700;
}

.notification-toast-message {
    margin: 0;
    color: #d1d5db;
    font-size: 14px;
}

.notification-toast-removing {
    opacity: 0;
    transform: translateX(20px);
    transition:
        opacity 0.25s ease,
        transform 0.25s ease;
}

@keyframes notification-toast-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

@media (max-width: 700px) {
    .notification-toast-container {
        left: 16px;
        right: 16px;
    }

    .notification-toast {
        width: 100%;
    }
}

.messenger-page {
    height: calc(100vh - 380px);
    min-height: 420px;
    display: flex;
}

.messenger-layout {
    display: flex;
    flex: 1;
    background: var(--bg-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.messenger-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.messenger-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
}

.messenger-sidebar-header h2 {
    margin: 0;
    font-size: 18px;
}

.messenger-conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color-soft);
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--bg-active);
}

.conversation-item.unread .conversation-participant {
    font-weight: 700;
}

.conversation-avatar {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 50%;
}

.conversation-item-body {
    flex: 1;
    min-width: 0;
}

.conversation-participant {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-date {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.conversation-unread-count {
    flex-shrink: 0;
    padding: 2px 7px;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
}

.messenger-empty-hint {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.messenger-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.messenger-panel-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.messenger-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
}

.messenger-back-link {
    display: none;
    color: #2563eb;
    text-decoration: none;
    font-weight: 700;
}

.messages-thread {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-item {
    max-width: 60%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
}

.message-item-sent {
    align-self: flex-end;
    background: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.message-item-received {
    align-self: flex-start;
    background: var(--bg-hover);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-sender {
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: 700;
    color: var(--sender-color, inherit);
    opacity: 0.8;
}

.message-content {
    margin: 0;
}

.message-date {
    margin: 4px 0 0;
    font-size: 11px;
    opacity: 0.7;
}

.message-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
}

.message-form textarea {
    flex: 1;
    max-width: none;
    height: 40px;
    min-height: 40px;
    max-height: 100px;
    margin-top: 0;
    padding: 8px 16px;
    border-radius: 20px;
    resize: none;
}

@media (max-width: 700px) {
    .messenger-page {
        height: calc(100vh - 260px);
        min-height: 360px;
    }

    .messenger-sidebar {
        width: 100%;
    }

    .messenger-back-link {
        display: inline-block;
    }

    .messenger-page-list .messenger-panel,
    .messenger-page-detail .messenger-sidebar {
        display: none;
    }

    .message-item {
        max-width: 85%;
    }
}

.room-online-users {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.room-chat-thread {
    max-height: 400px;
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    margin-top: 16px;
}

.room-chat-form {
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 12px 12px;
    margin-bottom: 16px;
}

.new-message-page {
    max-width: 800px;
    margin: 0 auto;
}

.new-message-search {
    max-width: 100%;
    margin-bottom: 18px;
}

.new-message-user-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.new-message-user-item {
    display: block;
    padding: 16px 20px;
    background: var(--bg-surface);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.new-message-user-item:hover {
    background: var(--bg-hover);
}

.calendar-event-content {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    overflow: hidden;
}

.calendar-event-content .fc-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event-avatars {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-left: 4px;
    flex-shrink: 0;
}

.calendar-avatar-wrapper {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: -6px;
}

.calendar-avatar-wrapper:first-child {
    margin-left: 0;
}

.calendar-avatar {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #ffffff;
}

.calendar-avatar-declined .calendar-avatar {
    filter: grayscale(100%);
    opacity: 0.7;
}

.calendar-avatar-declined::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(
        to top right,
        transparent 46%,
        #ef4444 48%,
        #ef4444 52%,
        transparent 54%
    );
}

.calendar-avatar-extra {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    border-radius: 50%;
    background: var(--chip-bg);
    color: var(--chip-text);
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
}
