:root {
    --primary-color: #3333FF;
    --dim-color: #1A1A4A;
    --bg-color: #202124;
    --surface-color: #292a2d;
    --border-color: #3c4043;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --hover-color: #35363a;
    --avatar-bg: #5f6368;
    --unread-bg: #0e0e0f;
    --unread-text: #ffffff;
    --input-bg: #484b50;
    --flyout-input-bg: #606368;
    --event-bg: #3c4043;
}

body {
    margin: 0;
    font-family: "Lucida Console", Monaco, monospace;
    background-color: var(--bg-color);
    overflow: hidden;
    color: var(--text-primary);
    font-size: 13px;
}

/* Toolbar */
#toolbar-wrapper {
    height: 64px;
    width: 100%;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-sizing: border-box;
}

#footer-wrapper {
    height: 64px;
    width: 100%;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    box-sizing: border-box;
}

.checkbox-wrapper {
    width: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    margin-left: 20px;
    gap: 16px;
}

.icon-btn {
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.1s;
    background-color: transparent;
    border: none;
    color: var(--text-primary);
}

.icon-btn svg {
    fill: currentColor;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.icon-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Search */
.search-container {
    position: relative;
    margin-left: 40px;
    flex: 1;
    max-width: 480px;
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border-radius: 8px;
    padding: 4px 8px;
}

#search-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px;
    flex: 1;
    font-family: inherit;
    outline: none;
    font-size: 14px;
}

#search-clear-btn {
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-weight: bold;
    font-size: 16px;
    margin-right: 4px;
}

#search-clear-btn:hover {
    color: var(--text-primary);
}

.search-options-btn {
    width: 24px;
    height: 24px;
    cursor: pointer;
    fill: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.1s;
}

.search-options-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    fill: var(--text-primary);
}

#search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 20;
    margin-top: 4px;
    border-radius: 8px;
    padding: 12px;
    box-sizing: border-box;
    flex-direction: column;
    gap: 8px;
}

#search-dropdown.open {
    display: flex;
}

.search-line {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.search-label {
    color: var(--text-secondary);
    font-weight: bold;
    font-size: 12px;
    white-space: nowrap;
    min-width: fit-content;
}

.search-field {
    background-color: var(--flyout-input-bg) !important;
    border: 1px solid transparent;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    min-width: 0;
}

.search-field:focus {
    border-color: var(--primary-color);
}

.flex-grow {
    flex: 1;
}

.search-checkbox-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    white-space: nowrap;
}

.search-checkbox-group label {
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
}

.search-checkbox-group input[type="checkbox"] {
    accent-color: var(--dim-color);
}

.search-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.search-btn {
    background-color: var(--primary-color);
    color: var(--unread-text);
    border: none;
    padding: 4px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
}

/* Main Container */
#main-container {
    margin-top: 64px;
    height: calc(100vh - 128px);
    overflow-y: hidden;
    padding: 0;
    background-color: var(--bg-color);
}

#calendar-view {
    display: none;
    height: 100%;
    flex-direction: column;
    overflow: hidden;
}

#texts-view {
    display: none;
    height: 100%;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Calendar */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
    height: 50px;
    flex-shrink: 0;
}

.calendar-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.calendar-title {
    font-size: 18px;
    font-weight: bold;
    width: 200px;
}

.cal-nav-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cal-nav-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.calendar-grid-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.cal-view-btn {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

.cal-view-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.cal-grid {
    display: grid;
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    min-height: auto;
}

.cal-cell {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    min-height: 100px;
    padding: 4px;
    position: relative;
    background-color: var(--bg-color);
}

.cal-cell.header {
    min-height: auto;
    text-align: center;
    padding: 8px;
    background-color: var(--surface-color);
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--border-color);
}

.cal-cell.day-view-row {
    min-height: 80px;
}

.cal-event {
    background-color: var(--primary-color);
    color: white;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 11px;
    margin-bottom: 2px;
    cursor: pointer;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-event:hover {
    opacity: 0.9;
}

.cal-event.search-match {
    background-color: #81c995 !important;
    color: #202124 !important;
}

.cal-event.day-mode {
    white-space: normal;
    height: auto;
    margin-bottom: 8px;
    padding: 8px;
}

.cal-event-time {
    font-weight: bold;
    margin-right: 4px;
}

.cal-event-desc {
    display: block;
    opacity: 0.8;
    font-size: 10px;
    margin-top: 4px;
}

.cal-date-label {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Checkboxes */
input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
    opacity: 0.6;
    filter: invert(1);
    accent-color: var(--primary-color);
}

input[type="checkbox"]:checked {
    opacity: 1;
}

/* Message Rows */
.message-row {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    height: 56px;
    transition: background-color 0.1s;
    color: var(--text-secondary);
}

.message-row.unread {
    background-color: var(--unread-bg);
    color: var(--unread-text);
    font-weight: 700;
}

.message-row:hover {
    background-color: rgba(26, 26, 74, 0.5);
    border-bottom: 1px solid var(--border-color);
    z-index: 2;
}

.message-row.selected {
    background-color: var(--dim-color);
    color: #ffffff;
}

.message-row.selected input[type="checkbox"] {
    accent-color: var(--primary-color);
}

.message-row.selected.unread {
    background-color: var(--primary-color);
    color: #ffffff;
}

.message-row.selected.unread input[type="checkbox"] {
    accent-color: var(--dim-color);
}

.message-row.selected .msg-sender,
.message-row.selected .msg-subject,
.message-row.selected .msg-date,
.message-row.selected .msg-snippet,
.message-row.selected.unread .msg-sender,
.message-row.selected.unread .msg-subject,
.message-row.selected.unread .msg-date,
.message-row.selected .msg-count,
.message-row.selected.unread .msg-count {
    color: #ffffff;
}

.message-row.unread .msg-sender,
.message-row.unread .msg-subject {
    color: white;
    font-weight: 700;
}

.message-row.unread .msg-date {
    color: white;
    font-weight: 700;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background-color: var(--avatar-bg);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    margin-right: 16px;
    flex-shrink: 0;
}

.msg-sender {
    width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    color: var(--text-primary);
}

.msg-count {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 4px;
    vertical-align: middle;
}

.msg-count.has-draft {
    color: #81c995;
    font-weight: bold;
}

.msg-content-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.msg-subject {
    margin-right: 8px;
    white-space: nowrap;
    color: var(--text-primary);
}

.msg-snippet {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.msg-date {
    width: 140px;
    text-align: right;
    color: var(--text-secondary);
    font-size: 12px;
    flex-shrink: 0;
    margin-left: 10px;
}

/* Conversation Modal */
#conversation-modal {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    width: 100%;
    height: calc(100vh - 64px);
    background-color: var(--bg-color);
    z-index: 20;
    flex-direction: column;
}

#conversation-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 15%;
    background-color: var(--bg-color);
}

.thread-message {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 16px;
    overflow: hidden;
}

.thread-message.collapsed .thread-body,
.thread-message.collapsed .message-toolbar {
    display: none;
}

.thread-message.collapsed .thread-header {
    border-bottom: none;
}

.thread-header {
    height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    background-color: #303134;
    position: relative;
    cursor: pointer;
    box-sizing: border-box;
}

.thread-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background-color: #555;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.thread-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.thread-sender-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.thread-sender {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 14px;
}

.thread-email {
    color: var(--text-secondary);
    font-size: 12px;
}

.thread-timestamp {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
}

.thread-body {
    padding: 24px;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

.thread-body img {
    max-width: 100%;
    height: auto;
}

.message-toolbar {
    background-color: #303134;
    padding: 0 16px;
    border-top: 1px solid var(--border-color);
    height: 56px;
    display: flex;
    gap: 16px;
    align-items: center;
    box-sizing: border-box;
}

/* Composer */
.composer-container {
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    margin-bottom: 20px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
}

.composer-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 16px;
}

.composer-label {
    width: 80px;
    color: var(--text-secondary);
    font-weight: bold;
}

.composer-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    flex: 1;
    outline: none;
    font-family: inherit;
    padding: 4px;
}

.composer-body-wrapper {
    background-color: var(--surface-color);
    padding: 0;
}

.tox-tinymce {
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.composer-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-send {
    background-color: var(--primary-color);
    color: var(--unread-text);
    border: none;
    padding: 6px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.composer-actions {
    display: flex;
    gap: 16px;
}

.composer-action-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
}

.action-save { color: #81c995; }
.action-cancel { color: #f28b82; }
.action-delete { color: #f28b82; }

.schedule-send-input {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 5px;
    border-radius: 4px;
    font-family: inherit;
    color-scheme: dark;
    margin-left: 10px;
}

/* Alerts */
#unsaved-alert {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

#delete-confirm-alert {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 60;
    align-items: center;
    justify-content: center;
}

.alert-box {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 8px;
    display: flex;
    gap: 32px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    align-items: center;
}

.alert-btn {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
}

.alert-btn.text-btn {
    width: auto;
    padding: 0 20px;
    font-size: 14px;
}

.alert-btn:hover {
    background-color: var(--hover-color);
}

.confirm-text {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: bold;
    margin-right: 16px;
}

/* Pagination */
.pagination-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pagination-display {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-secondary);
    gap: 8px;
    line-height: 1;
}

.pagination-display input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: center;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    margin: 0;
    width: 1ch;
    min-width: 1ch;
}

.close-conversation-btn {
    margin-left: auto;
    cursor: pointer;
    color: #9aa0a6;
    width: 30px;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: bold;
    font-size: 16px;
    margin-right: 16px;
}

.close-conversation-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.green-plus-add {
    color: #81c995;
    cursor: pointer;
    margin-left: 6px;
    font-weight: bold;
    font-size: 14px;
}

/* Contact Form */
.contact-form-container {
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    margin-bottom: 20px;
    border-radius: 4px;
    padding: 16px;
}

.contact-actions {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.btn-green-plus {
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #81c995;
    font-weight: bold;
    font-size: 20px;
}

.contact-email {
    flex: 1;
    margin-right: 16px;
    color: var(--text-secondary);
}

.contact-phone {
    width: 120px;
    text-align: right;
    color: var(--text-secondary);
}

/* Text Messages */
.text-inbox-wrapper {
    height: 100%;
    overflow-y: auto;
}

.text-conversation-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--surface-color);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    position: relative;
}

.text-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    background-color: #303134;
}

.text-roll {
    flex: 1;
    max-height: 600px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.text-row {
    display: flex;
    width: 100%;
    align-items: flex-end;
    gap: 8px;
}

.text-row.sent {
    justify-content: flex-end;
}

.text-row.received {
    justify-content: flex-start;
}

.text-bubble {
    padding: 10px 16px;
    border-radius: 16px;
    max-width: 70%;
    width: fit-content;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.text-bubble-received {
    background-color: #3c4043;
    color: white;
    border-bottom-left-radius: 2px;
}

.text-bubble-sent {
    background-color: #81c995;
    color: black;
    border-bottom-right-radius: 2px;
}

.text-quote {
    margin: 0 0 8px 0;
    padding-left: 8px;
    border-left: 2px solid rgba(255,255,255,0.5);
    opacity: 0.7;
    font-style: italic;
    font-size: 0.9em;
}

.text-bubble-sent .text-quote {
    border-left-color: rgba(0,0,0,0.5);
    color: rgba(0,0,0,0.7);
}

.text-reply-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.1s;
    margin-bottom: 4px;
}

.text-reply-btn:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.text-timestamp {
    font-size: 10px;
    color: #9aa0a6;
    margin-bottom: 12px;
}

.text-timestamp-received {
    align-self: flex-start;
    margin-left: 40px;
}

.text-timestamp-sent {
    align-self: flex-end;
    text-align: right;
    margin-right: 40px;
}

.text-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background-color: #303134;
}

.text-input-field {
    flex: 1;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 10px 16px;
    color: white;
    font-family: inherit;
    resize: none;
    height: 20px;
    max-height: 100px;
    overflow-y: auto;
}

.text-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary-color);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.text-send-btn.disabled {
    background-color: var(--dim-color);
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.text-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    cursor: pointer;
    color: #9aa0a6;
    font-weight: bold;
    font-size: 18px;
}