/* Mail Plugin - Consolidated Styles */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --bg-light: #f8fafc;
}

.mail-container {
    display: flex;
    height: calc(100vh - 160px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.mail-sidebar {
    width: 260px;
    background: var(--bg-light);
    border-right: 1px solid var(--border-color);
    padding: 20px;
}

.btn-compose {
    width: 100%;
    padding: 12px;
    margin-bottom: 25px;
    justify-content: center;
    font-size: 1rem;
    border-radius: 12px;
}

.mail-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    font-weight: 500;
    transition: all 0.2s;
}

.mail-nav a:hover, .mail-nav a.active {
    background: #e2e8f0;
    color: #0f172a;
}

.mail-nav a.active {
    background: var(--primary-color);
    color: #fff;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 15px 0;
}

.mail-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mail-toolbar {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toolbar-left button, .toolbar-right button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    transition: color 0.2s;
}

.toolbar-left button:hover, .toolbar-right button:hover {
    color: var(--primary-color);
}

.toolbar-search {
    position: relative;
    width: 300px;
}

.toolbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.toolbar-search input {
    width: 100%;
    padding: 8px 12px 8px 35px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Message List (Inbox) */
.message-list {
    flex: 1;
    overflow-y: auto;
}

.message-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.1s;
}

.message-item:hover {
    background: var(--bg-light);
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.message-item.unread {
    background: #f1f7ff;
    font-weight: 600;
}

.message-checkbox { margin-right: 15px; }
.message-star { margin-right: 15px; color: #cbd5e1; }
.message-star:hover { color: #f59e0b; }
.message-star .fa-solid.starred { color: #f59e0b; }

.message-sender {
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.message-content {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 20px;
}

.message-snippet {
    color: var(--text-muted);
    font-weight: 400;
}

.message-date {
    width: 120px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Message View */
.message-view {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    padding: 30px 40px;
}

.message-subject {
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 25px;
    padding-left: 60px;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.sender-avatar {
    width: 45px;
    height: 45px;
    background: #f1f5f9;
    color: #475569;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sender-info {
    flex: 1;
}

.sender-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sender-name {
    font-weight: 700;
    color: var(--text-main);
}

.sender-bottom {
    font-size: 0.85rem;
    color: #94a3b8;
}

.message-body {
    padding: 0 60px;
    color: #334155;
    line-height: 1.7;
    font-size: 1.05rem;
    margin-bottom: 50px;
}

.message-footer-actions {
    padding: 20px 60px;
    display: flex;
    gap: 15px;
    border-top: 1px solid #f1f5f9;
}

.btn-back {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Compose Form */
.compose-header {
    padding: 30px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
}

.compose-header h2 { 
    margin: 0; 
    font-size: 1.5rem; 
    font-weight: 800;
    color: #0f172a;
}

.compose-form {
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    background: #fff;
}

.form-group {
    display: flex;
    align-items: center;
    border: 1px solid #f1f5f9;
    padding: 12px 20px;
    border-radius: 12px;
    background: var(--bg-light);
    transition: all 0.2s;
}

.form-group:focus-within {
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.05);
}

.form-group label {
    width: 80px;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    padding: 5px;
    background: transparent;
    color: #0f172a;
    font-weight: 500;
}

.form-editor {
    flex: 1;
    margin-top: 10px;
    min-height: 500px;
    border: 1px solid #f1f5f9;
    border-radius: 16px;
}

.compose-footer {
    padding: 25px 30px;
    display: flex;
    gap: 15px;
    border-top: 1px solid #f1f5f9;
    background: #fff;
}

/* Contacts */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    padding: 25px;
    overflow-y: auto;
}

.contact-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.contact-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
    border-color: var(--primary-color);
}

.contact-avatar {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: #fff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.3rem;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.contact-info h3 { 
    margin: 0; 
    font-size: 1.05rem; 
    color: #0f172a;
    font-weight: 700;
}

.contact-info p { 
    margin: 4px 0 0 0; 
    color: var(--text-muted); 
    font-size: 0.9rem; 
}

.contact-actions {
    display: flex;
    gap: 8px;
}

.contact-actions a, .contact-actions button {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.contact-actions a:hover { 
    background: var(--primary-color); 
    color: #fff;
}

.contact-actions .btn-delete:hover { 
    background: #fee2e2; 
    color: #ef4444; 
}

/* Settings */
.mail-settings {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: 'Inter', sans-serif;
}

.header-breadcrumb { margin-bottom: 20px; }
.header-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
}
.header-breadcrumb a:hover { color: var(--primary-color); }

.header-main h1 { font-size: 2rem; color: #0f172a; font-weight: 800; margin: 0; }
.header-main p { color: var(--text-muted); margin-top: 6px; font-size: 1.1rem; }

.settings-card {
    background: #fff;
    border-radius: 24px;
    padding: 0;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.04);
    border: 1px solid #f1f5f9;
    overflow: hidden;
    margin-top: 30px;
}

.settings-section {
    padding: 40px;
    border-bottom: 1px solid #f1f5f9;
}

.section-title {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.section-title i {
    font-size: 1.5rem;
    color: var(--primary-color);
    background: #eff6ff;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
}

.section-title h3 { margin: 0; font-size: 1.25rem; font-weight: 700; color: #1e293b; }
.section-title p { margin: 4px 0 0 0; color: var(--text-muted); font-size: 0.95rem; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 10px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 15px;
    color: #94a3b8;
    font-size: 1rem;
}

.input-wrapper input, .input-wrapper select {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg-light);
}

.input-wrapper input:focus, .input-wrapper select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.form-note {
    margin-top: 20px;
    font-size: 0.85rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-section {
    background: #fffbfc;
}

.badge-admin {
    background: #fef2f2;
    color: #dc2626;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
}

.form-footer {
    padding: 30px 40px;
    background: var(--bg-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Dashboard / Index */
.mail-dashboard {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
}

.mail-header {
    margin-bottom: 40px;
}

.header-main h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0;
    color: #0f172a;
}

.header-main p {
    color: var(--text-muted);
    margin-top: 5px;
    font-size: 1.1rem;
}

.mail-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

.mail-card {
    background: #fff;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.04);
    border: 1px solid #f1f5f9;
}

.profile-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-user {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 1.4rem;
}

.user-info h3, .user-name {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

.email-address {
    margin: 4px 0 0 0;
    color: var(--primary-color);
    font-weight: 600;
}

.quota-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.quota-card .card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.quota-total {
    font-weight: 700;
    color: #0f172a;
}

.quota-progress-container {
    height: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}

.quota-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #2dd4bf);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.quota-progress-bar.progress-45 { width: 45%; }

.quota-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.quota-legend strong {
    color: #0f172a;
}

.section-card {
    background: #fff;
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.04);
    border: 1px solid #f1f5f9;
    margin-bottom: 25px;
}

.section-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-header p {
    color: var(--text-muted);
    margin: 0 0 25px 0;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.config-item label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.value-box {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}

.value-box span {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 0.95rem;
    font-weight: 600;
    color: #334155;
}

.copy-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

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

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.quick-card {
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border: 1px solid #f1f5f9;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.02);
}

.quick-card i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.quick-card span {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.quick-card:hover:not(.disabled) {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
    border-color: var(--primary-color);
}

.quick-card.disabled {
    opacity: 0.6;
    cursor: default;
    background: var(--bg-light);
}

.quick-card small {
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Global Buttons & Utilities */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover {
    background: var(--bg-light);
    color: #0f172a;
    border-color: #cbd5e1;
}

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f1f5f9; color: #1e293b; }

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

@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading { position: relative; pointer-events: none; }
.btn.loading span { opacity: 0; }
.btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsiveness */
@media (max-width: 768px) {
    .mail-grid { grid-template-columns: 1fr; }
    .profile-card { flex-direction: column; text-align: center; gap: 25px; }
    .config-grid { grid-template-columns: 1fr; }
    .mail-sidebar { display: none; } /* On mobile, we might need a hamburger menu later */
}

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-footer { flex-direction: column-reverse; gap: 15px; }
    .btn { width: 100%; justify-content: center; }
}
