* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 450px;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.login-header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 600;
}

.login-header p {
    font-size: 14px;
    opacity: 0.9;
}

.login-form {
    padding: 40px 30px;
}

.form-group {
    position: relative;
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input::placeholder {
    color: #999;
}

/* Login Type Selector */
.login-type-selector {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.login-type-selector > label {
    margin-bottom: 12px;
    font-weight: 600;
    color: #333;
}

.radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
    flex: 1;
    min-width: 150px;
}

.radio-label:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.radio-label input[type="radio"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #667eea;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: #667eea;
}

.radio-label span {
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
}

/* Field Hint */
.field-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* User Type Bubble */
.user-type-bubble {
    position: absolute;
    top: 5px;
    right: 10px;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: bubbleFadeIn 0.3s ease;
    z-index: 10;
    white-space: nowrap;
    border: none;
}

@keyframes bubbleFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-type-bubble.internal {
    background: #4F46E5;
}

.user-type-bubble.farmer {
    background: #10B981;
}

.user-type-bubble.retailer {
    background: #8B5CF6;
}

.user-type-bubble.dealer {
    background: #F59E0B;
}

.user-type-bubble.unknown {
    background: #6B7280;
}

.login-button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.login-button:active {
    transform: translateY(0);
}

.login-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.login-button.loading span {
    visibility: hidden;
}

.login-button.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-message,
.success-message {
    margin-top: 20px;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-message {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
    display: none; /* Hide by default */
}

/* Show error message only when it has content */
.error-message:not(:empty) {
    display: block;
}

/* Field-specific validation messages below inputs */
.field-validation-error {
    display: block;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 5px;
    animation: fadeIn 0.3s ease;
}

.field-validation-valid {
    display: none;
}

.success-message {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #66bb6a;
}

.login-footer {
    background: #f5f5f5;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.login-footer p {
    font-size: 13px;
    color: #666;
}

/* Portal Selection Modal */
.portal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.portal-modal-content {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.portal-modal-content h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    color: #333;
    text-align: center;
}

.portal-modal-content p {
    margin: 0 0 30px 0;
    font-size: 16px;
    color: #666;
    text-align: center;
}

.portal-buttons {
    display: flex;
    gap: 20px;
    flex-direction: column;
}

.portal-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    border: 3px solid transparent;
    border-radius: 12px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.portal-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.admin-btn {
    border-color: #667eea;
}

.admin-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-btn {
    border-color: #10B981;
}

.user-btn:hover {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
}

.portal-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.portal-label {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 5px;
}

.portal-desc {
    font-size: 14px;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 480px) {
    .login-card {
        border-radius: 0;
    }

    .login-header {
        padding: 30px 20px;
    }

    .login-header h1 {
        font-size: 24px;
    }

    .login-form {
        padding: 30px 20px;
    }
    
    .portal-modal-content {
        padding: 25px;
    }
    
    .portal-buttons {
        gap: 15px;
    }
    
    .portal-btn {
        padding: 20px;
    }
}