* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Roboto', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--light);
    min-height: 100vh;
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: #0f0f0f;
    color: var(--text);
}

/* ============ COLOR SCHEME ============ */
:root {
    --primary: #0073E6;
    --primary-dark: #0055B8;
    --primary-light: #E8F0FF;
    --secondary: #1a1a1a;
    --light: #f8f9fa;
    --white: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

/* Dark Mode Theme */
:root.dark-mode {
    --primary: #00A8FF;
    --primary-dark: #0088CC;
    --primary-light: #1a3a52;
    --secondary: #ffffff;
    --light: #1a1a1a;
    --white: #2a2a2a;
    --text: #e0e0e0;
    --text-light: #b0b0b0;
    --border: #404040;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
}

/* ============ LOGIN PAGE ============ */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #0073E6 0%, #0055B8 100%);
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0, 115, 230, 0.2);
    max-width: 450px;
    width: 100%;
    animation: slideIn 0.5s ease-out;
}

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

.logo-section {
    text-align: center;
    margin-bottom: 30px;
}

.logo-container {
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
}

.logo-image {
    height: 120px;
    width: auto;
    object-fit: contain;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.navbar-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.logo {
    font-size: 2.5em;
    color: #0073E6;
    margin-bottom: 5px;
    font-weight: 700;
}

.tagline {
    color: #666666;
    font-size: 0.9em;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #1a1a1a;
    font-weight: 600;
    font-size: 0.95em;
}

/* Password Wrapper for Show/Hide Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper .form-input {
    padding-right: 45px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.password-toggle:hover {
    transform: scale(1.1);
}

.form-input, .form-textarea, select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
    background: white;
    color: #1a1a1a;
}

.form-input:focus, .form-textarea:focus, select:focus {
    outline: none;
    border-color: #0073E6;
    box-shadow: 0 0 0 4px rgba(0, 115, 230, 0.1);
    background: white;
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
    min-height: 120px;
}

.math-question {
    background: linear-gradient(135deg, #0073E6 0%, #0055B8 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.4em;
    font-weight: bold;
    margin-bottom: 10px;
    box-shadow: 0 6px 20px rgba(0, 115, 230, 0.25);
}

/* ============ BUTTONS ============ */
.submit-btn, .btn-primary, .btn-secondary, .refresh-btn, .logout-btn {
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    text-align: center;
}

.submit-btn, .btn-primary {
    background: linear-gradient(135deg, #0073E6 0%, #0055B8 100%);
    color: white;
    padding: 12px 20px;
    width: 100%;
    border: 0;
}

.submit-btn:hover, .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 115, 230, 0.35);
}

.submit-btn:active, .btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #0073E6;
    color: white;
    padding: 10px 20px;
    width: auto;
}

.btn-secondary:hover {
    background: #0055B8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 115, 230, 0.3);
}

.refresh-btn {
    background: transparent;
    border: 2px solid #0073E6;
    color: #0073E6;
    padding: 10px 18px;
    font-size: 0.9em;
}

.refresh-btn:hover {
    background: #0073E6;
    color: white;
    transform: translateY(-2px);
}

.logout-btn {
    background: #1a1a1a;
    color: white;
    padding: 10px 20px;
    font-size: 0.9em;
}

.logout-btn:hover {
    background: #333333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.3);
}

/* ============ NAVBAR ============ */
.navbar {
    background: white;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 3px solid #0073E6;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-logo {
    color: #0073E6;
    font-size: 1.3em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-button {
    padding: 10px 16px;
    background: white;
    color: #0073E6;
    border: 2px solid #0073E6;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9em;
    white-space: nowrap;
}

.nav-button:hover {
    background: #0073E6;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 115, 230, 0.3);
}

.nav-button.active {
    background: #0073E6;
    color: white;
}

.nav-menu-icon {
    display: none;
    cursor: pointer;
    font-size: 1.5em;
}

@media (max-width: 768px) {
    .nav-buttons {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        right: 20px;
        background: white;
        border: 2px solid #0073E6;
        border-radius: 8px;
        gap: 0;
        z-index: 1000;
    }

    .nav-buttons.show {
        display: flex;
    }

    .nav-button {
        border: none;
        border-radius: 0;
        width: 100%;
        padding: 12px 20px;
        text-align: left;
    }

    .nav-menu-icon {
        display: block;
    }
}

/* ============ DASHBOARD ============ */
.dashboard {
    min-height: 100vh;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
}

.dashboard-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
    width: 100%;
}

.dashboard-header {
    margin-bottom: 35px;
}

.dashboard-header h2 {
    color: #1a1a1a;
    font-size: 2.2em;
    font-weight: 700;
    margin-bottom: 8px;
}

.dashboard-header p {
    color: #666666;
    font-size: 1.05em;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 25px;
}

.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

.card:hover {
    box-shadow: 0 12px 30px rgba(0, 115, 230, 0.12);
    transform: translateY(-4px);
    border-color: #0073E6;
}

.card.full-width {
    grid-column: 1 / -1;
}

.card h3 {
    color: #1a1a1a;
    margin-bottom: 20px;
    font-size: 1.3em;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid #0073E6;
    padding-bottom: 12px;
}

/* ============ MESSAGES & BADGES ============ */
.status-message {
    margin-top: 15px;
    padding: 14px 16px;
    border-radius: 10px;
    display: none;
    border-left: 4px solid transparent;
    font-weight: 500;
}

.status-message.success {
    background: #D1F2EB;
    color: #065f46;
    border-left-color: #10b981;
    display: block;
}

.status-message.error {
    background: #FED7D7;
    color: #742A2A;
    border-left-color: #ef4444;
    display: block;
}

.error-message {
    background: #FED7D7;
    color: #742A2A;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: none;
    border-left: 4px solid #ef4444;
}

.status-badge {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85em;
}

.status-badge.enabled {
    background: #D1F2EB;
    color: #065f46;
}

.status-badge.disabled {
    background: #FED7D7;
    color: #742A2A;
}

/* ============ CONTROLS & LISTS ============ */
.auto-reply-controls {
    margin-bottom: 20px;
}

.auto-reply-controls p {
    margin-bottom: 15px;
    color: #333333;
    font-weight: 500;
}

.info-box {
    background: #E8F0FF;
    padding: 16px;
    border-radius: 10px;
    margin-top: 15px;
    border-left: 4px solid #0073E6;
}

.info-box p {
    color: #1a1a1a;
    font-weight: 600;
    margin-bottom: 10px;
}

.info-box ul {
    margin-left: 20px;
    margin-top: 10px;
}

.info-box li {
    margin-bottom: 8px;
    color: #333333;
    line-height: 1.6;
}

.aliases-list {
    margin-top: 15px;
}

.alias-item {
    background: #f8f9fa;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-family: 'Courier New', monospace;
    color: #1a1a1a;
    border: 2px solid #e0e0e0;
    transition: all 0.2s ease;
}

.alias-item:hover {
    background: #E8F0FF;
    border-color: #0073E6;
}

/* ============ EMAIL DISPLAY ============ */
.email-history, #inbox {
    max-height: 600px;
    overflow-y: auto;
    border-radius: 10px;
    background: #f8f9fa;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid #e0e0e0;
}

.email-history::-webkit-scrollbar, #inbox::-webkit-scrollbar {
    width: 8px;
}

.email-history::-webkit-scrollbar-track, #inbox::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 10px;
}

.email-history::-webkit-scrollbar-thumb, #inbox::-webkit-scrollbar-thumb {
    background: #0073E6;
    border-radius: 10px;
}

.email-history::-webkit-scrollbar-thumb:hover, #inbox::-webkit-scrollbar-thumb:hover {
    background: #0055B8;
}

.empty-state {
    text-align: center;
    color: #999999;
    padding: 40px 20px;
    font-style: italic;
}

.history-item {
    background: white;
    padding: 14px 16px;
    border-radius: 8px;
    border-left: 4px solid #0073E6;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    word-wrap: break-word;
}

.history-item:hover {
    box-shadow: 0 4px 12px rgba(0, 115, 230, 0.15);
    background: #E8F0FF;
}

.history-item .timestamp {
    font-size: 0.8em;
    color: #999999;
    font-weight: 600;
}

.history-item .details {
    margin-top: 8px;
    color: #333333;
    line-height: 1.6;
    font-size: 0.95em;
}

.history-item .details strong {
    color: #1a1a1a;
    display: inline-block;
    min-width: 70px;
}

/* ============ UTILITIES ============ */
small {
    color: #666666;
    font-size: 0.85em;
    display: block;
    margin-top: 5px;
}

.mt-10 { margin-top: 10px; }
.mb-10 { margin-bottom: 10px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

.footer-text {
    text-align: center;
    margin-top: 20px;
    color: #666666;
    font-size: 0.85em;
}

/* ============ RESPONSIVE DESIGN ============ */
@media (max-width: 768px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }

    .nav-content {
        height: auto;
        padding: 12px 20px;
        flex-wrap: wrap;
    }

    .dashboard-header h2 {
        font-size: 1.6em;
    }

    .submit-btn, .btn-primary {
        font-size: 0.95em;
        padding: 12px;
    }

    .card {
        padding: 20px;
    }

    .card h3 {
        font-size: 1.1em;
    }
}

/* ============ CHAT STYLES ============ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, #0073E6 0%, #0055B8 100%);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 12px rgba(0, 115, 230, 0.2);
}

.message.ai .message-content {
    background: white;
    color: #1a1a1a;
    border: 1px solid #e0e0e0;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-input-area {
    padding: 20px;
    background: white;
    border-top: 2px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
}

.chat-input:focus {
    outline: none;
    border-color: #0073E6;
    box-shadow: 0 0 0 4px rgba(0, 115, 230, 0.1);
}

.btn-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, #0073E6 0%, #0055B8 100%);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.95em;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 115, 230, 0.3);
}

.btn-clear {
    padding: 12px 20px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.btn-clear:hover {
    background: #333333;
    box-shadow: 0 4px 12px rgba(26, 26, 26, 0.3);
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0073E6;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* ============ ANIMATIONS ============ */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============ DARK MODE STYLES ============ */
.dark-mode {
    background: #0f0f0f;
}

.dark-mode body {
    background: #0f0f0f;
    color: #e0e0e0;
}

.dark-mode .dashboard {
    background: #1a1a1a;
}

.dark-mode .navbar {
    background: #0a0a0a;
    border-bottom-color: #404040;
}

.dark-mode .card {
    background: #1a1a1a !important;
    border-color: #404040;
    color: #e0e0e0;
}

.dark-mode .form-input,
.dark-mode .form-textarea,
.dark-mode select {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #404040;
}

.dark-mode .form-input:focus,
.dark-mode .form-textarea:focus,
.dark-mode select:focus {
    border-color: #00A8FF;
}

.dark-mode .form-group label {
    color: #e0e0e0;
}

.dark-mode .login-card {
    background: #1a1a1a;
    color: #e0e0e0;
}

.dark-mode .container {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
}

.dark-mode .btn-primary {
    background: linear-gradient(135deg, #00A8FF 0%, #0088CC 100%);
}

.dark-mode .btn-secondary {
    background: #2a2a2a;
    color: #e0e0e0;
}

.dark-mode .status-message {
    color: #e0e0e0;
}

.dark-mode .email-history {
    background: #0a0a0a;
    border-color: #404040;
}

.dark-mode .history-item {
    border-color: #404040;
    color: #e0e0e0;
}

.dark-mode .history-item:hover {
    background: #2a2a2a;
}

.dark-mode .chat-container {
    background: #1a1a1a;
}

.dark-mode .chat-messages {
    background: #0a0a0a;
}

.dark-mode .message {
    color: #e0e0e0;
}

.dark-mode .message.user {
    background: #0055B8;
}

.dark-mode .message.assistant {
    background: #2a2a2a;
}

.dark-mode .chat-input-area {
    background: #1a1a1a;
    border-top-color: #404040;
}

.dark-mode .chat-input {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #404040;
}

.dark-mode table {
    color: #e0e0e0;
    border-color: #404040;
}

.dark-mode th {
    background: #2a2a2a;
    color: #e0e0e0;
}

.dark-mode td {
    border-color: #404040;
}
