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

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

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(99, 102, 241, 0.6);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --gradient-1: #6366f1;
    --gradient-2: #8b5cf6;
    --gradient-3: #a855f7;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Animated Background */
.bg-animated {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3e 25%, #0a0a1a 50%, #1e1045 75%, #0a0a1a 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

.bg-animated::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Floating orbs */
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--gradient-1);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--gradient-3);
    bottom: -50px;
    left: -50px;
    animation-delay: -7s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: var(--gradient-2);
    top: 50%;
    left: 50%;
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(30px, -30px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    75% {
        transform: translate(15px, 15px) scale(1.02);
    }
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card .logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-card .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-3));
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 8px 25px var(--accent-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 8px 25px var(--accent-glow);
    }

    50% {
        box-shadow: 0 8px 40px rgba(99, 102, 241, 0.5);
    }
}

.login-card .logo-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.login-card .logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card .logo p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--border-focus);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    min-height: 180px;
    resize: vertical;
}

.form-group .input-icon {
    position: absolute;
    right: 14px;
    top: 40px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s;
}

.form-group input:focus~.input-icon {
    color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
    width: 100%;
}

.btn-primary:hover {
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

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

.btn-send {
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
    padding: 14px 36px;
}

.btn-send:hover {
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.btn-danger {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
}

/* Compose Page Layout */
.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
    min-height: 100vh;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    animation: fadeInUp 0.5s ease-out;
}

.app-header .brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-3));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.app-header .brand-icon svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.app-header .brand h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.app-header .brand span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.app-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header .user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    font-size: 0.8125rem;
    color: var(--accent-hover);
}

.app-header .btn-logout {
    padding: 8px 16px;
    font-size: 0.8125rem;
}

/* Compose Card */
.compose-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.compose-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.compose-card h3 svg {
    width: 22px;
    height: 22px;
    fill: var(--accent);
}

/* Toggle CC/BCC */
.toggle-fields {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.toggle-fields button {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-fields button:hover,
.toggle-fields button.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.hidden {
    display: none !important;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    margin-bottom: 8px;
}

.file-upload-area:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.03);
}

.file-upload-area.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.file-upload-area svg {
    width: 36px;
    height: 36px;
    fill: var(--text-muted);
    margin-bottom: 8px;
}

.file-upload-area p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.file-upload-area span {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.file-list {
    list-style: none;
    padding: 0;
}

.file-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.file-list li .remove-file {
    color: var(--error);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.file-list li .remove-file:hover {
    background: var(--error-bg);
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* Alerts */
.alert {
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: fadeInUp 0.4s ease-out;
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.alert-success svg {
    fill: var(--success);
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.alert-error svg {
    fill: var(--error);
}

/* Loading Spinner */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

/* Password toggle */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.3s;
}

.password-toggle:hover {
    color: var(--accent);
}

/* Responsive */
@media (max-width: 640px) {
    .login-card {
        padding: 32px 24px;
    }

    .compose-card {
        padding: 24px 20px;
    }

    .app-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-send {
        width: 100%;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Character counter */
.char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Sent history badge */
.sent-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 6px;
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 500;
}