@import '../variables.css';

/* Login Page Styles */
html {
    height: 100%;
    overflow: hidden;
    /* Verhindert Scrolling auf HTML-Ebene */
    -webkit-overflow-scrolling: none;
    touch-action: none;
}
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    height: 100vh; /* Feste Höhe für mobile Geräte */
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    position: relative;
    overflow: hidden;
    /* Mobile-spezifische Scroll-Verhinderung */
    touch-action: none;
    -webkit-overflow-scrolling: none;
}

/* Animated Background Pattern */
body::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: backgroundMove 20s linear infinite;
    opacity: 0.3;
}

@keyframes backgroundMove {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(50px, 50px);
    }
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow:
            0 20px 60px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: slideUp 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .login-container {
        background: rgba(22, 27, 34, 0.95);
        box-shadow:
                0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    }
}

.logo-container {
    margin-bottom: 2.5rem;
    animation: fadeIn 0.6s ease 0.2s both;
}

.logo {
    max-width: 180px;
    height: auto;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform var(--transition-base);
}

.logo:hover {
    transform: scale(1.05);
}

.login-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.login-demo-banner {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.35rem auto 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    background: rgba(255, 214, 102, 0.18);
    border: 1px solid rgba(255, 214, 102, 0.4);
    color: var(--text-color);
    font-weight: 700;
    font-size: 0.95rem;
}

.demo-info {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.login-demo-hint {
    margin: 0 0 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    background: rgba(255, 214, 102, 0.12);
    border: 1px solid rgba(255, 214, 102, 0.3);
    color: var(--text-color);
    font-size: 0.95rem;
    text-align: left;
}

.login-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.8rem;
    text-align: left;
    animation: fadeIn 0.6s ease 0.3s both;
}

.form-group:nth-child(2) {
    animation-delay: 0.4s;
}

.form-label {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    transition: color var(--transition-base);
    pointer-events: none;
    z-index: 2;
}

.form-control {
    width: 100%;
    padding: 0.9rem 1rem 0.9rem 2.8rem;
    background-color: var(--inner-container-background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-color);
    transition: all var(--transition-base);
    box-sizing: border-box;
}

.form-control:hover {
    border-color: var(--accent-primary);
    background-color: var(--card-hover);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background-color: var(--inner-container-background);
}

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

/* Password visibility toggle */
.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition-base);
    z-index: 2;
}

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

.login-button {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    margin-top: 1.5rem;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.6s ease 0.5s both;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.login-button:hover::before {
    width: 300px;
    height: 300px;
}

.login-button:active {
    transform: translateY(0);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Remember me + forgot password */
.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    font-size: 0.9rem;
    width: 100%;
    flex-wrap: wrap;
}

.remember-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex: 1 1 auto;
    min-width: 220px;
    position: relative;
}

.remember-option {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.remember-option span {
    color: var(--text-secondary);
    transition: color var(--transition-base);
}

:root[data-theme="dark"] .remember-option span {
    color: color-mix(in srgb, var(--accent-primary) 60%, white);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .remember-option span {
        color: color-mix(in srgb, var(--accent-primary) 60%, white);
    }
}

.remember-option input[type="checkbox"] {
    margin-right: 0.45rem;
    cursor: pointer;
}

.remember-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: transform var(--transition-base), box-shadow var(--transition-base), background-color var(--transition-base);
    padding: 0;
    line-height: 1;
    font-family: inherit;
}

.remember-tooltip:hover,
.remember-tooltip:focus {
    transform: translateY(-1px);
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.remember-tooltip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.remember-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.6rem);
    left: 50%;
    transform: translate(-50%, 8px);
    padding: 0.55rem 0.7rem;
    background-color: var(--inner-container-background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
    max-width: min(260px, calc(100vw - 48px));
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base), transform var(--transition-base);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
    z-index: 10;
    text-align: left;
    white-space: normal;
}

.remember-tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 0.2rem);
    left: 50%;
    transform: translate(-50%, 4px);
    border-width: 6px;
    border-style: solid;
    border-color: var(--inner-container-background) transparent transparent transparent;
    opacity: 0;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.remember-tooltip:hover::after,
.remember-tooltip:focus::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

.remember-tooltip:hover::before,
.remember-tooltip:focus::before {
    opacity: 1;
    transform: translate(-50%, 0);
}

@supports (color: color-mix(in srgb, white 50%, black)) {
    .remember-tooltip {
        border-color: color-mix(in srgb, var(--accent-primary) 55%, white);
    }
}

.login-options .forgot-password {
    margin-left: auto;
    white-space: nowrap;
    flex: 0 0 auto;
}

.forgot-password {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color var(--transition-base);
}

.forgot-password:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

:root[data-theme="dark"] .forgot-password {
    color: color-mix(in srgb, var(--accent-primary) 60%, white);
}

:root[data-theme="dark"] .forgot-password:hover {
    color: color-mix(in srgb, var(--accent-primary) 80%, white);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .forgot-password {
        color: color-mix(in srgb, var(--accent-primary) 60%, white);
    }

    :root:not([data-theme]) .forgot-password:hover {
        color: color-mix(in srgb, var(--accent-primary) 80%, white);
    }
}

@media (max-width: 520px) {
    .login-options {
        justify-content: center;
    }

    .remember-wrapper {
        flex: 1 1 100%;
        justify-content: center;
        gap: 0.6rem;
    }

    .login-options .forgot-password {
        margin-left: 0;
        order: 2;
        width: 100%;
        text-align: center;
    }

    .remember-tooltip::after {
        max-width: min(260px, calc(100vw - 48px));
    }
}

/* Error and Success Messages */
.message {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    font-size: 0.9rem;
    display: none;
    animation: slideDown 0.3s ease;
    position: relative;
    padding-left: 3rem;
}

.message::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.error-message {
    background: linear-gradient(135deg, color-mix(in srgb, var(--danger-color) 12%, white) 0%, color-mix(in srgb, var(--danger-color) 28%, white) 100%);
    color: var(--danger-color);
    border: 1px solid color-mix(in srgb, var(--danger-color) 32%, white);
}

.error-message::before {
    background: var(--danger-color);
    content: '!';
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.success-message {
    background: linear-gradient(135deg, color-mix(in srgb, var(--success-color) 12%, white) 0%, color-mix(in srgb, var(--success-color) 24%, white) 100%);
    color: var(--success-color);
    border: 1px solid color-mix(in srgb, var(--success-color) 30%, white);
}

.success-message::before {
    background: var(--success-color);
    content: '✓';
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.visible {
    display: block;
}

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

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

/* Loading Spinner */
.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

.login-button.loading .button-text {
    opacity: 0;
}

.login-button.loading .spinner {
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-container {
        margin: 1rem;
        padding: 2rem;
        max-width: calc(100% - 2rem);
    }

    .logo {
        max-width: 150px;
    }

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

@media (max-width: 480px) {
    body {
        background: linear-gradient(180deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    }

    .login-container {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }

    .logo {
        max-width: 120px;
    }

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

    .form-control {
        padding: 0.8rem 1rem 0.8rem 2.5rem;
    }

    .login-button {
        padding: 0.9rem;
        font-size: 1rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
/* Popup Styling */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.popup-content {
    background-color: var(--card-color);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.popup-title {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.popup-message {
    margin-bottom: 20px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.popup-button {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.popup-button:hover {
    background-color: color-mix(in srgb, var(--accent-primary) 85%, black);
}

.tenant-switch {
    position: fixed;
    bottom: 1.1rem;
    right: 1.1rem;
    margin: 0;
    padding: 0.35rem 0.65rem;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    color: var(--text-secondary);
    opacity: 0.65;
    z-index: 5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tenant-switch:hover,
.tenant-switch:focus-within {
    opacity: 1;
    transform: translateY(-1px);
}

.tenant-switch-form {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.tenant-switch-button {
    border: none;
    background: none;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.45rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    opacity: 0.85;
    transition: color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.tenant-switch-button:hover,
.tenant-switch-button:focus {
    color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.tenant-switch-button:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
    .tenant-switch-button:hover,
    .tenant-switch-button:focus {
        background: rgba(255, 255, 255, 0.08);
    }
}

@media (max-width: 640px) {
    .tenant-switch {
        top: 0.8rem;
        bottom: auto;
        right: 0.8rem;
        left: auto;
        padding: 0.3rem 0.45rem;
        opacity: 0.85;
    }

    .tenant-switch-button {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }
}
