/* CSS Variables for easy theming */
:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --secondary-color: #7b68ee;
    --accent-color: #ff6b6b;
    --success-color: #51cf66;
    --warning-color: #ffd43b;
    --danger-color: #ff6b6b;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-muted: #95a5a6;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --bg-hover: #f0f2f5;
    --border-color: #e1e8ed;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
    --border-radius: 0.5rem;
    --border-radius-sm: 0.25rem;
    --border-radius-lg: 1rem;
}

/* Dark mode variables */
[data-theme="dark"],
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --text-primary: #ecf0f1;
        --text-secondary: #bdc3c7;
        --text-muted: #7f8c8d;
        --bg-light: #2c3e50;
        --bg-white: #34495e;
        --bg-hover: #3d566e;
        --border-color: #4a5568;
        --bg-gradient-start: #434343;
        --bg-gradient-end: #000000;
    }
}

[data-theme="dark"] {
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --text-muted: #7f8c8d;
    --bg-light: #2c3e50;
    --bg-white: #34495e;
    --bg-hover: #3d566e;
    --border-color: #4a5568;
    --bg-gradient-start: #434343;
    --bg-gradient-end: #000000;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
}

/* Login Page Styles */
.login-container {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1rem;
    animation: fadeIn 0.5s ease;
}

.login-card {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    animation: slideUp 0.5s ease;
}

[data-theme="dark"] .login-card {
    background: rgba(52, 73, 94, 0.95);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 2rem;
}

.login-form {
    display: grid;
    gap: 1.5rem;
}

.form-group {
    display: grid;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-white);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-group small {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.btn-primary,
.btn-secondary,
.btn-action,
.btn-secondary-small {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--secondary-color) 100%);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-secondary-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary-small:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-danger:hover {
    background: #e63946;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-danger-outline:hover {
    background: var(--danger-color);
    color: white;
}

.btn-action {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-action:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
}

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

.error-message {
    padding: 0.75rem;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid var(--danger-color);
    border-radius: var(--border-radius);
    color: var(--danger-color);
    text-align: center;
}

/* Webmail Styles */
.webmail-body {
    background: var(--bg-light);
}

.webmail-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: grid;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    gap: 1rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: grid;
    gap: 0.5rem;
    position: sticky;
    bottom: 0;
    background: var(--bg-white);
}

.btn-logout {
    width: 100%;
    padding: 0.75rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-logout:hover {
    background: #e55555;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.folder-list {
    padding: 0.5rem;
    display: grid;
    gap: 0.25rem;
    align-content: start;
    overflow-y: auto;
}

.folder-item {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

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

.folder-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.folder-item .unread-badge {
    background: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
}

.folder-item.active .unread-badge {
    background: rgba(255, 255, 255, 0.3);
}

.folder-item.subfolder {
    padding-left: 2rem;
}

.folder-item.grouped {
    padding-left: 1.5rem;
}

.folder-group {
    margin: 0.25rem 0;
}

.folder-group-header {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem;
    align-items: center;
}

.folder-group-header:hover {
    background: var(--bg-hover);
    border-radius: var(--border-radius);
}

.folder-expand-icon {
    font-size: 0.75rem;
    display: inline-block;
    transition: var(--transition);
}

.folder-group-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.folder-group-content.collapsed {
    max-height: 0;
}

.email-content {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.content-header {
    padding: 1rem 1.5rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-primary);
}

.search-bar {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    width: 100%;
    background: var(--bg-light);
    color: var(--text-primary);
    transition: var(--transition);
}

.search-bar:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-white);
}

.header-actions {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 0.5rem;
    align-items: center;
    justify-self: end;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: right;
}

.email-list-container {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.email-toolbar {
    padding: 1rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
}

.selection-actions {
    display: grid;
    grid-template-columns: auto repeat(5, auto);
    gap: 0.5rem;
    align-items: center;
}

.folder-title h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    text-align: center;
}

.list-actions {
    display: grid;
    grid-auto-flow: column;
    gap: 0.5rem;
}

.email-list {
    overflow-y: auto;
    padding: 1rem;
    display: grid;
    gap: 0.5rem;
    align-content: start;
}

.email-item {
    background: var(--bg-white);
    padding: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: start;
}

.email-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.email-item.unread {
    font-weight: 600;
    border-left: 4px solid var(--primary-color);
}

.email-item.spam {
    border-left: 4px solid #ff9800; /* Orange for spam */
}

.email-item.phishing {
    border-left: 4px solid #f44336; /* Red for phishing */
}

/* Drag and drop styles */
.email-item.dragging {
    opacity: 0.5;
    cursor: move;
}

.folder-item.drag-over {
    background: rgba(74, 144, 226, 0.15);
    border-left: 4px solid var(--primary-color);
    transform: translateX(4px);
}

.email-item-checkbox {
    margin-top: 0.25rem;
}

.email-item-content {
    display: grid;
    gap: 0.25rem;
}

.email-item-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: baseline;
}

.email-item-from {
    color: var(--text-primary);
    font-weight: 600;
}

.email-item-date {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.email-item-subject {
    color: var(--text-primary);
    font-size: 1rem;
}

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

.email-viewer {
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.email-viewer-toolbar {
    padding: 1rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: center;
}

.viewer-actions {
    display: grid;
    grid-auto-flow: column;
    gap: 0.5rem;
    justify-content: end;
}

.email-viewer-content {
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-white);
}

.email-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.email-meta {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.email-meta-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1rem;
}

.email-meta-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.email-meta-value {
    color: var(--text-primary);
}

.email-subject {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
}

.email-body {
    color: var(--text-primary);
    line-height: 1.8;
}

.email-body img {
    max-width: 100%;
    height: auto;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-content.modal-small {
    max-width: 400px;
}

.modal-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light);
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.folder-selection {
    display: grid;
    gap: 0.5rem;
}

.folder-selection-item {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.folder-selection-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

/* Loading state */
.loading {
    display: grid;
    place-items: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '⏳';
    font-size: 2rem;
    animation: spin 1s linear infinite;
}

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

/* Empty state */
.empty-state {
    display: grid;
    place-items: center;
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state-message {
    font-size: 1.125rem;
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .sidebar,
    .content-header,
    .email-toolbar,
    .email-viewer-toolbar {
        display: none !important;
    }

    .email-viewer {
        display: block !important;
    }

    .email-viewer-content {
        padding: 0;
    }
}

/* Mobile First - Responsive */
@media (max-width: 768px) {
    .webmail-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 280px;
        height: 100vh;
        z-index: 999;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-visible {
        left: 0;
        box-shadow: var(--shadow-xl);
    }

    .menu-toggle {
        display: block;
    }

    .content-header {
        grid-template-columns: auto 1fr;
    }

    .header-actions {
        grid-template-columns: auto auto;
    }

    .user-email {
        display: none;
    }

    .email-toolbar {
        grid-template-columns: 1fr;
    }

    .selection-actions {
        grid-template-columns: auto 1fr;
        justify-items: start;
    }

    .folder-title {
        order: -1;
    }

    .list-actions {
        justify-self: end;
    }

    .email-item {
        grid-template-columns: 1fr;
    }

    .email-item-checkbox {
        position: absolute;
        top: 1rem;
        right: 1rem;
    }

    .email-viewer-toolbar {
        grid-template-columns: 1fr;
    }

    .viewer-actions {
        justify-content: start;
        grid-auto-flow: row;
    }

    .form-actions {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 1.5rem;
    }

    .modal-content {
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .selection-actions {
        grid-template-columns: 1fr;
    }

    .selection-actions button {
        width: 100%;
    }

    .email-item-header {
        grid-template-columns: 1fr;
    }

    .email-meta-row {
        grid-template-columns: 1fr;
    }
}

/* Email address badges */
.email-input-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    width: 100%;
}

.email-badges-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
    min-height: 2.5rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: text;
}

.email-badge {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    width: fit-content;
    max-width: 100%;
    transition: var(--transition);
}

.email-badge.valid {
    background: rgba(81, 207, 102, 0.15);
    border: 1px solid var(--success-color);
    color: var(--text-primary);
}

.email-badge.invalid {
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.email-badge-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-badge-remove {
    cursor: pointer;
    font-weight: bold;
    padding: 0 0.25rem;
    opacity: 0.7;
    transition: var(--transition);
}

.email-badge-remove:hover {
    opacity: 1;
}

.email-input {
    border: none;
    outline: none;
    background: transparent;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-width: 150px;
    grid-column: 1 / -1;
}

.email-input::placeholder {
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* Dashboard Styles */
.dashboard-content {
    padding: 2rem;
    overflow-y: auto;
    display: block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-info h3 {
    font-size: 2rem;
    color: var(--primary-color);
    margin: 0;
}

.stat-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.table-section {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: 2rem;
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem;
}

.table-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.table-container {
    overflow-x: auto;
}

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

.data-table th {
    background: var(--bg-light);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table td.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(81, 207, 102, 0.15);
    color: var(--success-color);
}

.status-badge.inactive {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger-color);
}

.status-badge.admin-role {
    background: rgba(138, 116, 249, 0.15);
    color: #8a74f9;
}

.status-badge.user-role {
    background: rgba(66, 153, 225, 0.15);
    color: var(--primary-color);
}

.action-buttons {
    display: grid;
    grid-auto-flow: column;
    gap: 0.5rem;
    justify-content: start;
}

.btn-icon-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.btn-icon-small:hover {
    background: var(--bg-hover);
}

.btn-icon-small.edit {
    color: var(--primary-color);
}

.btn-icon-small.delete {
    color: var(--danger-color);
}

/* DNS Configuration */
.dns-info {
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.dns-description {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.dns-records {
    display: grid;
    gap: 1rem;
}

.dns-record {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.dns-record-header {
    padding: 0.75rem 1rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: center;
}

.dns-record-type {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
}

.dns-record-status {
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dns-record-status.unchecked {
    color: var(--warning-color);
}

.dns-record-status.valid {
    color: var(--success-color);
}

.dns-record-status.invalid {
    color: var(--warning-color);
}

.dns-record-body {
    padding: 1rem;
}

.dns-record-field {
    margin-bottom: 0.75rem;
}

.dns-record-field strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.code-with-copy {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.dns-record-field code {
    display: block;
    background: var(--bg-white);
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    word-break: break-all;
    border: 1px solid var(--border-color);
}

.copy-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    transition: var(--transition);
    border-radius: var(--border-radius-sm);
}

.copy-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.email-input-with-domain {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background: var(--bg-white);
}

.email-input-with-domain input {
    border: none;
    border-right: 1px solid var(--border-color);
    border-radius: 0;
    margin: 0;
}

.email-input-with-domain input:focus {
    border: none;
    border-right: 1px solid var(--primary-color);
    outline: none;
}

.email-domain-suffix {
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.password-input-with-generate {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.password-input-with-generate input {
    margin: 0;
}

.generate-password-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.generate-password-btn:hover {
    background: var(--primary-hover);
    transform: rotate(180deg);
}

.dns-record-description {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive dashboard tables */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        display: block;
    }

    .data-table {
        min-width: 600px;
        width: auto;
        display: table;
    }

    .dashboard-content {
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }

    .table-section {
        width: 100%;
        overflow: hidden;
    }

    /* Make webmail container responsive on dashboard */
    body:has(.dashboard-content) .webmail-container {
        grid-template-columns: 280px 1fr;
        overflow-x: hidden;
    }

    body:has(.dashboard-content) .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    body:has(.dashboard-content) .sidebar.mobile-visible {
        left: 0;
    }

    body:has(.dashboard-content) .email-content {
        grid-column: 1 / -1;
        width: 100%;
    }

    body:has(.dashboard-content) .menu-toggle {
        display: block;
    }
}

/* Security info button and modal */
.email-item-date-container {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.5rem;
    align-items: center;
}

.email-info-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.25rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    opacity: 1;
    pointer-events: auto;
}

.email-info-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.2);
}

.security-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.security-info-section {
    padding: 1rem;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.security-info-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.security-info-item {
    margin-bottom: 1rem;
}

.security-info-item:last-child {
    margin-bottom: 0;
}

.security-info-item label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.security-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(81, 207, 102, 0.15);
    color: var(--success-color);
}

.badge-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger-color);
}

.security-report {
    background: var(--bg-white);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
}

.security-details {
    background: var(--bg-white);
    padding: 0.75rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
}

.security-detail-item {
    padding: 0.25rem 0;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

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

.security-info-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.security-info-footer small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.security-info-footer small:last-child {
    text-align: right;
}

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

    .security-info-footer {
        grid-template-columns: 1fr;
    }

    .security-info-footer small:last-child {
        text-align: left;
    }

    .email-info-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Email status badges for Sent folder */
.email-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    transition: var(--transition);
    cursor: help;
}

.email-status-badge.status-sent {
    background: rgba(81, 207, 102, 0.15);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.email-status-badge.status-delivered {
    background: rgba(81, 207, 102, 0.25);
    color: var(--success-color);
    border: 2px solid var(--success-color);
}

.email-status-badge.status-failed {
    background: rgba(255, 107, 107, 0.15);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.email-status-badge.status-sending {
    background: rgba(74, 144, 226, 0.15);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    animation: pulse 1.5s ease-in-out infinite;
}

.email-status-badge.status-queued {
    background: rgba(255, 212, 59, 0.15);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.email-status-badge.status-unknown {
    background: rgba(127, 140, 141, 0.15);
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Email attachments */
.email-attachments {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
}

.attachments-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--background-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
    max-width: 300px;
}

.attachment-item:hover {
    background: var(--background-hover);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.attachment-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.attachment-size {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* File input */
.file-input {
    display: block;
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--background-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.file-input:hover {
    border-color: var(--primary-color);
}

/* Attachments preview in compose form */
.attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attachment-preview-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.attachment-preview-remove {
    cursor: pointer;
    color: var(--danger-color);
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0 0.25rem;
    border-radius: 50%;
    transition: var(--transition);
}

.attachment-preview-remove:hover {
    background: var(--danger-color);
    color: white;
}

/* API Key Card */
.api-key-card {
    padding: 1.5rem;
}

.api-key-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.api-key-display {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.api-key-value {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-all;
    overflow-wrap: break-word;
}

.api-key-note {
    color: var(--warning-color);
    font-size: 0.85rem;
    margin: 0;
    padding: 0.75rem;
    background: rgba(255, 212, 59, 0.1);
    border-left: 3px solid var(--warning-color);
    border-radius: var(--border-radius-sm);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Domain Edit Form Styles */
.domain-form-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.form-section {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.form-section h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-grid-full {
    grid-column: 1 / -1;
}

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

.form-group input:disabled {
    background: var(--bg-light);
    cursor: not-allowed;
    opacity: 0.6;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.api-key-display {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.api-key-display input {
    flex: 1;
    font-family: 'Courier New', monospace;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

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

    .domain-form-container {
        padding: 1rem;
    }
}
