/* Mail module styles */

.mail-layout {
    display: grid;
    grid-template-columns: 260px 380px 1fr;
    height: calc(100vh - 64px);
    background: var(--bg);
}

.panel {
    background: var(--surface);
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

.panel:last-child {
    border-right: none;
}

/* Sidebar */
.mail-sidebar {
    display: flex;
    flex-direction: column;
}

.compose-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.compose-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.compose-btn:hover {
    background: var(--primary-hover);
}

.folders-section {
    padding: 0.5rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.875rem;
}

.nav-item:hover {
    background: var(--surface-hover);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item svg {
    flex-shrink: 0;
}

.folder-badge {
    margin-left: auto;
    background: var(--surface-hover);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.folder-badge.unread {
    background: var(--primary);
    color: white;
}

.labels-section {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.icon-btn {
    padding: 0.375rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.label-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.label-item:hover {
    background: var(--surface-hover);
}

.label-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--label-color);
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--text-secondary);
}

/* Mail List */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.list-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.list-header-left h3 {
    font-size: 1rem;
    font-weight: 600;
}

.list-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.875rem;
    width: 140px;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}

.selected-count {
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 500;
    margin-right: auto;
}

.bulk-btn {
    padding: 0.375rem 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
}

.bulk-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.bulk-btn.danger:hover {
    color: var(--error);
}

.mail-item {
    display: flex;
    flex-direction: column;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.mail-item:hover {
    background: var(--surface-hover);
}

.mail-item.unread {
    background: var(--primary-light);
}

.mail-item.unread .mail-from {
    font-weight: 600;
}

.mail-item.selected {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.mail-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.mail-item-header input[type="checkbox"] {
    margin-right: 0.25rem;
}

.mail-from {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.mail-subject {
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mail-labels {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

.mail-label {
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
}

/* Mail Content */
.mail-content {
    display: flex;
    flex-direction: column;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.empty-state p {
    font-size: 0.875rem;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modals */
dialog.modal {
    display: none;
    border: none;
    padding: 0;
    background: transparent;
    max-width: none;
    max-height: none;
}

dialog.modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 1rem;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-large {
    max-width: 700px;
}

.modal-small {
    max-width: 320px;
}

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

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* Compose */
.compose-fields {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.field-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.field-row:last-child {
    border-bottom: none;
}

.field-row label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    width: 60px;
    flex-shrink: 0;
}

.field-row input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.875rem;
}

.field-toggle {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
}

.field-toggle:hover {
    background: var(--surface-hover);
}

.compose-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar-btn {
    padding: 0.375rem 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
}

.toolbar-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

.compose-body {
    flex: 1;
    min-height: 200px;
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text);
    outline: none;
    overflow-y: auto;
}

.compose-body:empty::before {
    content: attr(placeholder);
    color: var(--text-secondary);
}

.compose-attachments {
    padding: 0 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.compose-options {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.priority-select {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.compose-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.send-group {
    display: flex;
    position: relative;
}

.send-group .btn-primary:first-child {
    border-radius: 6px 0 0 6px;
}

.send-group .dropdown-toggle {
    padding: 0.625rem 0.5rem;
    border-radius: 0 6px 6px 0;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.schedule-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 240px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10;
    margin-bottom: 0.5rem;
}

.schedule-menu.show {
    display: block;
}

.schedule-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.875rem;
}

.schedule-option:hover {
    background: var(--surface-hover);
}

.schedule-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-secondary {
    padding: 0.625rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.form-group {
    margin-bottom: 1rem;
    padding: 0 1.25rem;
}

.form-group:first-child {
    padding-top: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="datetime-local"],
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
}

.form-group textarea {
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

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

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    transition: background 0.2s;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

input:checked + .toggle-switch {
    background: var(--primary);
}

input:checked + .toggle-switch::after {
    transform: translateX(20px);
}

.compose-actions-top {
    display: flex;
    gap: 0.25rem;
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: var(--surface-hover);
    border-radius: 4px;
    font-size: 0.75rem;
}

.attachment-chip button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .mail-layout {
        grid-template-columns: 220px 1fr;
    }
    .mail-content {
        display: none;
    }
    .mail-content.active {
        display: flex;
        position: fixed;
        inset: 64px 0 0 0;
        z-index: 100;
    }
}

@media (max-width: 768px) {
    .mail-layout {
        grid-template-columns: 1fr;
    }
    .mail-sidebar {
        display: none;
    }
    .mail-sidebar.active {
        display: flex;
        position: fixed;
        inset: 64px 0 0 0;
        z-index: 100;
        width: 280px;
    }
    .modal-content {
        max-height: 90vh;
    }
    .compose-toolbar {
        display: none;
    }
}
