/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #2c3e50;
    line-height: 1.6;
}

/* ===== AUTH PAGE ===== */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #4a6fa5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.auth-body::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800"><defs><radialGradient id="a" cx="50%" cy="50%"><stop offset="0%" stop-color="%23fff" stop-opacity=".05"/><stop offset="100%" stop-color="%23fff" stop-opacity="0"/></radialGradient></defs><circle cx="200" cy="200" r="300" fill="url(%23a)"/><circle cx="900" cy="600" r="400" fill="url(%23a)"/></svg>');
    background-size: cover;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.bg-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(74, 111, 165, 0.15);
    backdrop-filter: blur(2px);
    z-index: 0;
}
.auth-container {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 20px;
}
.logo {
    margin-bottom: 24px;
    color: #fff;
}
.logo-icon {
    font-size: 56px;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}
.logo h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
}
.tagline {
    font-size: 14px;
    opacity: 0.85;
    margin-top: 4px;
}
.popup {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 32px;
    max-width: 420px;
    margin: 0 auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.3);
}
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: #f0f4f8;
    border-radius: 10px;
    padding: 4px;
}
.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
}
.tab.active {
    background: #fff;
    color: #4a6fa5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.form-group {
    margin-bottom: 16px;
    text-align: left;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74,111,165,0.1);
}
.captcha-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.captcha-row input { flex: 1; }
.captcha-row img {
    height: 42px;
    border-radius: 6px;
    cursor: pointer;
    border: 1.5px solid #e2e8f0;
}
.hint {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    display: block;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 6px;
}
.btn-primary {
    background: #4a6fa5;
    color: #fff;
}
.btn-primary:hover {
    background: #3d5d8a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74,111,165,0.3);
}
.btn-outline {
    background: transparent;
    border: 1.5px solid #cbd5e1;
    color: #475569;
}
.btn-outline:hover {
    border-color: #4a6fa5;
    color: #4a6fa5;
}
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 6px 10px; font-size: 16px; background: transparent; }
.btn-icon:hover { background: #f1f5f9; border-radius: 6px; }
.btn-block { width: 100%; }
.error-msg {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid #fecaca;
}
.success-msg {
    background: #f0fdf4;
    color: #16a34a;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    border: 1px solid #bbf7d0;
}
.footer-text {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    margin-top: 24px;
}
.admin-badge {
    background: linear-gradient(135deg, #4a6fa5, #667eea);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 14px;
}

/* ===== WEBMAIL ===== */
.webmail-body {
    background: #f0f4f8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.wm-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.wm-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo-icon-sm {
    font-size: 24px;
}
.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: #4a6fa5;
}
.wm-search {
    flex: 1;
    max-width: 400px;
}
.wm-search input {
    width: 100%;
    padding: 8px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    font-size: 13px;
    background: #f8fafc;
}
.wm-search input:focus {
    outline: none;
    border-color: #4a6fa5;
    background: #fff;
}
.wm-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.user-email {
    font-size: 13px;
    color: #64748b;
}
.wm-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.wm-sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.btn-compose {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
}
.folder-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #475569;
    font-size: 14px;
    transition: all 0.15s;
}
.folder-item:hover {
    background: #f1f5f9;
}
.folder-item.active {
    background: #e8eef7;
    color: #4a6fa5;
    font-weight: 500;
}
.folder-icon { font-size: 16px; }
.folder-name { flex: 1; }
.folder-count {
    background: #e2e8f0;
    color: #64748b;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.folder-item.active .folder-count {
    background: #4a6fa5;
    color: #fff;
}
.wm-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}
.list-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.list-header h2 {
    font-size: 18px;
    color: #1e293b;
}
.email-items {
    flex: 1;
    overflow-y: auto;
}
.email-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
}
.email-item:hover {
    background: #f8fafc;
}
.email-item.unread {
    background: #f0f7ff;
    font-weight: 600;
}
.email-item.unread:hover {
    background: #e6f0fa;
}
.email-from {
    width: 200px;
    font-size: 13px;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-subject {
    flex: 1;
    font-size: 13px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-date {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
}
.email-size {
    font-size: 11px;
    color: #cbd5e1;
    width: 50px;
    text-align: right;
}
.loading {
    padding: 40px;
    text-align: center;
    color: #94a3b8;
}
.empty-list {
    padding: 60px 20px;
    text-align: center;
    color: #94a3b8;
}
.empty-list-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Email View */
.wm-email-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.view-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.view-actions {
    display: flex;
    gap: 4px;
}
.view-meta {
    padding: 20px;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
}
.view-meta-row {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}
.view-meta-label {
    color: #94a3b8;
    min-width: 50px;
}
.view-meta-value {
    color: #334155;
    font-weight: 500;
}
.view-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
}

/* Compose */
.wm-compose {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.compose-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.compose-header h2 {
    font-size: 18px;
    color: #1e293b;
}
#composeForm {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}
.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.form-row label {
    min-width: 60px;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}
.form-row input,
.form-row textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.form-row input:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #4a6fa5;
}
.form-row textarea {
    resize: vertical;
    min-height: 200px;
}
.compose-actions {
    display: flex;
    gap: 10px;
    padding-top: 10px;
}
.msg-box {
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 10px;
}
.msg-box.success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}
.msg-box.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Ad Sidebar */
.wm-ad-sidebar {
    width: 260px;
    background: #fff;
    border-left: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
.ad-container {
    width: 240px;
    min-height: 600px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: #fafbfc;
}
.ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 600px;
    color: #94a3b8;
    font-size: 13px;
}
.ad-placeholder-icon {
    font-size: 40px;
    margin-bottom: 10px;
    opacity: 0.4;
}

/* ===== ADMIN ===== */
.admin-body {
    background: #f0f4f8;
    min-height: 100vh;
}
.admin-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.admin-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #4a6fa5;
}
.admin-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-link {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover {
    background: #f1f5f9;
    color: #4a6fa5;
}
.nav-link.active {
    background: #e8eef7;
    color: #4a6fa5;
}
.admin-main {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}
.admin-section {
    display: none;
}
.admin-section.active {
    display: block;
}
.admin-section h2 {
    font-size: 22px;
    color: #1e293b;
    margin-bottom: 20px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}
.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #4a6fa5;
}
.stat-label {
    font-size: 13px;
    color: #64748b;
    margin-top: 4px;
}
.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}
.inline-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.inline-form input {
    flex: 1;
    max-width: 300px;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}
.inline-form input:focus {
    outline: none;
    border-color: #4a6fa5;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}
.data-table tr:hover td {
    background: #f8fafc;
}
.data-table code {
    font-size: 11px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
}
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green {
    background: #dcfce7;
    color: #16a34a;
}
.badge-red {
    background: #fee2e2;
    color: #dc2626;
}

/* Ad FAB */
.ad-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a6fa5, #667eea);
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(74,111,165,0.4);
    transition: all 0.2s;
    z-index: 100;
}
.ad-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(74,111,165,0.5);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 {
    font-size: 16px;
    color: #1e293b;
}
.modal-body {
    padding: 20px;
}
.modal-body textarea {
    width: 100%;
    padding: 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
}
.modal-body textarea:focus {
    outline: none;
    border-color: #4a6fa5;
}
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Responsive */
@media (max-width: 1024px) {
    .wm-ad-sidebar { display: none; }
    .wm-sidebar { width: 180px; }
}
@media (max-width: 768px) {
    .wm-sidebar { width: 60px; }
    .folder-name, .folder-count { display: none; }
    .btn-compose { font-size: 18px; padding: 12px; }
    .email-from { width: 120px; }
}

/* ===== PROFILE ===== */
.profile-body {
    background: #f0f4f8;
    min-height: 100vh;
}
.profile-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.profile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.profile-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.profile-main {
    padding: 40px 24px;
    display: flex;
    justify-content: center;
}
.profile-container {
    max-width: 600px;
    width: 100%;
}
.profile-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    text-align: center;
}
.profile-avatar {
    margin-bottom: 20px;
}
.avatar-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a6fa5, #667eea);
    color: #fff;
    font-size: 40px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 4px 16px rgba(74,111,165,0.3);
}
.profile-name {
    font-size: 24px;
    color: #1e293b;
    margin-bottom: 8px;
}
.profile-email {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
}
.profile-info {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: left;
}
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}
.info-row:last-child {
    border-bottom: none;
}
.info-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}
.info-value {
    font-size: 13px;
    color: #334155;
    font-weight: 500;
}
.profile-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
