/* ============================================
   0-Day Security — DRP Mail
   Design System & Styles
   ============================================ */

/* ── CSS Custom Properties ── */
:root {
    /* Brand Colors */
    --primary:        #0078d4;
    --primary-hover:  #005a9e;
    --primary-light:  #4da3e8;
    --accent:         #00b4d8;
    --accent-light:   #48cae4;

    /* Status Colors */
    --success:        #2ed573;
    --success-bg:     rgba(46, 213, 115, 0.1);
    --error:          #ff4757;
    --error-bg:       rgba(255, 71, 87, 0.1);
    --warning:        #ffa502;
    --warning-bg:     rgba(255, 165, 2, 0.1);

    /* Surfaces */
    --bg-primary:     #06080f;
    --bg-secondary:   #0c1220;
    --bg-card:        rgba(12, 18, 35, 0.85);
    --bg-card-border: rgba(255, 255, 255, 0.06);
    --bg-input:       rgba(255, 255, 255, 0.04);
    --bg-input-focus: rgba(255, 255, 255, 0.07);
    --bg-hover:       rgba(255, 255, 255, 0.05);

    /* Text */
    --text-primary:   #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted:     #5f6368;
    --text-inverse:   #ffffff;

    /* Typography */
    --font-sans:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --space-xs:       0.25rem;
    --space-sm:       0.5rem;
    --space-md:       1rem;
    --space-lg:       1.5rem;
    --space-xl:       2rem;
    --space-2xl:      3rem;

    /* Borders */
    --radius-sm:      0.5rem;
    --radius-md:      0.75rem;
    --radius-lg:      1rem;
    --radius-xl:      1.25rem;
    --radius-full:    9999px;

    /* Shadows */
    --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md:      0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg:      0 8px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow:    0 0 20px rgba(0, 120, 212, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ── Animated Background ── */
.bg-gradient {
    position: fixed;
    inset: 0;
    z-index: -2;
    background: linear-gradient(
        135deg,
        var(--bg-primary) 0%,
        #0a1628 25%,
        #0d1b33 50%,
        #081420 75%,
        var(--bg-primary) 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    25%      { background-position: 50% 0%; }
    50%      { background-position: 100% 50%; }
    75%      { background-position: 50% 100%; }
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 40%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 40%, transparent 100%);
}

/* ── Layout ── */
.main-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: var(--space-lg);
}

/* ── Card (Glassmorphism) ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
    opacity: 0.7;
}

.card-login {
    max-width: 440px;
}

.card-mail {
    max-width: 680px;
}

.card-result {
    max-width: 520px;
    text-align: center;
}

/* ── Login Header ── */
.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.logo-icon {
    margin-bottom: var(--space-md);
    animation: pulse 3s ease-in-out infinite;
}

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

.login-title {
    font-size: 1.625rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ── Mail Header ── */
.mail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.mail-header-left {
    flex: 1;
    min-width: 200px;
}

.mail-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.mail-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    letter-spacing: -0.02em;
}

.mail-title svg {
    color: var(--primary);
    flex-shrink: 0;
}

.mail-subtitle {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--bg-card-border);
}

/* ── Form ── */
.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.label-icon {
    color: var(--primary-light);
    flex-shrink: 0;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-base);
}

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

.form-input:hover {
    background: var(--bg-input-focus);
    border-color: rgba(255, 255, 255, 0.1);
}

.form-input:focus {
    background: var(--bg-input-focus);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15), var(--shadow-glow);
}

.form-input.is-valid {
    border-color: var(--success);
}

.form-input.is-invalid {
    border-color: var(--error);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239aa0a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

.form-textarea {
    resize: vertical;
    min-height: 140px;
    max-height: 400px;
    line-height: 1.7;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 18px;
}

.form-hint-counter {
    text-align: right;
}

.form-hint.is-error {
    color: var(--error);
}

/* ── Password Toggle ── */
.input-password-wrapper {
    position: relative;
}

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

.btn-toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-password:hover {
    color: var(--text-primary);
}

/* ── Signature Preview ── */
.signature-preview {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    transition: opacity var(--transition-base);
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.signature-img {
    max-width: 100%;
    max-height: 160px;
    height: auto;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* ── File Upload Dropzone ── */
.file-dropzone {
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.file-dropzone:hover,
.file-dropzone.is-dragover {
    border-color: var(--primary);
    background: rgba(0, 120, 212, 0.05);
}

.file-dropzone.is-dragover {
    transform: scale(1.01);
}

.file-input-hidden {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.dropzone-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.dropzone-link {
    color: var(--primary-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dropzone-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
}

.file-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    overflow: hidden;
}

.file-info svg {
    color: var(--primary-light);
    flex-shrink: 0;
}

.file-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    flex-shrink: 0;
}

.btn-remove-file:hover {
    color: var(--error);
    background: var(--error-bg);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: var(--text-inverse);
    box-shadow: 0 2px 12px rgba(0, 120, 212, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 120, 212, 0.5);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 120, 212, 0.3);
}

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

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

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-sm {
    font-size: 0.8125rem;
    padding: 8px 14px;
}

.btn-full {
    width: 100%;
}

.btn-send {
    margin-top: var(--space-sm);
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-text,
.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ── Spinner ── */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--text-inverse);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Alert ── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: var(--space-md);
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid rgba(255, 71, 87, 0.2);
    color: #ffa0a8;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(46, 213, 115, 0.2);
    color: #7aeaa0;
}

.alert-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

/* ── Divider ── */
.divider {
    height: 1px;
    background: var(--bg-card-border);
    margin: var(--space-sm) 0;
}

.divider-subtle {
    opacity: 0.5;
}

/* ── Result Page ── */
.result-icon {
    margin: var(--space-md) auto var(--space-lg);
}

.result-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.02em;
}

.result-title-success {
    color: var(--success);
}

.result-title-error {
    color: var(--error);
}

.result-message {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    line-height: 1.6;
}

.result-message-error {
    color: #ffa0a8;
    text-align: left;
    background: var(--error-bg);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 71, 87, 0.15);
}

.result-details {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    text-align: left;
}

.result-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    gap: var(--space-md);
}

.result-detail-row:last-child {
    border-bottom: none;
}

.result-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.result-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.result-actions {
    margin-top: var(--space-md);
}

/* ── Checkmark Animation ── */
.checkmark-circle {
    stroke-dasharray: 226;
    stroke-dashoffset: 226;
    animation: drawCircle 0.6s ease-out 0.2s forwards;
}

.checkmark-check {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    animation: drawCheck 0.4s ease-out 0.7s forwards;
}

@keyframes drawCircle {
    to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease-out;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    max-width: 400px;
}

.toast-success {
    background: rgba(46, 213, 115, 0.15);
    border: 1px solid rgba(46, 213, 115, 0.3);
    color: #7aeaa0;
}

.toast-error {
    background: rgba(255, 71, 87, 0.15);
    border: 1px solid rgba(255, 71, 87, 0.3);
    color: #ffa0a8;
}

.toast-warning {
    background: rgba(255, 165, 2, 0.15);
    border: 1px solid rgba(255, 165, 2, 0.3);
    color: #ffd060;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-exit {
    animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

/* ── Animations ── */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

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

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-8px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: var(--space-md) var(--space-lg);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .main-container {
        padding: var(--space-md);
        align-items: flex-start;
        padding-top: var(--space-xl);
    }

    .card {
        padding: var(--space-xl) var(--space-lg);
    }

    .mail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .mail-header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .result-detail-row {
        flex-direction: column;
        gap: 2px;
    }

    .result-value {
        text-align: left;
    }

    .file-name {
        max-width: 180px;
    }
}

@media (max-width: 480px) {
    :root {
        font-size: 15px;
    }

    .card {
        padding: var(--space-lg) var(--space-md);
        border-radius: var(--radius-lg);
    }

    .login-title {
        font-size: 1.375rem;
    }

    .mail-title {
        font-size: 1.125rem;
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
    }

    .toast {
        max-width: 100%;
    }
}
