:root {
    /* Light mode colors */
    --bg-primary: #f5f7fa;
    --bg-secondary: white;
    --bg-tertiary: #f9fafb;
    --text-primary: #374151;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-hover: #d1d5db;
    --accent-primary: #4f46e5;
    --accent-secondary: #7c3aed;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --success-border: #a7f3d0;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --error-border: #fca5a5;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.3);
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #1f2937;
    --bg-secondary: #374151;
    --bg-tertiary: #4b5563;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #4b5563;
    --border-hover: #6b7280;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --success-bg: #064e3b;
    --success-text: #a7f3d0;
    --success-border: #065f46;
    --error-bg: #7f1d1d;
    --error-text: #fca5a5;
    --error-border: #991b1b;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.2);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 100;
    padding: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.header .theme-toggle {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: inline-block;
    text-decoration: none;
    line-height: 1;
    box-sizing: border-box;
    /* CSS Reset to normalize button and anchor differences */
    margin: 0;
    vertical-align: baseline;
    font-family: inherit;
    font-style: inherit;
    font-variant: inherit;
}

.header .theme-toggle:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* Header button styles - more specific to avoid conflicts */
.header .btn {
    padding: 10px 16px; /* Match theme toggle padding */
    border: 2px solid rgba(255,255,255,0.3); /* Match theme toggle border */
    border-radius: 10px; /* Match theme toggle border radius */
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    font-size: 14px; /* Match theme toggle font size */
    width: auto; /* Override form button width */
    line-height: 1; /* Match theme toggle line height */
    box-sizing: border-box; /* Match theme toggle box sizing */
    backdrop-filter: blur(10px); /* Match theme toggle backdrop filter */
    /* CSS Reset to normalize button and anchor differences */
    margin: 0;
    vertical-align: baseline;
    font-family: inherit;
    font-style: inherit;
    font-variant: inherit;
    background: rgba(255,255,255,0.2); /* Ensure same background */
    color: white; /* Ensure same text color */
}

.header .btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
}

.header .btn-secondary:hover {
    background: rgba(255,255,255,0.3);
    border: 2px solid rgba(255,255,255,0.3); /* Maintain consistent border on hover */
}

.login-container {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    position: relative;
    border: 1px solid var(--border-color);
    margin: 120px auto 40px; /* Increased top margin to account for new header */
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
    margin-top: 20px;
}

.login-header h1 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 2rem;
    font-weight: 700;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-section {
    margin-bottom: 25px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-toggle {
    background: transparent;
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.section-toggle:hover {
    background: var(--accent-primary);
    color: white;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    transform: translateY(-1px);
}

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

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

.form-status {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    width: 100%;
    padding: 15px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

#loginModal .btn-secondary {
    width: 100%;
}

.form-links a {
    color: var(--accent-primary);
    text-decoration: underline;
    font-size: 14px;
    transition: color 0.3s ease;
}

.form-links a:hover {
    color: var(--accent-secondary);
}

.alert {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    text-align: center;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.register-section {
    text-align: center;
    margin-top: 20px;
}

.register-summary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.register-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.register-summary-item:last-child {
    margin-bottom: 0;
}

.register-summary-label {
    font-weight: 500;
    color: var(--text-primary);
}

.register-summary-value {
    color: var(--text-secondary);
    font-size: 14px;
}


/* Register Form */
.register-form {
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.register-form.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.register-form h3 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-primary);
}

/* Tenant Info Display */
.tenant-info {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 10px;
    margin-bottom: 15px;
    display: none;
}

.tenant-info .tenant-name {
    font-weight: 600;
    color: var(--success-text);
}

.tenant-info .tenant-description {
    font-size: 12px;
    color: var(--success-text);
    opacity: 0.8;
    margin-top: 4px;
}

/* Loading state */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Helper text */
.helper-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 480px) {
    .login-container {
        padding: 30px 25px;
        margin: 80px 10px 10px;
    }

    .login-header h1 {
        font-size: 1.7rem;
    }

}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
}

.hidden {
    display: none !important;
}
